diff options
author | Michael K. Johnson <johnsonm@redhat.com> | 1997-09-16 18:27:40 +0000 |
---|---|---|
committer | Michael K. Johnson <johnsonm@redhat.com> | 1997-09-16 18:27:40 +0000 |
commit | 15bb4512255d2790567231b99c54a45a98644d71 (patch) | |
tree | 0fc378da6900ed36a9eee114fec532add4fa4e85 /sysconfig/network-scripts | |
parent | 9d4ab932f93b7193ea86f230aae060b5b68f0308 (diff) | |
download | initscripts-15bb4512255d2790567231b99c54a45a98644d71.tar initscripts-15bb4512255d2790567231b99c54a45a98644d71.tar.gz initscripts-15bb4512255d2790567231b99c54a45a98644d71.tar.bz2 initscripts-15bb4512255d2790567231b99c54a45a98644d71.tar.xz initscripts-15bb4512255d2790567231b99c54a45a98644d71.zip |
ifup and ifdown complain if $1 not specified.
The "ifcfg-" part of the device name is now optional for ifup and ifdown.
ifdown-ppp kills a pppd's chat session if it is active.
Generic part of ifup uses MACADDR variable if present.
ifup-ppp honors DEBUG variable, both for pppd (debug) and chat (-v).
Diffstat (limited to 'sysconfig/network-scripts')
-rwxr-xr-x | sysconfig/network-scripts/ifdown | 21 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifdown-ppp | 6 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup | 28 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-ppp | 5 |
4 files changed, 48 insertions, 12 deletions
diff --git a/sysconfig/network-scripts/ifdown b/sysconfig/network-scripts/ifdown index 079d1ff5..ef8fe1cf 100755 --- a/sysconfig/network-scripts/ifdown +++ b/sysconfig/network-scripts/ifdown @@ -3,21 +3,34 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin cd /etc/sysconfig/network-scripts +CONFIG=$1 + +[ -z "$CONFIG" ] && { + echo "usage: ifdown <device name>" >&2 + exit 1 +} + +[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG +[ -f "$CONFIG" ] || { + echo "usage: ifdown <device name>" >&2 + exit 1 +} + if [ $UID != 0 ]; then if [ -x /usr/sbin/usernetctl ]; then - exec /usr/sbin/usernetctl $1 down + exec /usr/sbin/usernetctl $CONFIG down fi echo "Users cannot control this device." >&2 exit 1 fi -. $1 +. $CONFIG DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"` OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${DEVICETYPE}" if [ -x $OTHERSCRIPT ]; then - $OTHERSCRIPT $1 $2 + $OTHERSCRIPT $CONFIG $2 exit $? fi @@ -38,5 +51,5 @@ fi ifconfig ${DEVICE} down -exec /etc/sysconfig/network-scripts/ifdown-post $1 +exec /etc/sysconfig/network-scripts/ifdown-post $CONFIG diff --git a/sysconfig/network-scripts/ifdown-ppp b/sysconfig/network-scripts/ifdown-ppp index 31845640..84325ca6 100755 --- a/sysconfig/network-scripts/ifdown-ppp +++ b/sysconfig/network-scripts/ifdown-ppp @@ -23,7 +23,13 @@ if [ -z "$PID" ]; then exit 1 fi +# pppd might have chat as a child; remember chat's pid to kill after pppd. +# (After, not before, so that pppd doesn't just restart it). + +CHATPID=`ps aul | awk '$4 ~ $PID {print $3}' 2>/dev/null` + kill $PID > /dev/null 2>&1 +[ -n "$CHATPID" ] && kill $CHATPID > /dev/null 2>&1 if [ ! -d /proc/$PID ]; then /etc/sysconfig/network-scripts/ifdown-post $1 exit 0 diff --git a/sysconfig/network-scripts/ifup b/sysconfig/network-scripts/ifup index 76cdf379..ab1e6f7f 100755 --- a/sysconfig/network-scripts/ifup +++ b/sysconfig/network-scripts/ifup @@ -1,17 +1,30 @@ -#!/bin/sh +#!/bin/bash PATH=/sbin:/usr/sbin:/bin:/usr/bin cd /etc/sysconfig/network-scripts +CONFIG=$1 + +[ -z "$CONFIG" ] && { + echo "usage: ifup <device name>" >&2 + exit 1 +} + +[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG +[ -f "$CONFIG" ] || { + echo "usage: ifup <device name>" >&2 + exit 1 +} + if [ $UID != 0 ]; then if [ -x /usr/sbin/usernetctl ]; then - exec /usr/sbin/usernetctl $1 up + exec /usr/sbin/usernetctl $CONFIG up fi echo "Users cannot control this device." >&2 exit 1 fi -. $1 +. $CONFIG if [ "foo$2" = "fooboot" -a "${ONBOOT}" = "no" ] then @@ -55,7 +68,7 @@ fi OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}" if [ -x $OTHERSCRIPT ]; then - exec $OTHERSCRIPT $1 $2 + exec $OTHERSCRIPT $CONFIG $2 fi # is this device available? (this catches PCMCIA devices for us) @@ -111,14 +124,15 @@ elif [ "$BOOTPROTO" = dhcp -a "$ISALIAS" = no ]; then fi if [ "$IPSETUP" != yes ]; then - ifconfig ${DEVICE} ${IPADDR} netmask ${NETMASK} broadcast ${BROADCAST} + ifconfig ${DEVICE} ${MACADDR:+hw ether $MACADDR} ${IPADDR} \ + netmask ${NETMASK} broadcast ${BROADCAST} if [ "$ISALIAS" = no ] ; then route add -net ${NETWORK} netmask ${NETMASK} ${DEVICE} else route add -host ${IPADDR} ${DEVICE} fi - # this is broken! it's only here for compatibility RH sytstems + # this is broken! it's only here for compatibility with old RH systems if [ "${GATEWAY}" != "" -a "${GATEWAY}" != "none" ]; then route add default gw ${GATEWAY} metric 1 ${DEVICE} fi @@ -155,4 +169,4 @@ if [ "$IPSETUP" != yes ]; then fi fi -exec /etc/sysconfig/network-scripts/ifup-post $1 +exec /etc/sysconfig/network-scripts/ifup-post $CONFIG diff --git a/sysconfig/network-scripts/ifup-ppp b/sysconfig/network-scripts/ifup-ppp index f1b5813f..7b5cb377 100755 --- a/sysconfig/network-scripts/ifup-ppp +++ b/sysconfig/network-scripts/ifup-ppp @@ -63,6 +63,9 @@ fi if [ -n "${PAPNAME}" ] ; then opts="$opts name ${PAPNAME}" fi +if [ -n "${DEBUG}" ] ; then + opts="$opts debug" +fi while : ; do (logger -p daemon.info -t ifup-ppp \ @@ -72,7 +75,7 @@ while : ; do /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \ remotename $DEVICE ipparam $DEVICE \ ${PPPOPTIONS} \ - connect "/usr/sbin/chat -f /etc/sysconfig/network-scripts/chat-$DEVICE" + connect "/usr/sbin/chat ${DEBUG:+-v} -f /etc/sysconfig/network-scripts/chat-$DEVICE" # exit if we're not supposed to persist or our lock file has disappeared if [ "$PERSIST" != "yes" -o ! -f /var/run/ppp-$DEVICE.dev ]; then |