Advertisement
Guest User

Untitled

a guest
May 13th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. # networking - configure virtual network devices
  2. #
  3. # This task causes virtual network devices that do not have an associated
  4. # kernel object to be started on boot.
  5.  
  6. description "configure virtual network devices"
  7.  
  8. emits static-network-up
  9. emits net-device-up
  10. emits deconfiguring-networking
  11.  
  12. start on (local-filesystems
  13. and (stopped udevtrigger or container)) or runlevel [2345] or stopped networking RESULT=failed PROCESS=post-stop EXIT_STATUS=100
  14. stop on unmounted-remote-filesystems
  15.  
  16. pre-start script
  17. if [ "$UPSTART_EVENTS" = "stopped" ] && [ "$UPSTART_JOB" = "networking" ] && [ "$EXIT_STATUS" = "100" ]; then
  18. exit 0
  19. fi
  20.  
  21. mkdir -p /run/network
  22. ifup -a
  23. end script
  24.  
  25. post-stop script
  26. if [ -z "$UPSTART_STOP_EVENTS" ]; then
  27. echo "Stopping or restarting the networking job is not supported."
  28. echo "Use ifdown & ifup to reconfigure desired interface."
  29. exit 100
  30. fi
  31.  
  32. log_warning_msg() {
  33. echo $*
  34. }
  35.  
  36. # These checks were taken from the Debian ifupdown.networking.init script
  37. check_network_file_systems() {
  38. [ -e /proc/mounts ] || return 0
  39.  
  40. if [ -e /etc/iscsi/iscsi.initramfs ]; then
  41. log_warning_msg "not deconfiguring network interfaces: iSCSI root is mounted."
  42. exit 0
  43. fi
  44.  
  45. while read DEV MTPT FSTYPE REST; do
  46. case $DEV in
  47. /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
  48. log_warning_msg "not deconfiguring network interfaces: network devices still mounted."
  49. exit 0
  50. ;;
  51. esac
  52. case $FSTYPE in
  53. nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs)
  54. log_warning_msg "not deconfiguring network interfaces: network file systems still mounted."
  55. exit 0
  56. ;;
  57. esac
  58. done < /proc/mounts
  59. }
  60.  
  61. check_network_swap() {
  62. [ -e /proc/swaps ] || return 0
  63.  
  64. while read DEV MTPT FSTYPE REST; do
  65. case $DEV in
  66. /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
  67. log_warning_msg "not deconfiguring network interfaces: network swap still mounted."
  68. exit 0
  69. ;;
  70. esac
  71. done < /proc/swaps
  72. }
  73.  
  74. check_network_file_systems
  75. check_network_swap
  76.  
  77. # Anything that manages network interfaces *MUST* wait for this event
  78. initctl emit deconfiguring-networking
  79. ifdown -a --exclude=lo
  80. end script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement