diff options
author | Dan Horák <dan@danny.cz> | 2010-03-31 15:28:18 +0200 |
---|---|---|
committer | Dan Horák <dan@danny.cz> | 2010-03-31 15:28:18 +0200 |
commit | f46dfd2339f7acbe35ce49da2cfe250a58731831 (patch) | |
tree | 4c9acfbb7df34afffb09ada5559ed24102d88118 | |
parent | 07492edecae0bde5f1a7dd84eda445f5f637682c (diff) | |
download | utils-f46dfd2339f7acbe35ce49da2cfe250a58731831.tar.gz utils-f46dfd2339f7acbe35ce49da2cfe250a58731831.tar.xz utils-f46dfd2339f7acbe35ce49da2cfe250a58731831.zip |
change mode handling in device_cio_free
The mode handling in device_cio_free is now changed so it will process
all kinds of devices in one run of the scripts. It lowers the maximum
waiting time from 3x 60 secs to 60 secs.
-rw-r--r-- | device_cio_free | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/device_cio_free b/device_cio_free index 238d5ab..e7ffbc7 100644 --- a/device_cio_free +++ b/device_cio_free @@ -79,25 +79,45 @@ wait_on_device() echo "Error: device $DEV still not ready" } +process_config_file() +{ + local CONFIG + + [ -z "$1" ] && return + + CONFIG="$1" + if [ -f "$CONFIG" ]; then + while read line; do + case $line in + \#*) ;; + *) + [ -z "$line" ] && continue + set $line + free_device $1 + ;; + esac + done < $CONFIG + fi +} + # check how we were called CMD=${0##*/} DIR=${0%/*} ARGS=$@ case $CMD in "dasd_cio_free") - CONFIG=$DASDCONFIG - MODE=dasd + MODE_DASD="yes" ;; "zfcp_cio_free") - CONFIG=$ZFCPCONFIG - MODE=zfcp + MODE_ZFCP="yes" ;; "znet_cio_free") - CONFIG=$ZNETCONFIG - MODE=znet + MODE_ZNET="yes" ;; "device_cio_free") - MODE=all + MODE_DASD="yes" + MODE_ZFCP="yes" + MODE_ZNET="yes" ;; *) echo "Error: unknown alias '$CMD'." @@ -128,33 +148,19 @@ if [ ! -f $BLACKLIST ]; then exit 2 fi -if [ $MODE = "all" ]; then - # shortcut for calling all 3 scripts - $DIR/dasd_cio_free $ARGS || exit $? - $DIR/zfcp_cio_free $ARGS || exit $? - $DIR/znet_cio_free $ARGS || exit $? - exit 0 -fi - -[ $VERBOSE ] && echo "Freeing $MODE devices" -if [ $MODE = "dasd" -o $MODE = "zfcp" ]; then - # process the config file - if [ -f "$CONFIG" ]; then - while read line; do - case $line in - \#*) ;; - *) - [ -z "$line" ] && continue - set $line - free_device $1 - ;; - esac - done < $CONFIG - fi +if [ $VERBOSE ]; then + echo -n "Freeing devices:" + [ $MODE_DASD ] && echo -n " dasd" + [ $MODE_ZFCP ] && echo -n " zfcp" + [ $MODE_ZNET ] && echo -n " znet" + echo fi -if [ $MODE = "dasd" ]; then +[ $MODE_DASD ] && process_config_file $DASDCONFIG +[ $MODE_ZFCP ] && process_config_file $ZFCPCONFIG + +if [ $MODE_DASD ]; then # process the device list defined as option for the dasd module DEVICES=$(modprobe --showconfig | grep "options[[:space:]]\+dasd_mod" | \ sed -e 's/.*[[:space:]]dasd=\([^[:space:]]*\).*/\1/' -e 's/([^)]*)//g' \ @@ -165,9 +171,9 @@ if [ $MODE = "dasd" ]; then done fi -if [ $MODE = "znet" ]; then +if [ $MODE_ZNET ]; then # process the config file - if [ -f "$CONFIG" ]; then + if [ -f "$ZNETCONFIG" ]; then while read line; do case $line in \#*) ;; @@ -178,7 +184,7 @@ if [ $MODE = "znet" ]; then free_device $DEVICES ;; esac - done < $CONFIG + done < $ZNETCONFIG fi # process channels from network interface configurations for line in $(grep -E -i -h "^[[:space:]]*SUBCHANNELS=['\"]?([0-9]\.[0-9]\.[a-f0-9]+,){1,2}([0-9]\.[0-9]\.[a-f0-9]+)['\"]?([[:space:]]+#|[[:space:]]*$)" /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null) |