home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / init.d / networking < prev    next >
Encoding:
Text File  |  2010-04-18  |  2.4 KB  |  110 lines

  1. #!/bin/sh -e
  2. ### BEGIN INIT INFO
  3. # Provides:          networking
  4. # Required-Start:    mountkernfs $local_fs
  5. # Required-Stop:     $local_fs
  6. # Should-Start:      ifupdown
  7. # Should-Stop:       ifupdown
  8. # Default-Start:     S
  9. # Default-Stop:      0 6
  10. # Short-Description: Raise network interfaces.
  11. ### END INIT INFO
  12.  
  13. PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
  14.  
  15. [ -x /sbin/ifup ] || exit 0
  16.  
  17. . /lib/lsb/init-functions
  18.  
  19. process_options() {
  20.     [ -e /etc/network/options ] || return 0
  21.     log_warning_msg "/etc/network/options still exists and it will be IGNORED! Read README.Debian of netbase."
  22. }
  23.  
  24. check_network_file_systems() {
  25.     [ -e /proc/mounts ] || return 0
  26.  
  27.     if [ -e /etc/iscsi/iscsi.initramfs ]; then
  28.     log_warning_msg "not deconfiguring network interfaces: iSCSI root is mounted."
  29.     exit 0
  30.     fi
  31.  
  32.     exec 9<&0 < /proc/mounts
  33.     while read DEV MTPT FSTYPE REST; do
  34.     case $DEV in
  35.     /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
  36.         log_warning_msg "not deconfiguring network interfaces: network devices still mounted."
  37.         exit 0
  38.         ;;
  39.     esac
  40.     case $FSTYPE in
  41.     nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs)
  42.         log_warning_msg "not deconfiguring network interfaces: network file systems still mounted."
  43.         exit 0
  44.         ;;
  45.     esac
  46.     done
  47.     exec 0<&9 9<&-
  48. }
  49.  
  50. check_network_swap() {
  51.     [ -e /proc/swaps ] || return 0
  52.  
  53.     exec 9<&0 < /proc/swaps
  54.     while read DEV MTPT FSTYPE REST; do
  55.     case $DEV in
  56.     /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
  57.         log_warning_msg "not deconfiguring network interfaces: network swap still mounted."
  58.         exit 0
  59.         ;;
  60.     esac
  61.     done
  62.     exec 0<&9 9<&-
  63. }
  64.  
  65. case "$1" in
  66. start)
  67.     process_options
  68.  
  69.     log_action_begin_msg "Configuring network interfaces"
  70.     if ifup -a; then
  71.         log_action_end_msg $?
  72.     else
  73.         log_action_end_msg $?
  74.     fi
  75.     ;;
  76.  
  77. stop)
  78.     check_network_file_systems
  79.     check_network_swap
  80.  
  81.     log_action_begin_msg "Deconfiguring network interfaces"
  82.     if ifdown -a --exclude=lo; then
  83.         log_action_end_msg $?
  84.     else
  85.         log_action_end_msg $?
  86.     fi
  87.     ;;
  88.  
  89. force-reload|restart)
  90.     process_options
  91.  
  92.     log_warning_msg "Running $0 $1 is deprecated because it may not enable again some interfaces"
  93.     log_action_begin_msg "Reconfiguring network interfaces"
  94.     ifdown -a --exclude=lo || true
  95.     if ifup -a --exclude=lo; then
  96.         log_action_end_msg $?
  97.     else
  98.         log_action_end_msg $?
  99.     fi
  100.     ;;
  101.  
  102. *)
  103.     echo "Usage: /etc/init.d/networking {start|stop}"
  104.     exit 1
  105.     ;;
  106. esac
  107.  
  108. exit 0
  109.  
  110.