2007/11/27, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > Hi all, > > I am building my own little automated LFS install script in Bash. > Basically its a copy-paste job from LFS book, of course, with minor > corrections for function. > > One of the things i find difficult to script is a "nice" (read pretty) > way of continuing the install script after doing "su - lfs". the 'su' > command apparently starts a subshell process, and so the new subshell > just waits for user action, pausing the whole install script that > started the 'su'. And I cannot make it continue with the script as the > 'lfs' user, since, well su just blocks, and that is the way it works. > > Why can't the book just silently change user id instead ? > > I could alternatively do a 'su -c ./lfs-continue - lfs', essentially > passing control further via another script, but then again, i also > have variables that i need the 'lfs' user shell inherit, which I > create on my own, for different purposes. Things like timeout values, > etc... (not part of LFS, although the $LFS variable would be nice to > have exported). > The easiest and probably best thing to do (I do it ;) is to use something like this in .bashrc for the lfs user: cd $LFS/sources sh stage1-static.sh 2>&1 | tee /mnt/lfs/sources/logs/detailed-stage1.log exit
Of course your scripts need to be in $LFS/sources/[somewhere]. After the lfs user automatically finished the static tools mount the virutal fs: su - lfs mount .... (see the book) chroot "$LFS" /tools/bin/env -i HOME=/root TERM="$TERM" PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" /tools/bin/bash --login +h /sources/stage2-wrapper.sh This way the lfs user builds everything static, exits nicely if everything worked out OK and your script is back in control. After this, I execute a script (in this case called /sources/stage2-wrapper.sh) which builds the rest of the system. -- http://linuxfromscratch.org/mailman/listinfo/lfs-support FAQ: http://www.linuxfromscratch.org/lfs/faq.html Unsubscribe: See the above information page