PageRenderTime 122ms CodeModel.GetById 117ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/init.d/networking

http://github.com/brinkman83/bashrc
Shell | 100 lines | 73 code | 16 blank | 11 comment | 13 complexity | db7e515f04f04f54708b5ea862585c31 MD5 | raw file
  1#!/bin/sh -e
  2### BEGIN INIT INFO
  3# Provides:          networking
  4# Required-Start:    
  5# Required-Stop:     $local_fs
  6# Default-Start:     
  7# Default-Stop:      0 6
  8# Short-Description: Raise network interfaces.
  9### END INIT INFO
 10
 11PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
 12
 13[ -x /sbin/ifup ] || exit 0
 14
 15. /lib/lsb/init-functions
 16
 17# helper function to set the usplash timeout. https://launchpad.net/bugs/21617
 18usplash_timeout () {
 19	TIMEOUT=$1
 20	if [ -x /sbin/usplash_write ]; then
 21	    /sbin/usplash_write "TIMEOUT $TIMEOUT" || true
 22	fi
 23}
 24
 25process_options() {
 26    [ -e /etc/network/options ] || return 0
 27    log_warning_msg "/etc/network/options still exists and it will be IGNORED! Read README.Debian of netbase."
 28}
 29
 30check_network_file_systems() {
 31    [ -e /proc/mounts ] || return 0
 32
 33    if [ -e /etc/iscsi/iscsi.initramfs ]; then
 34	# probably root on iSCSI
 35	log_warning_msg "not deconfiguring network interfaces: root filesystem appears to be on iSCSI."
 36	exit 0
 37    fi
 38
 39    exec 9<&0 < /proc/mounts
 40    while read DEV MTPT FSTYPE REST; do
 41	case $DEV in
 42	/dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
 43	    log_warning_msg "not deconfiguring network interfaces: network devices still mounted."
 44	    exit 0
 45	    ;;
 46	esac
 47	case $FSTYPE in
 48	nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs)
 49	    log_warning_msg "not deconfiguring network interfaces: network file systems still mounted."
 50	    exit 0
 51	    ;;
 52	esac
 53    done
 54    exec 0<&9 9<&-
 55}
 56
 57case "$1" in
 58start)
 59	/lib/init/upstart-job networking start
 60	;;
 61
 62stop)
 63	check_network_file_systems
 64
 65	log_action_begin_msg "Deconfiguring network interfaces"
 66	if [ "$VERBOSE" != no ]; then
 67	    if ifdown -a --exclude=lo; then
 68		log_action_end_msg $?
 69	    else
 70		log_action_end_msg $?
 71	    fi
 72	else
 73	    if ifdown -a --exclude=lo >/dev/null 2>/dev/null; then
 74		log_action_end_msg $?
 75	    else
 76		log_action_end_msg $?
 77	    fi
 78	fi
 79	;;
 80
 81force-reload|restart)
 82	process_options
 83
 84	log_action_begin_msg "Reconfiguring network interfaces"
 85	ifdown -a --exclude=lo || true
 86	if ifup -a --exclude=lo; then
 87	    log_action_end_msg $?
 88	else
 89	    log_action_end_msg $?
 90	fi
 91	;;
 92
 93*)
 94	echo "Usage: /etc/init.d/networking {start|stop|restart|force-reload}"
 95	exit 1
 96	;;
 97esac
 98
 99exit 0
100