90 lines
2.5 KiB
Bash
Executable File
90 lines
2.5 KiB
Bash
Executable File
#! /bin/sh
|
|
# network - Network interfaces start/stop script
|
|
|
|
# Based on ethnet script from LFS-3.1 and earlier.
|
|
# Rewritten by Gerard Beekmans <gerard@linuxfromscratch.org>
|
|
# Modified by Silvan Calarco <silvan.calarco@mambasoft.it>
|
|
#
|
|
# chkconfig: 2345 20 97
|
|
# description: Network interfaces start/stop script
|
|
|
|
. /etc/sysconfig/rc
|
|
. $rc_functions
|
|
. /etc/sysconfig/network
|
|
|
|
unset MAKEDEFAULT
|
|
|
|
case "$1" in
|
|
start)
|
|
if [ -x /usr/sbin/ifrename ] && [ -r /etc/iftab ]; then
|
|
echo -n "Renaming interfaces: "
|
|
ifrename -t
|
|
evaluate_retval
|
|
echo
|
|
fi
|
|
|
|
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/network_makefile_$$
|
|
trap "rm -f $tempfile" HUP INT QUIT ABRT KILL TERM
|
|
|
|
for file in `grep -il "ONBOOT=yes" $network_devices/ifconfig.* 2>/dev/null`; do
|
|
interface=$(basename $file | sed "s/ifconfig.//")
|
|
case "$interface" in
|
|
*~) ;;
|
|
*) parentinterface=$(echo $interface | sed s/:.*// )
|
|
targetinterface=$(echo $interface | sed s/:/-/ )
|
|
[ "$parentinterface" = "$targetinterface" ] && unset parentinterface
|
|
cat >> $tempfile << EOF
|
|
$targetinterface: $parentinterface
|
|
@$network_devices/ifup $interface
|
|
EOF
|
|
MAKEDEFAULT="$targetinterface $MAKEDEFAULT"
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [ "$MAKEDEFAULT" != "" ]; then
|
|
echo -n $"Bringing up interface(s): $MAKEDEFAULT"
|
|
echo "all: $MAKEDEFAULT" >> $tempfile
|
|
make -j -k -f $tempfile all 1>/dev/null
|
|
evaluate_retval
|
|
echo
|
|
fi
|
|
rm -f $tempfile
|
|
;;
|
|
stop)
|
|
if [ "$GATEWAY" != "" ]; then
|
|
echo -n "Removing default gateway: "
|
|
route del -net default
|
|
evaluate_retval
|
|
echo
|
|
fi
|
|
for file in `grep -il "ONBOOT=yes" $network_devices/ifconfig.* 2>/dev/null`; do
|
|
interface=$(basename $file | sed s/ifconfig.//)
|
|
case "$interface" in
|
|
*~) ;;
|
|
*) echo -n $"Bringing down the $interface interface: "
|
|
$network_devices/ifdown $interface
|
|
evaluate_retval
|
|
echo
|
|
;;
|
|
esac
|
|
done
|
|
;;
|
|
restart)
|
|
$0 stop
|
|
sleep 1
|
|
$0 start
|
|
;;
|
|
status)
|
|
[ -x /sbin/ifconfig ] && /sbin/ifconfig || :
|
|
for wint in $(find /sys/class/net/wlan[0-9]* \
|
|
-maxdepth 0 -type d -printf "%f " 2>/dev/null); do
|
|
/usr/sbin/iwconfig $wint
|
|
done
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart|status}"
|
|
exit 1
|
|
;;
|
|
esac
|