General TC > Programming & Scripting - Unofficial
After booting USB to console can I finish in /mnt/sd# instead of /home/tc?
Rudock1:
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?
--- Code: ---#!/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
--- End code ---
Thanks in advance, as always, I appreciate your good advice.
thx
Billy
Rich:
Hi Rudock1
There is no variable that records the boot device. The best you can hope for is to derive the boot device by ensuring it contains
your tce directory and including the boot code:
--- Code: ---tce=UUID="Place your devices UUID here"
--- End code ---
Knowing the tce directory you are using is on the boot device allows you to find it like this:
--- Code: ---tc@E310:~$ readlink /etc/sysconfig/tcedir | cut -d '/' -f 2,3
mnt/sda1
tc@E310:~$
--- End code ---
Rudock1:
Thanks, Rich,
I like your method of determining /mnt/sda1 (in your example, and my system too). I added that to my bootlocal.sh but I am still finishing the boot sequence at ~ (/home/tc) rather than at the /mnt/sda1 prompt. Wondering how to make that last 'cd /mnt/sda1' stick.
thx
Billy
Rich:
Hi Rudock1
I think you could add it to your .profile file in your home directory. Something like this:
--- Code: ---TERMTYPE=`/usr/bin/tty`
[ ${TERMTYPE:5:3} == "tty" ] && (
[ ! -f /etc/sysconfig/Xserver ] ||
[ -f /etc/sysconfig/text ] ||
[ -e /tmp/.X11-unix/X0 ] ||
startx
)
cd /`readlink /etc/sysconfig/tcedir | cut -d '/' -f 2,3`
--- End code ---
If that doesn't work, try adding it just above the TERMTYPE=`/usr/bin/tty` line.
Rich:
Hi Rudock1
--- Quote ---cd /`readlink /etc/sysconfig/tcedir | cut -d '/' -f 2,3`
--- End quote ---
In case you didn't realize it, the green punctuation marks are single quotes (on the " key). The red punctuation marks are back ticks
(on the ~ key).
Navigation
[0] Message Index
[#] Next page
Go to full version