#!/bin/sh #################################################################### # # bootprofile: Allow users to select distinct bootprofile based on # desired networked environment on Linux at boot time. # #################################################################### # Copyright (C) 2002 Rajeev Kumar # Shell Version Copyright (C) 2003 Al Tobey # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, # Boston, MA 02111-1307 USA # # Rajeev Kumar (rajeev@rajeevnet.com) # Albert P Tobey (tobeya@tobert.org) ################################################################### # #DISCLAIMER: # THIS SOFTWARE RUNS AS A ROOT AT A VERY EARLY STAGE OF LINUX BOOT. # IMPROPER USE OF THIS SOFTWARE MAY CAUSE BOOT PROBLEMS OR OTHER # POSSIBLE DAMAGES TO YOUR SYSTEM. USE THIS SOFTWARE AT YOUR OWN # RISK. AUTHOR ASSUMES NO RESPONSIBILITY FOR ANY DAMAGE(S) CAUSED # BY THE USE OF THIS SOFTWARE. ################################################################### # ---------------------------------------------------------------------------- # # FUNCTIONS # ---------------------------------------------------------------------------- # function doprofile { prof=$1 exec 5\$counter )) do sleep 1 counter=\$(( \$counter + 1 )) (ps -e |grep -qE '^\\ *$$.*bootprofile.sh\$') || exit 0 done echo "Time is up ... booting with previous profile." if ( ps -e |grep -qE '^\\ *$$.*bootprofile.sh\$' ) ; then kill $$ fi EOCMD } function mkline { echo "--------------------------------------------------------------------------------" } # ---------------------------------------------------------------------------- # # MAIN # --------------------------------------------------------------------------- # [ ! -f /etc/sysconfig/bootprofile ] && exit 1 . /etc/sysconfig/bootprofile # parse options while [ $# -ne 0 ] do case $1 in --execute) EXECUTE=1 shift ;; --test) unset EXECUTE VERBOSE=1 shift ;; --verbose) VERBOSE=1 shift ;; --nocmdline) NOCMDLINE=1 shift ;; *) ;; esac done # check to make sure bootprofile is enabled [ -z "$BOOTPROFILE" -o "$BOOTPROFILE" != "ON" ] && exit 0 # start the timeout a'tickin' timeout & if [ -z "$NOCMDLINE" ] ; then if ( grep -q 'bootprofile=' /proc/cmdline ) ; then profile=`tr ' ' '\n'