home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / etc / init.d / networking < prev    next >
Encoding:
Text File  |  2009-03-05  |  2.4 KB  |  112 lines

  1. #!/bin/sh -e
  2. ### BEGIN INIT INFO
  3. # Provides:          networking
  4. # Required-Start:    mountkernfs ifupdown $local_fs
  5. # Required-Stop:     ifupdown $local_fs
  6. # Default-Start:     S
  7. # Default-Stop:      0 6
  8. # Short-Description: Raise network interfaces.
  9. ### END INIT INFO
  10.  
  11. PATH="/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
  18. usplash_timeout () {
  19.     TIMEOUT=$1
  20.     if [ -x /sbin/usplash_write ]; then
  21.         /sbin/usplash_write "TIMEOUT $TIMEOUT" || true
  22.     fi
  23. }
  24.  
  25. process_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.  
  30. check_network_file_systems() {
  31.     [ -e /proc/mounts ] || return 0
  32.  
  33.     exec 9<&0 < /proc/mounts
  34.     while read DEV MTPT FSTYPE REST; do
  35.     case $DEV in
  36.     /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
  37.         log_warning_msg "not deconfiguring network interfaces: network devices still mounted."
  38.         exit 0
  39.         ;;
  40.     esac
  41.     case $FSTYPE in
  42.     nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs)
  43.         log_warning_msg "not deconfiguring network interfaces: network file systems still mounted."
  44.         exit 0
  45.         ;;
  46.     esac
  47.     done
  48.     exec 0<&9 9<&-
  49. }
  50.  
  51. case "$1" in
  52. start)
  53.     process_options
  54.  
  55.     log_action_begin_msg "Configuring network interfaces"
  56.     usplash_timeout 120
  57.     if [ "$VERBOSE" != no ]; then
  58.         if ifup -a; then
  59.         log_action_end_msg $?
  60.         else
  61.         log_action_end_msg $?
  62.         fi
  63.     else
  64.         if ifup -a >/dev/null 2>&1; then
  65.         log_action_end_msg $?
  66.         else
  67.         log_action_end_msg $?
  68.         fi
  69.     fi
  70.     usplash_timeout 15
  71.     ;;
  72.  
  73. stop)
  74.     check_network_file_systems
  75.  
  76.     log_action_begin_msg "Deconfiguring network interfaces"
  77.     if [ "$VERBOSE" != no ]; then
  78.         if ifdown -a --exclude=lo; then
  79.         log_action_end_msg $?
  80.         else
  81.         log_action_end_msg $?
  82.         fi
  83.     else
  84.         if ifdown -a --exclude=lo >/dev/null 2>/dev/null; then
  85.         log_action_end_msg $?
  86.         else
  87.         log_action_end_msg $?
  88.         fi
  89.     fi
  90.     ;;
  91.  
  92. force-reload|restart)
  93.     process_options
  94.  
  95.     log_action_begin_msg "Reconfiguring network interfaces"
  96.     ifdown -a --exclude=lo || true
  97.     if ifup -a --exclude=lo; then
  98.         log_action_end_msg $?
  99.     else
  100.         log_action_end_msg $?
  101.     fi
  102.     ;;
  103.  
  104. *)
  105.     echo "Usage: /etc/init.d/networking {start|stop|restart|force-reload}"
  106.     exit 1
  107.     ;;
  108. esac
  109.  
  110. exit 0
  111.  
  112.