#!/bin/bash # This script should be called late in the boot process. It # will check to see if any of the AMI tools need to be customized # and will run the individual tool customization scripts. # # Rich Carlson 4/21/06 # ANSI COLORS NORMAL="" RED="" GREEN="" YELLOW="" BLUE="" MAGENTA="" CYAN="" WHITE="" NEED=0 STATICIP=0 BWCTL=0 NDT=0 NPAD=0 NTP=0 OWAMP=0 USB=0 # bring in NPT functions for later use ENV="env -i PATH=/lib/init:/bin:/sbin:/usr/bin" . /lib/init/nptoolkit-functions.sh if [ -f /tmp/customize.staticip ]; then USB=1 NEED=1 fi if [ -f /tmp/customize.staticip ]; then STATICIP=1 NEED=1 fi if [ -f /tmp/customize.bwctld ]; then BWCTL=1 NEED=1 fi if [ -f /tmp/customize.ndt ]; then NDT=1 NEED=1 fi if [ -f /tmp/customize.npad ]; then NPAD=1 NEED=1 fi if [ -f /tmp/customize.ntpd ]; then NTP=1 NEED=1 fi if [ -f /tmp/customize.owampd ]; then OWAMP=1 NEED=1 fi if [ $NEED == 0 ]; then # All tools have been customized, so there's no # need to prompt the user for some action. Simply # exit, they can always manually run the customization # scripts. echo "${GREEN}All tools have been customized, exiting.${NORMAL}" exit 0 fi # setup a loop to prompt the user for action. answer="" while [ "$answer" != "0" ]; do echo "${NORMAL}Internet2 Network Performance Tool Customization script" echo " Tools listed in ${RED}RED${NORMAL} need to be customized" echo -n "${NORMAL} 1. " echo "${MAGENTA}Setup Drive(s) to hold customization files${NORMAL}" echo -n "${NORMAL} 2. " if [ $BWCTL == 1 ]; then echo "${RED}bwctl${NORMAL}" else echo "${GREEN}bwctl${NORMAL}" fi echo -n "${NORMAL} 3. " if [ $NDT == 1 ]; then echo "${RED}ndt${NORMAL}" else echo "${GREEN}ndt${NORMAL}" fi echo -n "${NORMAL} 4. " if [ $NPAD == 1 ]; then echo "${RED}npad${NORMAL}" else echo "${GREEN}npad${NORMAL}" fi echo -n "${NORMAL} 5. " if [ $NTP == 1 ]; then echo "${RED}ntp${NORMAL}" else echo "${GREEN}ntp${NORMAL}" fi echo -n "${NORMAL} 6. " if [ $OWAMP == 1 ]; then echo "${RED}owamp${NORMAL}" else echo "${GREEN}owamp${NORMAL}" fi echo -n "${NORMAL} 7. " echo "${MAGENTA}staticIP${NORMAL}" echo "${NORMAL} 0. exit" answer=0 TMOUT=20 read answer case $answer in 0) exit ;; 1) # run Main customize script echo "Configuring system drive(s) to support customized tools." mount_NPT_drives select_drive if [ "$DRVS" == "" ] ; then echo "Warning: No drives available to hold customization files." echo "Check your internal hard drive, or insert a thumb drive." else cnt=0 for DRV in $DRVS ; do is_NPT_usb $DRV if [ $USB == 0 ] ; then echo -n "Configure Internal Harddrive '$DRV' to hold NPToolkit customization files? [y] - " else echo -n "Configure External USB drive '$DRV' to hold NPToolkit customization files? [y] - " fi read ans if [ "$ans" == "n" ] || [ "$ans" == "no" ] ; then continue fi /bin/cp /usr/local/etc/knoppix.sh /UNIONFS/media/$DRV /bin/mkdir /UNIONFS/media/$DRV/NPTools 2> /dev/null echo "done." if [ $cnt == 1 ] ; then echo "Information: more than 1 drive is being configured." fi cnt=`expr $cnt + 1` done fi USB=0 ;; 2) # run Bwctl customize script /usr/local/bin/create-bwctld.sh /bin/rm /tmp/customize.bwctld BWCTL=0 ;; 3) # Run NDT customization script /usr/local/bin/create-ndt.sh /bin/rm /tmp/customize.ndt NDT=0 ;; 4) # run NPAD customize script /usr/local/bin/create-npad.sh /bin/rm /tmp/customize.npad NPAD=0 ;; 5) # run NTP customize script /usr/local/bin/create-ntpd.sh /bin/rm /tmp/customize.ntpd NTP=0 ;; 6) # run Owamp customize script /usr/local/bin/create-owampd.sh /bin/rm /tmp/customize.owampd OWAMP=0 ;; 7) # run staticIP customize script /usr/local/bin/create-staticIP.sh /bin/rm /tmp/customize.staticIP STATICIP=0 ;; esac done