#!/bin/sh ######################################################################## # Begin network # # Description : Network Control Script # # Authors : Gerard Beekmans - gerard@linuxfromscratch.org # Nathan Coulson - nathan@linuxfromscratch.org # Kevin P. Fleming - kpfleming@linuxfromscratch.org # DJ Lucas - dj@linuxfromscratch.org # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org # # Changes for NuTyX : piernov - piernov@piernov.org # # Version : LFS 7.0 # ######################################################################## ### 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: 2 3 4 5 # Default-Stop: 0 1 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 # Network configuration . /etc/sysconfig/network NM_PIDFILE=/var/run/NetworkManager.pid WICD_PIDFILE= TIME=$NETWORKDELAY case "${1}" in start) if [ "$MANAGER" == "networkmanager" ] && [ -x /usr/sbin/NetworkManager ]; then log_info_msg "Starting NetworkManager daemon..." start_daemon /usr/sbin/NetworkManager --pid-file $NM_PIDFILE evaluate_retval if [ "${NETWORKWAIT}" == "yes" ]; then [ -z "${LINKDELAY}" ] && LINKDELAY=10 log_info_msg "Waiting for network..." nm-online -q --timeout=$LINKDELAY || nm-online -q -x --timeout=30 evaluate_retval [ -n "${NETWORKDELAY}" ] && /bin/sleep ${NETWORKDELAY} fi elif [ "$MANAGER" == "wicd" ] && [ -f /usr/share/wicd/daemon/wicd-daemon.py ]; then log_info_msg "Starting the wicd Daemon..." start_daemon /usr/share/wicd/daemon/wicd-daemon.py evaluate_retval if grep -v ^# /etc/fstab | grep _netdev > /dev/null; then while ! grep "nameserver" /etc/resolv.conf ; do if [ $TIME -gt 0 ]; then sleep 1 echo -n . let TIME=$TIME-1 if [ $TIME -lt 1 ]; then log_failure_msg "Time out" exit 1 fi fi done log_success_msg "Network successfully configured..." fi else # Start all network interfaces for file in /etc/sysconfig/ifconfig.* do interface=${file##*/ifconfig.} # Skip if $file is * (because nothing was found) if [ "${interface}" = "*" ] then continue fi /sbin/ifup ${interface} done fi ;; stop) if [ "$MANAGER" == "networkmanager" ] && [ -x /usr/sbin/NetworkManager ]; then log_info_msg "Stopping NetworkManager daemon..." killproc -p $NM_PIDFILE /usr/sbin/NetworkManager evaluate_retval elif [ "$MANAGER" == "wicd" ] && [ -f /usr/share/wicd/daemon/wicd-daemon.py ]; then log_info_msg "Stopping the wicd Daemon..." /usr/share/wicd/daemon/wicd-daemon.py --kill evaluate_retval else # Reverse list net_files="" for file in /etc/sysconfig/ifconfig.* do net_files="${file} ${net_files}" done # Stop all network interfaces for file in ${net_files} do interface=${file##*/ifconfig.} # Skip if $file is * (because nothing was found) if [ "${interface}" = "*" ] then continue fi /sbin/ifdown ${interface} done fi ;; status) if [ "$MANAGER" == "networkmanager" ] && [ -x /usr/sbin/NetworkManager ]; then statusproc -p $NM_PIDFILE NetworkManager elif [ "$MANAGER" == "wicd" ] && [ -f /usr/share/wicd/daemon/wicd-daemon.py ]; then statusproc -p /var/run/wicd/wicd.pid /usr/share/wicd/daemon/wicd-daemon.py fi ;; restart) ${0} stop sleep 3 ${0} start ;; *) echo "Usage: ${0} {start|stop|restart|status}" exit 1 ;; esac exit 0 # End network