diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh index de7dfc664d..6dd210a65e 100755 --- a/sdk_lib/enter_chroot.sh +++ b/sdk_lib/enter_chroot.sh @@ -282,16 +282,18 @@ function setup_env { # Turn off automounting of external media when we enter the # chroot; thus we don't have to worry about being able to unmount # from inside. - if [ $(which gconftool-2 2>/dev/null) ]; then - gconftool-2 -g ${AUTOMOUNT_PREF} > \ - "${FLAGS_chroot}${SAVED_AUTOMOUNT_PREF_FILE}" - if [ $(gconftool-2 -s --type=boolean ${AUTOMOUNT_PREF} false) ]; then - warn "-- Note: USB sticks may be automounted by your host OS." - warn "-- Note: If you plan to burn bootable media, you may need to" - warn "-- Note: unmount these devices manually, or run image_to_usb.sh" - warn "-- Note: outside the chroot." + if SAVED_PREF=$(gconftool-2 -g ${AUTOMOUNT_PREF} 2>/dev/null); then + if [ "${SAVED_PREF}" != "false" ]; then + if [ $(gconftool-2 -s --type=boolean ${AUTOMOUNT_PREF} false) ]; then + warn "-- Note: USB sticks may be automounted by your host OS." + warn "-- Note: If you plan to burn bootable media, you may need to" + warn "-- Note: unmount these devices manually, or run image_to_usb.sh" + warn "-- Note: outside the chroot." + fi fi fi + # Always write the temp file so we can read it when exiting + echo "${SAVED_PREF:-false}" > "${FLAGS_chroot}${SAVED_AUTOMOUNT_PREF_FILE}" if [ -d "$HOME/.subversion" ]; then TARGET="/home/${USER}/.subversion" @@ -377,8 +379,8 @@ function teardown_env { # Remove any dups from lock file while installing new one sort -n "$TMP_LOCKFILE" | uniq > "$LOCKFILE" - if [ $(which gconftool-2 2>/dev/null) ]; then - SAVED_PREF=$(cat "${FLAGS_chroot}${SAVED_AUTOMOUNT_PREF_FILE}") + SAVED_PREF=$(<"${FLAGS_chroot}${SAVED_AUTOMOUNT_PREF_FILE}") + if [ "${SAVED_PREF}" != "false" ]; then gconftool-2 -s --type=boolean ${AUTOMOUNT_PREF} ${SAVED_PREF} || \ warn "could not re-set your automount preference." fi