I use bootable USB flash drives in simple text console mode. Rather than finishing the boot in my home folder (~ or /home/tc), I would like to exit with my pwd located at the boot device /mnt/sd? directory. I am trying to make a change to /opt/bootlocal.sh but I am not succeeding.
I am using tc-functions find_mountpoint and $MOUNTPOINT. I think I understand my problem exists because scripts run a sub-shell and all newly exported system environment variables are lost after the sub-shell is terminated. The child process does not control the parent process.
I tried a few different ways which are commented out below... any suggestions how to finish booting and landing at the boot device /mnt/sd? directory?
#!/bin/bash
source /etc/init.d/tc-functions
readonly MYLABEL="SEABOOT"; # my USB flash drives always have this label
declare MNTPATH="";
#------------------------------------------------------
function _bootguess () {
local default_blkid="";
default_blkid=$(blkid -L "${MYLABEL}");
BOOTFROM=${default_blkid};
BOOTFROM=$(echo ${BOOTFROM/\/dev\//}); #string substitution delete
#echo ${BOOTFROM};
find_mountpoint ${BOOTFROM}; # one of the tc-functions
#echo ${MOUNTPOINT}; # one of the tc-functions globals
MNTPATH=${MOUNTPOINT};
}
_bootguess
echo ${MNTPATH}
# try #1
#cd ${MNTPATH}
# try #2
#export PWD=${MNTPATH}
# try 3
#shopt -s expand_aliases
#alias cm='cd ${MNTPATH}';
#cm
pwd
Thanks in advance, as always, I appreciate your good advice.
thx
Billy