123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #!/bin/sh
- # Begin $RC_BASE/init.d/network
- ### BEGIN INIT INFO
- # Provides: $network
- # Required-Start: $local_fs swap localnet
- # Should-Start: $syslog
- # Required-Stop: $local_fs swap localnet
- # Should-Stop: $syslog
- # Default-Start: 3 4 5
- # Default-Stop: 0 1 2 6
- # Short-Description: Starts and configures network interfaces.
- # Description: Starts and configures network interfaces.
- # X-LFS-Provided-By: LFS
- ### END INIT INFO
- . /lib/lsb/init-functions
- case "${1}" in
- start)
- # Start all network interfaces
- for dir in ${NETWORK_DEVICES}/ifconfig.*
- do
- interface=${dir##*/ifconfig.}
- # skip if $dir is * (because nothing was found)
- if [ "${interface}" = "*" ]; then
- continue
- fi
- # Process individual configuration files
- for file in "${dir}"/* ; do
- ONBOOT=`grep "ONBOOT" "${file}" | sed 's@^ONBOOT=@@'`
- case "${ONBOOT}" in
- Y* | y* | 0)
- /sbin/ifup -c "${file}" "${interface}"
- ;;
- esac
- done
- done
- ;;
- stop)
- # Reverse list
- DIRS=""
- for dir in /run/network/ifconfig.*
- do
- DIRS="${dir} ${DIRS}"
- done
- # Stop all network interfaces
- for dir in ${DIRS}; do
- interface=${dir##*/ifconfig.}
- # skip if $dir is * (because nothing was found)
- if [ "${interface}" = "*" ]; then
- continue
- fi
- # Process individual configuration files
- for file in "${dir}"/* ; do
- # No checking necessary if it is in /run/network
- /sbin/ifdown -c "${file}" "${interface}"
- done
- link_status=`/sbin/ip link show "${interface}" | \
- grep -o "state DOWN"`
- if [ "${link_status}" != "state DOWN" ]; then
- message="Shutting down the ${interface} interface..."
- /sbin/ip addr flush "${interface}" &&
- /sbin/ip link set "${interface}" down
- evaluate_retval standard
- fi
- done
- ;;
- restart)
- ${0} stop
- sleep 1
- ${0} start
- ;;
- *)
- echo "Usage: ${0} {start|stop|restart}"
- exit 1
- ;;
- esac
- # End $RC_BASE/init.d/network
|