diff options
author | Erik Troan <ewt@redhat.com> | 1997-09-16 14:12:05 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 1997-09-16 14:12:05 +0000 |
commit | ced9dffda28f1ec2b060f3e419cf3c6b964b03a1 (patch) | |
tree | da3f56c24861ddc77e2910291c71adc12dca136b /sysconfig | |
download | initscripts-ced9dffda28f1ec2b060f3e419cf3c6b964b03a1.tar initscripts-ced9dffda28f1ec2b060f3e419cf3c6b964b03a1.tar.gz initscripts-ced9dffda28f1ec2b060f3e419cf3c6b964b03a1.tar.bz2 initscripts-ced9dffda28f1ec2b060f3e419cf3c6b964b03a1.tar.xz initscripts-ced9dffda28f1ec2b060f3e419cf3c6b964b03a1.zip |
Initial revision
Diffstat (limited to 'sysconfig')
-rw-r--r-- | sysconfig/network-scripts/ifcfg-lo | 6 | ||||
-rw-r--r-- | sysconfig/network-scripts/ifdhcpc-done | 20 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifdown | 42 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifdown-post | 18 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifdown-ppp | 44 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifdown-sl | 35 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup | 158 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-plip | 29 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-post | 43 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-ppp | 103 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-routes | 17 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-sl | 56 |
12 files changed, 571 insertions, 0 deletions
diff --git a/sysconfig/network-scripts/ifcfg-lo b/sysconfig/network-scripts/ifcfg-lo new file mode 100644 index 00000000..e21fb29f --- /dev/null +++ b/sysconfig/network-scripts/ifcfg-lo @@ -0,0 +1,6 @@ +DEVICE=lo +IPADDR=127.0.0.1 +NETMASK=255.0.0.0 +NETWORK=127.0.0.0 +BROADCAST=127.255.255.255 +ONBOOT=yes diff --git a/sysconfig/network-scripts/ifdhcpc-done b/sysconfig/network-scripts/ifdhcpc-done new file mode 100644 index 00000000..239725de --- /dev/null +++ b/sysconfig/network-scripts/ifdhcpc-done @@ -0,0 +1,20 @@ +#!/bin/sh -x + +SLEEPPIDFILE=/var/run/dhcp-wait-${IFNAME}.pid + +if [ ! -f $SLEEPPIDFILE ]; then + # the parent must have timed out already -- we can't do much about + # it now + echo "DHCP configured but ifup timed out" + #exit 0 +fi + +# get the pid of the process which is waiting for this to complete +SLEEPPID=`cat $SLEEPPIDFILE` +rm -f $SLEEPPIDFILE +kill $SLEEPPID + +if [ -f /etc/dhcpc/resolv.conf ]; then + echo "setting up resolv.conf" >> /tmp/dhcplog + cp /etc/dhcpc/resolv.conf /etc +fi diff --git a/sysconfig/network-scripts/ifdown b/sysconfig/network-scripts/ifdown new file mode 100755 index 00000000..079d1ff5 --- /dev/null +++ b/sysconfig/network-scripts/ifdown @@ -0,0 +1,42 @@ +#!/bin/sh +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +cd /etc/sysconfig/network-scripts + +if [ $UID != 0 ]; then + if [ -x /usr/sbin/usernetctl ]; then + exec /usr/sbin/usernetctl $1 down + fi + echo "Users cannot control this device." >&2 + exit 1 +fi + +. $1 + +DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"` +OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${DEVICETYPE}" + +if [ -x $OTHERSCRIPT ]; then + $OTHERSCRIPT $1 $2 + exit $? +fi + +if echo $DEVICE | grep -q ':' ; then + ISALIAS=yes +else + ISALIAS=no +fi + +if [ "$BOOTPROTO" = dhcp -a "$ISALIAS" = no ]; then + if [ -f /var/run/dhcpcd-${DEVICE}.pid ]; then + kill `cat /var/run/dhcpcd-${DEVICE}.pid` + rm -f /var/run/dhcpcd-${DEVICE}.pid + exit 0 + fi + exit 1 +fi + +ifconfig ${DEVICE} down + +exec /etc/sysconfig/network-scripts/ifdown-post $1 + diff --git a/sysconfig/network-scripts/ifdown-post b/sysconfig/network-scripts/ifdown-post new file mode 100755 index 00000000..cb7ce8c1 --- /dev/null +++ b/sysconfig/network-scripts/ifdown-post @@ -0,0 +1,18 @@ +#!/bin/sh +# This should be called whenever an interface goes down, not just when +# it is brought down explicitly. + +cd /etc/sysconfig/network-scripts + +. $1 + +# Notify programs that have requested notification +( cd /var/run/netreport || exit + for i in * ; do + [ -f $i ] && \ + kill -SIGIO $i >/dev/null 2>&1 || \ + rm -f $i >/dev/null 2>&1 + done +) + +exit 0 diff --git a/sysconfig/network-scripts/ifdown-ppp b/sysconfig/network-scripts/ifdown-ppp new file mode 100755 index 00000000..31845640 --- /dev/null +++ b/sysconfig/network-scripts/ifdown-ppp @@ -0,0 +1,44 @@ +#!/bin/bash +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +cd /etc/sysconfig/network-scripts + +. $1 + +if [ ! -f /var/run/ppp-$DEVICE.dev ]; then + # ppp isn't running, or we didn't start it + exit 0 +fi + +file=/var/run/`cat /var/run/ppp-$DEVICE.dev`.pid +if [ ! -f $file ]; then + exit 0 +fi + +# signals ifup-ppp not to persist +rm -f /var/run/ppp-$DEVICE.dev + +PID=`cat $file` +if [ -z "$PID" ]; then + exit 1 +fi + +kill $PID > /dev/null 2>&1 +if [ ! -d /proc/$PID ]; then + /etc/sysconfig/network-scripts/ifdown-post $1 + exit 0 +fi +sleep 2 +if [ ! -d /proc/$PID ]; then + /etc/sysconfig/network-scripts/ifdown-post $1 + exit 0 +fi + +kill -KILL $PID > /dev/null 2>&1 +if [ -d /proc/$PID ]; then + logger -p daemon.info -t ifdown-ppp "ifdown-ppp unable to kill pppd-$DEVICE" & +else + /etc/sysconfig/network-scripts/ifdown-post $1 +fi + +exit 1 diff --git a/sysconfig/network-scripts/ifdown-sl b/sysconfig/network-scripts/ifdown-sl new file mode 100755 index 00000000..cb3a8f12 --- /dev/null +++ b/sysconfig/network-scripts/ifdown-sl @@ -0,0 +1,35 @@ +#!/bin/bash +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +cd /etc/sysconfig/network-scripts + +. $1 + +# signals ifup-sl not to persist +rm -f /var/run/sl-$DEVICE.dev + +PID=`pidof dip-$DEVICE` +if [ -z "$PID" ]; then + exit 1 +fi + +kill $PID > /dev/null 2>&1 +if [ ! -d /proc/$PID ]; then + /etc/sysconfig/network-scripts/ifdown-post $1 + exit 0 +fi +sleep 2 +if [ ! -d /proc/$PID ]; then + /etc/sysconfig/network-scripts/ifdown-post $1 + exit 0 +fi + +kill -KILL $PID > /dev/null 2>&1 +if [ -d /proc/$PID ]; then + logger -p daemon.info -t ifdown-ppp "ifdown-ppp unable to kill pppd-$DEVICE" & +else + /etc/sysconfig/network-scripts/ifdown-post $1 +fi + +exit 1 + diff --git a/sysconfig/network-scripts/ifup b/sysconfig/network-scripts/ifup new file mode 100755 index 00000000..76cdf379 --- /dev/null +++ b/sysconfig/network-scripts/ifup @@ -0,0 +1,158 @@ +#!/bin/sh +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +cd /etc/sysconfig/network-scripts + +if [ $UID != 0 ]; then + if [ -x /usr/sbin/usernetctl ]; then + exec /usr/sbin/usernetctl $1 up + fi + echo "Users cannot control this device." >&2 + exit 1 +fi + +. $1 + +if [ "foo$2" = "fooboot" -a "${ONBOOT}" = "no" ] +then + exit +fi + +IPSETUP=no + +DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"` +REALDEVICE=`echo $DEVICE | sed 's/:.*//g'` +if echo $DEVICE | grep -q ':' ; then + ISALIAS=yes +else + ISALIAS=no +fi + +# Old BOOTP variable +if [ "$BOOTP" = "yes" ]; then + BOOTPROTO=bootp +fi + +if [ -e /etc/sysconfig/pcmcia ]; then + . /etc/sysconfig/pcmcia +else + PCMCIA=no +fi + +if [ $DEVICETYPE = "eth" -a "foo${ISPCMCIA}" = "foo" ]; then + # this is a horrible hack to work around prior brokenness + if [ "$PCMCIA" = "yes" -a "foo$2" = "fooboot" ]; then + # cardmgr will start us up properly + exit 0; + fi +elif [ "${ISPCMCIA}" = "yes" -a "$2" = "boot" ]; then + # cardmgr will start us up properly + exit 0; +fi + +### end of horrible hack + +OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}" + +if [ -x $OTHERSCRIPT ]; then + exec $OTHERSCRIPT $1 $2 +fi + +# is this device available? (this catches PCMCIA devices for us) +/sbin/ifconfig ${REALDEVICE} 2>&1 | grep -s "unknown interface" > /dev/null +if [ "$?" = "0" ]; then + echo "Delaying ${DEVICE} initialization." + exit 0 +fi + +if [ "$SLAVE" = yes -a "$ISALIAS" = no -a "$MASTER" != "" -a \ + -x /sbin/ifenslave ]; then + RFLAG="" ; [ "$RECIEVE-ONLY" = yes ] && RFLAG="-r" + + ifconfig ${DEVICE} down + echo "Enslaving $DEVICE to $MASTER" + ifenslave $RFLAG "$DEVICE" "$MASTER" + + exit 0 +fi + +if [ "$BOOTPROTO" = bootp -a "$ISALIAS" = no ]; then + ifconfig ${DEVICE} down + ifconfig ${DEVICE} 0.0.0.0 broadcast 255.255.255.255 netmask 0.0.0.0 + route add default ${DEVICE} + echo "Sending bootp request" + bootpc --returniffail --timeoutwait 6 --dev ${DEVICE} 2>/dev/null > /tmp/bootpc-response-${DEVICE} + if [ "$?" = "0" ]; then + . /tmp/bootpc-response-${DEVICE} + BOOTPHOSTNAME="$HOSTNAME" + echo "bootp response received -- using IP ${IPADDR}" + elif [ -z "$IPADDR" ]; then + echo "No bootp response recieved -- not configuring device ${DEVICE}." + rm -f /tmp/bootpc-response-${DEVICE} + exit 1 + else + echo "No bootp response recieved -- using default configuration for device ${DEVICE}." + fi + + rm -f /tmp/bootpc-response-${DEVICE} +elif [ "$BOOTPROTO" = dhcp -a "$ISALIAS" = no ]; then + echo -n "Using DHCP for ${DEVICE}... " + /sbin/dhcpcd -c /etc/sysconfig/network-scripts/ifdhcpc-done ${DEVICE} + echo "echo \$$ > /var/run/dhcp-wait-${DEVICE}.pid; exec sleep 30" | sh + + if [ -f /var/run/dhcp-wait-${DEVICE}.pid ]; then + echo "failed." + exit 1 + else + rm -f /var/run/dhcp-wait-${DEVICE}.pid + echo "done." + IPSETUP=yes + fi +fi + +if [ "$IPSETUP" != yes ]; then + ifconfig ${DEVICE} ${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 + if [ "${GATEWAY}" != "" -a "${GATEWAY}" != "none" ]; then + route add default gw ${GATEWAY} metric 1 ${DEVICE} + fi + + . /etc/sysconfig/network + + if [ "${GATEWAY}" != "" ]; then + if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then + # set up default gateway + route add default gw ${GATEWAY} ${DEVICE} + DEFGW=${GATEWAY} + fi + fi + + if [ "$BOOTPROTO" = bootp -a "$ISALIAS" = no ]; then + if [ -n "$GATEWAYS" ]; then + for gw in $GATEWAYS; do + if [ $gw != "${DEFGW}" ]; then + route add default gw $gw ${DEVICE} + fi + done + fi + + if [ -n "$DNSSRVS" -a -n "$SEARCH" ]; then + echo "search $SEARCH" > /etc/resolv.conf + for dns in $DNSSRVS; do + echo "nameserver $dns" >> /etc/resolv.conf + done + fi + + if [ -n "$BOOTPHOSTNAME" -a -z "`hostname`" ]; then + hostname $BOOTPHOSTNAME + fi + fi +fi + +exec /etc/sysconfig/network-scripts/ifup-post $1 diff --git a/sysconfig/network-scripts/ifup-plip b/sysconfig/network-scripts/ifup-plip new file mode 100755 index 00000000..ea423944 --- /dev/null +++ b/sysconfig/network-scripts/ifup-plip @@ -0,0 +1,29 @@ +#!/bin/sh +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +. $1 + +if [ "foo$2" = "fooboot" -a ${ONBOOT} = "no" ] +then + exit +fi + +ifconfig ${DEVICE} ${IPADDR} pointopoint ${REMIP} +route add -net ${NETWORK} netmask ${NETMASK} ${DEVICE} + +# this is broken! it's only here to keep compatibility with old RH sytstems +if [ "${GATEWAY}" != "" -a "${GATEWAY}" != "none" ] +then + route add default gw ${GATEWAY} metric 1 ${DEVICE} +fi + +. /etc/sysconfig/network + +if [ "${GATEWAY}" != "" ]; then + if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then + # set up default gateway + route add default gw ${GATEWAY} + fi +fi + +/etc/sysconfig/network-scripts/ifup-post $1 diff --git a/sysconfig/network-scripts/ifup-post b/sysconfig/network-scripts/ifup-post new file mode 100755 index 00000000..f8c07822 --- /dev/null +++ b/sysconfig/network-scripts/ifup-post @@ -0,0 +1,43 @@ +#!/bin/sh + +cd /etc/sysconfig/network-scripts + +. $1 + +DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"` +REALDEVICE=`echo $DEVICE | sed 's/:.*//g'` +if echo $DEVICE | grep -q ':' ; then + ISALIAS=yes +else + ISALIAS=no +fi + +/etc/sysconfig/network-scripts/ifup-routes ${DEVICE} + +if [ "$ISALIAS" = no ] ; then + allow_null_glob_expansion=foo + for alias in /etc/sysconfig/network-scripts/ifcfg-${DEVICE}:* ; do + /etc/sysconfig/network-scripts/ifup $alias + done + unset allow_null_glob_expansion +fi + +if [ `hostname` = '(none)' -o `hostname` = localhost -a ${DEVICE} != lo ]; then + IPADDR=`ifconfig ${DEVICE} | grep 'inet addr' | awk -F: '{ print $2 } ' | awk '{ print $1 }'` + host=`host ${IPADDR} | grep Name: | awk '{ print $2 }'` + if [ -n "$host" ]; then + echo "$host" > /etc/HOSTNAME + hostname $host + fi +fi + +# Notify programs that have requested notification +( cd /var/run/netreport || exit + for i in * ; do + [ -f $i ] && \ + kill -SIGIO $i >/dev/null 2>&1 || \ + rm -f $i >/dev/null 2>&1 + done +) + +exit 0 diff --git a/sysconfig/network-scripts/ifup-ppp b/sysconfig/network-scripts/ifup-ppp new file mode 100755 index 00000000..f1b5813f --- /dev/null +++ b/sysconfig/network-scripts/ifup-ppp @@ -0,0 +1,103 @@ +#!/bin/sh +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +# ifup-post for PPP is handled through /etc/ppp/ip-up + +if [ "$1" != daemon ] ; then + $0 daemon $*& + exit 0 +fi + +shift + +. $1 + +if [ -z "$DISCONNECTTIMEOUT" ]; then + DISCONNECTTIMEOUT=2 +fi + +if [ -z "$RETRYTIMEOUT" ]; then + RETRYTIMEOUT=30 +fi + +if [ "$2" = "boot" -a ${ONBOOT} = "no" ]; then + exit +fi + +[ -x /usr/sbin/pppd ] || { + echo "/usr/sbin/pppd does not exist or is not executable" + echo "ifup-ppp for $DEVICE exiting" + logger -p daemon.info -t ifup-ppp \ + "/usr/sbin/pppd does not exist or is not executable for $DEVICE" + exit 1 +} + +[ -f /etc/sysconfig/network-scripts/chat-$DEVICE ] || { + echo "/etc/sysconfig/network-scripts/chat-$DEVICE does not exist" + echo "ifup-ppp for $DEVICE exiting" + logger -p daemon.info -t ifup-ppp \ + "/etc/sysconfig/network-scripts/chat-$DEVICE does not exist for $DEVICE" + exit 1 +} + +opts="lock" +if [ "${HARDFLOWCTL}" = yes ] ; then + opts="$opts modem crtscts" +fi +if [ "${ESCAPECHARS}" = yes ] ; then + opts="$opts asyncmap 00000000" +fi +if [ "${DEFROUTE}" = yes ] ; then + opts="$opts defaultroute" +fi +if [ -n "${MRU}" ] ; then + opts="$opts mru ${MRU}" +fi +if [ -n "${MTU}" ] ; then + opts="$opts mtu ${MTU}" +fi +if [ -n "${IPADDR}${REMIP}" ] ; then + # if either IP address is set, the following will work. + opts="$opts ${IPADDR}:${REMIP}" +fi +if [ -n "${PAPNAME}" ] ; then + opts="$opts name ${PAPNAME}" +fi + +while : ; do + (logger -p daemon.info -t ifup-ppp \ + "pppd started for $DEVICE on $MODEMPORT at $LINESPEED" &)& + + > /var/run/ppp-$DEVICE.dev + /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \ + remotename $DEVICE ipparam $DEVICE \ + ${PPPOPTIONS} \ + connect "/usr/sbin/chat -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 + rm -f /var/run/ppp-$DEVICE.dev + exit 0 + fi + + size=`wc -c < /var/run/ppp-$DEVICE.dev` + + rm -f /var/run/ppp-$DEVICE.dev + + if [ $size = 0 ]; then + # pppd never connected + timeout=$RETRYTIMEOUT + else + # pppd connected and then disconnected + timeout=$DISCONNECTTIMEOUT + fi + + [ -z "$timeout" ] && { + timeout=30 + } + + sleep $timeout || { + # sleep was killed + exit 0 + } +done diff --git a/sysconfig/network-scripts/ifup-routes b/sysconfig/network-scripts/ifup-routes new file mode 100755 index 00000000..0733eea5 --- /dev/null +++ b/sysconfig/network-scripts/ifup-routes @@ -0,0 +1,17 @@ +#!/bin/sh + +# adds static routes which go through device $1 + +if [ "$1" = "" ]; then + echo "usage: $0 <net-device>" + exit 1 +fi + +if [ ! -f /etc/sysconfig/static-routes ]; then + exit 0 +fi + +#note the trailing space in the grep gets rid of aliases +grep "^$1 " /etc/sysconfig/static-routes | while read device args; do + route add -$args $device +done diff --git a/sysconfig/network-scripts/ifup-sl b/sysconfig/network-scripts/ifup-sl new file mode 100755 index 00000000..aad0b051 --- /dev/null +++ b/sysconfig/network-scripts/ifup-sl @@ -0,0 +1,56 @@ +#!/bin/sh +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +# ifup-post can't be done for slip :-( Solution: use PPP + +if [ "$1" != daemon ] ; then + $0 daemon $*& + exit 0 +fi + +shift + +. $1 + +if [ "foo$2" = "fooboot" -a ${ONBOOT} = "no" ] +then + exit +fi + +if [ -z "$RETRYTIMEOUT" ]; then + RETRYTIMEOUT=30 +fi + +[ -x /usr/sbin/dip ] || { + echo "/usr/sbin/dip does not exist or is not executable" + echo "ifup-sl for $DEVICE exiting" + logger -p daemon.info -t ifup-sl \ + "/usr/sbin/dip does not exist or is not executable for $DEVICE" + exit 1 +} + +[ -f /etc/sysconfig/network-scripts/dip-$DEVICE ] || { + echo "/etc/sysconfig/network-scripts/dip-$DEVICE does not exist" + echo "ifup-sl for $DEVICE exiting" + logger -p daemon.info -t ifup-sl \ + "/etc/sysconfig/network-scripts/dip-$DEVICE does not exist for $DEVICE" + exit 1 +} + +while : ; do + echo > /var/run/sl-$DEVICE.dev + (logger -p daemon.info -t ifup-sl \ + "dip started for $DEVICE on $MODEMPORT at $LINESPEED" &)& + doexec /usr/sbin/dip dip-$DEVICE /etc/sysconfig/network-scripts/dip-$DEVICE + if [ "$PERSIST" != "yes" -o ! -f /var/run/sl-$DEVICE.dev ] ; then + exit 0 + fi + rm -f /var/run/sl-$DEVICE.dev + + + sleep $RETRYTIMEOUT || { + # sleep was killed + exit 0 + } +done + |