|
From: Serge L. <sma...@us...> - 2010-08-22 08:00:39
|
Update of /cvsroot/devil-linux/build/scripts/scripts In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv31552/scripts/scripts Modified Files: save-config Log Message: partially fixed bug #84: failing 'copy default configuration' upon clean installation For now only "save-config -s" is fixed. Index: save-config =================================================================== RCS file: /cvsroot/devil-linux/build/scripts/scripts/save-config,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- save-config 2 Jun 2010 07:05:30 -0000 1.42 +++ save-config 22 Aug 2010 08:00:31 -0000 1.43 @@ -86,7 +86,7 @@ if [ -z "$WRITE2STDOUT" ]; then - if [ -n $DL_CONFIG_SOURCE ]; then + if [ -n "$DL_CONFIG_SOURCE" ]; then if [ -b $DL_CONFIG_SOURCE ]; then if [ -z "$QUIET" ]; then $GREEN @@ -103,80 +103,79 @@ else # generate the device list we need to search for the configuration information - PARTITIONS_IDE=`find /dev/ide/ -name "part*" 2> /dev/null` - PARTITIONS_SCSI=`find /dev/scsi/ -name "part*" 2> /dev/null` + PARTITIONS=`for i in /dev/disk/by-path/*-part* ; do echo "/dev/"$(basename $(readlink $i)) ; done` FLOPPIES=`find /dev/floppy/ -name "?" 2> /dev/null` - CONFIG_SRC_LIST="$PARTITIONS_SCSI $PARTITIONS_IDE $FLOPPIES" + CONFIG_SRC_LIST="$PARTITIONS $FLOPPIES" $GREEN echo -e "searching for configuration media" $NORMAL - until [ -e "$CONFIG_MOUNT/$DL_CONFIG_FILE" ] ; + until [ -n "$DL_CONFIG_SOURCE" ] ; do - for CFG_SRC in $CONFIG_SRC_LIST - do - echo -e "Checking $CFG_SRC" - if mount -n -o ro,noatime -t auto $CFG_SRC $CONFIG_MOUNT > /dev/null 2>&1 ; then + for CFG_SRC in $CONFIG_SRC_LIST + do + echo -e "Checking $CFG_SRC" + if mount -n -o ro,noatime -t auto $CFG_SRC $CONFIG_MOUNT > /dev/null 2>&1 ; then - if [ -e "$CONFIG_MOUNT/$DL_CONFIG_FILE" ] ; then - umount $CONFIG_MOUNT - $SUCCESS - echo -e "Found configuration on $CFG_SRC" - $NORMAL - if [ -z "$QUIET" ]; then - echo -n "Do you want to use this device?" - if ask_yes_no ; then - DL_CONFIG_SOURCE=$CFG_SRC - continue 2 - fi - else - DL_CONFIG_SOURCE=$CFG_SRC - continue 2 - fi - else - beep; - umount $CONFIG_MOUNT - $SUCCESS - echo -e "\n*** Found empty media $CFG_SRC . ***\n" - $NORMAL - echo -n "Do you want to save your configuration to this device?" - if ask_yes_no ; then - DL_CONFIG_SOURCE=$CFG_SRC - continue 2 - fi - fi - elif mount -n -o ro,noatime -t $FS_TYPE $CFG_SRC $CONFIG_MOUNT > /dev/null 2>&1 ; then + if [ -e "$CONFIG_MOUNT/$DL_CONFIG_FILE" ] ; then + umount $CONFIG_MOUNT + $SUCCESS + echo -e "Found configuration on $CFG_SRC" + $NORMAL + if [ -z "$QUIET" ]; then + echo -n "Do you want to use this device?" + if ask_yes_no ; then + DL_CONFIG_SOURCE=$CFG_SRC + continue 2 + fi + else + DL_CONFIG_SOURCE=$CFG_SRC + continue 2 + fi + else + beep; + umount $CONFIG_MOUNT + $SUCCESS + echo -e "\n*** Found empty media $CFG_SRC . ***\n" + $NORMAL + echo -n "Do you want to save your configuration to this device?" + if ask_yes_no ; then + DL_CONFIG_SOURCE=$CFG_SRC + continue 2 + fi + fi + elif mount -n -o ro,noatime -t $FS_TYPE $CFG_SRC $CONFIG_MOUNT > /dev/null 2>&1 ; then - if [ -e "$CONFIG_MOUNT/$DL_CONFIG_FILE" ] ; then - umount $CONFIG_MOUNT - $SUCCESS - echo -e "Found configuration on $CFG_SRC" - $NORMAL - if [ -z "$QUIET" ]; then - echo -n "Do you want to use this device?" - if ask_yes_no ; then - DL_CONFIG_SOURCE=$CFG_SRC - continue 2 - fi - else - DL_CONFIG_SOURCE=$CFG_SRC - continue 2 - fi - else - beep; - umount $CONFIG_MOUNT - $SUCCESS - echo -e "\n*** Found empty media $CFG_SRC . ***\n" - $NORMAL - echo -n "Do you want to save your configuration to this device?" - if ask_yes_no ; then - DL_CONFIG_SOURCE=$CFG_SRC - continue 2 - fi - fi - fi - done + if [ -e "$CONFIG_MOUNT/$DL_CONFIG_FILE" ] ; then + umount $CONFIG_MOUNT + $SUCCESS + echo -e "Found configuration on $CFG_SRC" + $NORMAL + if [ -z "$QUIET" ]; then + echo -n "Do you want to use this device?" + if ask_yes_no ; then + DL_CONFIG_SOURCE=$CFG_SRC + continue 2 + fi + else + DL_CONFIG_SOURCE=$CFG_SRC + continue 2 + fi + else + beep; + umount $CONFIG_MOUNT + $SUCCESS + echo -e "\n*** Found empty media $CFG_SRC . ***\n" + $NORMAL + echo -n "Do you want to save your configuration to this device?" + if ask_yes_no ; then + DL_CONFIG_SOURCE=$CFG_SRC + continue 2 + fi + fi + fi + done beep; sleep 1; beep; sleep 1; beep; $ERROR echo -e "Please insert Configuration Media and press 'ENTER'" @@ -202,7 +201,7 @@ else # why should we require it exist? If the user # wants it elsewhere let them say so. - # maybe the wanted to make a copy of a tesy config + # maybe the wanted to make a copy of a test config # on a new diskette? $YELLOW echo "Creating new file on device..." @@ -330,20 +329,23 @@ $NORMAL else if [ $error -eq 0 ]; then - chmod 0600 $CONFIG_MOUNT/$DL_CONFIG_FILE - $SUCCESS - echo "Configuration saved" - $NORMAL + chmod 0600 $CONFIG_MOUNT/$DL_CONFIG_FILE + $SUCCESS + echo "Configuration saved" + $NORMAL - # run user specfic script after successful save - # useful for backing up the config elsewhere - # Pass device and file name just saved - [ -x /root/bin/post-save-config ] && /root/bin/post-save-config $DL_CONFIG_SOURCE $CONFIG_MOUNT $DL_CONFIG_FILE + # Update /shm/DL_CONFIG_SOURCE + echo "$DL_CONFIG_SOURCE" > /shm/DL_CONFIG_SOURCE + + # run user specfic script after successful save + # useful for backing up the config elsewhere + # Pass device and file name just saved + [ -x /root/bin/post-save-config ] && /root/bin/post-save-config $DL_CONFIG_SOURCE $CONFIG_MOUNT $DL_CONFIG_FILE else - $RED - beep - echo "failed to save configuration" - $NORMAL + $RED + beep + echo "failed to save configuration" + $NORMAL fi fi |