diff options
author | Michael K. Johnson <johnsonm@redhat.com> | 1999-09-08 20:14:38 +0000 |
---|---|---|
committer | Michael K. Johnson <johnsonm@redhat.com> | 1999-09-08 20:14:38 +0000 |
commit | 40ecc9bedb8b80aea208404be2c9eb23fa52ff55 (patch) | |
tree | d171e3319033fae76fe800e9bd4f3a1a04392916 /sysconfig/network-scripts | |
parent | 8f705efdedc37e43620b8ec88f9b156f85a1f2d0 (diff) | |
download | initscripts-40ecc9bedb8b80aea208404be2c9eb23fa52ff55.tar initscripts-40ecc9bedb8b80aea208404be2c9eb23fa52ff55.tar.gz initscripts-40ecc9bedb8b80aea208404be2c9eb23fa52ff55.tar.bz2 initscripts-40ecc9bedb8b80aea208404be2c9eb23fa52ff55.tar.xz initscripts-40ecc9bedb8b80aea208404be2c9eb23fa52ff55.zip |
make ifdown synchronous modulo timeout
Diffstat (limited to 'sysconfig/network-scripts')
-rwxr-xr-x | sysconfig/network-scripts/ifdown | 28 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifdown-ppp | 1 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifdown-sl | 1 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup | 4 | ||||
-rw-r--r-- | sysconfig/network-scripts/network-functions | 11 |
5 files changed, 33 insertions, 12 deletions
diff --git a/sysconfig/network-scripts/ifdown b/sysconfig/network-scripts/ifdown index 6f02c394..5018e708 100755 --- a/sysconfig/network-scripts/ifdown +++ b/sysconfig/network-scripts/ifdown @@ -19,7 +19,9 @@ CONFIG=$1 if [ $UID != 0 ]; then if [ -x /usr/sbin/usernetctl ]; then - exec /usr/sbin/usernetctl $CONFIG down + if /usr/sbin/usernetctl $CONFIG report ; then + exec /usr/sbin/usernetctl $CONFIG down + fi fi echo "Users cannot control this device." >&2 exit 1 @@ -31,14 +33,7 @@ DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"` OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${DEVICETYPE}" if [ -x $OTHERSCRIPT ]; then - $OTHERSCRIPT $CONFIG $2 - exit $? -fi - -if echo $DEVICE | grep -q ':' ; then - ISALIAS=yes -else - ISALIAS=no + exec $OTHERSCRIPT $CONFIG $2 fi if [ "$BOOTPROTO" = bootp -o "$BOOTPROTO" = dhcp ]; then @@ -46,6 +41,17 @@ if [ "$BOOTPROTO" = bootp -o "$BOOTPROTO" = dhcp ]; then fi ifconfig ${DEVICE} down +# wait up to 5 seconds for device to actually come down... +waited=0 +while ! check_device_down && [ "$waited" -lt 50 ] ; do + usleep 100000 + waited=$(($waited+1)) +done + +if [ "$retcode" = 0 ] ; then + /etc/sysconfig/network-scripts/ifdown-post $CONFIG + # do NOT use $? because ifdown should return whether or not + # the interface went down. +fi -exec /etc/sysconfig/network-scripts/ifdown-post $CONFIG - +exit $retcode diff --git a/sysconfig/network-scripts/ifdown-ppp b/sysconfig/network-scripts/ifdown-ppp index 2e56b0c0..3265c72d 100755 --- a/sysconfig/network-scripts/ifdown-ppp +++ b/sysconfig/network-scripts/ifdown-ppp @@ -26,5 +26,6 @@ sleep 2 kill -TERM $PID > /dev/null 2>&1 # ip-down won't run in this case /etc/sysconfig/network-scripts/ifdown-post $1 +[ ! -d /proc/$PID ] && exit 0 exit 1 diff --git a/sysconfig/network-scripts/ifdown-sl b/sysconfig/network-scripts/ifdown-sl index 0bb9d425..813ee0af 100755 --- a/sysconfig/network-scripts/ifdown-sl +++ b/sysconfig/network-scripts/ifdown-sl @@ -40,6 +40,7 @@ if [ -d /proc/$PID ]; then else /etc/sysconfig/network-scripts/ifdown-post $1 fi +[ ! -d /proc/$PID ] && exit 0 exit 1 diff --git a/sysconfig/network-scripts/ifup b/sysconfig/network-scripts/ifup index 64309d5b..3a979c91 100755 --- a/sysconfig/network-scripts/ifup +++ b/sysconfig/network-scripts/ifup @@ -21,7 +21,9 @@ CONFIG=$1 if [ $UID != 0 ]; then if [ -x /usr/sbin/usernetctl ]; then - exec /usr/sbin/usernetctl $CONFIG up + if /usr/sbin/usernetctl $CONFIG report ; then + exec /usr/sbin/usernetctl $CONFIG up + fi fi echo "Users cannot control this device." >&2 exit 1 diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index f015525d..feea9922 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -48,3 +48,14 @@ set_hostname() echo "search $domain" >> /etc/resolv.conf fi } + +check_device_down () +{ + if ifconfig ${DEVICE} | grep UP >/dev/null 2>&1 ; then + retcode=1 + else + retcode=0 + fi + return $retcode +} + |