Advertisement
Guest User

etc_init_d_networking

a guest
Apr 24th, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. #!/bin/sh -e
  2. ### BEGIN INIT INFO
  3. # Provides: networking
  4. # Required-Start:
  5. # Required-Stop: $local_fs
  6. # Should-Start: ifupdown
  7. # Should-Stop: ifupdown
  8. # Default-Start:
  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. # helper function to set the usplash timeout. https://launchpad.net/bugs/21617
  20. usplash_timeout () {
  21. TIMEOUT=$1
  22. if [ -x /sbin/usplash_write ]; then
  23. /sbin/usplash_write "TIMEOUT $TIMEOUT" || true
  24. fi
  25. }
  26.  
  27. process_options() {
  28. [ -e /etc/network/options ] || return 0
  29. log_warning_msg "/etc/network/options still exists and it will be IGNORED! Read README.Debian of netbase."
  30. }
  31.  
  32. check_network_file_systems() {
  33. [ -e /proc/mounts ] || return 0
  34.  
  35. if [ -e /etc/iscsi/iscsi.initramfs ]; then
  36. log_warning_msg "not deconfiguring network interfaces: iSCSI root is mounted."
  37. exit 0
  38. fi
  39.  
  40. exec 9<&0 < /proc/mounts
  41. while read DEV MTPT FSTYPE REST; do
  42. case $DEV in
  43. /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
  44. log_warning_msg "not deconfiguring network interfaces: network devices still mounted."
  45. exit 0
  46. ;;
  47. esac
  48. case $FSTYPE in
  49. nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs)
  50. log_warning_msg "not deconfiguring network interfaces: network file systems still mounted."
  51. exit 0
  52. ;;
  53. esac
  54. done
  55. exec 0<&9 9<&-
  56. }
  57.  
  58. check_network_swap() {
  59. [ -e /proc/swaps ] || return 0
  60.  
  61. exec 9<&0 < /proc/swaps
  62. while read DEV MTPT FSTYPE REST; do
  63. case $DEV in
  64. /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
  65. log_warning_msg "not deconfiguring network interfaces: network swap still mounted."
  66. exit 0
  67. ;;
  68. esac
  69. done
  70. exec 0<&9 9<&-
  71. }
  72.  
  73. case "$1" in
  74. start)
  75. /lib/init/upstart-job networking start
  76. ;;
  77.  
  78. stop)
  79. check_network_file_systems
  80. check_network_swap
  81.  
  82. # Anything that manages network interfaces *MUST* wait for this event
  83. initctl emit deconfiguring-networking
  84.  
  85. log_action_begin_msg "Deconfiguring network interfaces"
  86. if [ "$VERBOSE" != no ]; then
  87. if ifdown -a --exclude=lo; then
  88. log_action_end_msg $?
  89. else
  90. log_action_end_msg $?
  91. fi
  92. else
  93. if ifdown -a --exclude=lo >/dev/null 2>/dev/null; then
  94. log_action_end_msg $?
  95. else
  96. log_action_end_msg $?
  97. fi
  98. fi
  99. ;;
  100.  
  101. force-reload|restart)
  102. process_options
  103.  
  104. log_warning_msg "Running $0 $1 is deprecated because it may not enable again some interfaces"
  105. log_action_begin_msg "Reconfiguring network interfaces"
  106. ifdown -a --exclude=lo || true
  107. if ifup -a --exclude=lo; then
  108. log_action_end_msg $?
  109. else
  110. log_action_end_msg $?
  111. fi
  112. ;;
  113.  
  114. *)
  115. echo "Usage: /etc/init.d/networking {start|stop}"
  116. exit 1
  117. ;;
  118. esac
  119.  
  120. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement