diff options
Diffstat (limited to 'meta/recipes-core/init-ifupdown/init-ifupdown-1.0/init')
-rw-r--r-- | meta/recipes-core/init-ifupdown/init-ifupdown-1.0/init | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/meta/recipes-core/init-ifupdown/init-ifupdown-1.0/init b/meta/recipes-core/init-ifupdown/init-ifupdown-1.0/init new file mode 100644 index 0000000000..bace9df991 --- /dev/null +++ b/meta/recipes-core/init-ifupdown/init-ifupdown-1.0/init | |||
@@ -0,0 +1,89 @@ | |||
1 | #!/bin/sh -e | ||
2 | ### BEGIN INIT INFO | ||
3 | # Provides: networking | ||
4 | # Required-Start: mountvirtfs $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 | check_network_file_systems() { | ||
18 | [ -e /proc/mounts ] || return 0 | ||
19 | |||
20 | if [ -e /etc/iscsi/iscsi.initramfs ]; then | ||
21 | echo "not deconfiguring network interfaces: iSCSI root is mounted." | ||
22 | exit 0 | ||
23 | fi | ||
24 | |||
25 | exec 9<&0 < /proc/mounts | ||
26 | while read DEV MTPT FSTYPE REST; do | ||
27 | case $DEV in | ||
28 | /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*) | ||
29 | echo "not deconfiguring network interfaces: network devices still mounted." | ||
30 | exit 0 | ||
31 | ;; | ||
32 | esac | ||
33 | case $FSTYPE in | ||
34 | nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs) | ||
35 | echo "not deconfiguring network interfaces: network file systems still mounted." | ||
36 | exit 0 | ||
37 | ;; | ||
38 | esac | ||
39 | done | ||
40 | exec 0<&9 9<&- | ||
41 | } | ||
42 | |||
43 | check_network_swap() { | ||
44 | [ -e /proc/swaps ] || return 0 | ||
45 | |||
46 | exec 9<&0 < /proc/swaps | ||
47 | while read DEV MTPT FSTYPE REST; do | ||
48 | case $DEV in | ||
49 | /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*) | ||
50 | echo "not deconfiguring network interfaces: network swap still mounted." | ||
51 | exit 0 | ||
52 | ;; | ||
53 | esac | ||
54 | done | ||
55 | exec 0<&9 9<&- | ||
56 | } | ||
57 | |||
58 | case "$1" in | ||
59 | start) | ||
60 | echo -n "Configuring network interfaces... " | ||
61 | ifup -a | ||
62 | echo "done." | ||
63 | ;; | ||
64 | |||
65 | stop) | ||
66 | check_network_file_systems | ||
67 | check_network_swap | ||
68 | |||
69 | echo -n "Deconfiguring network interfaces... " | ||
70 | ifdown -a | ||
71 | echo "done." | ||
72 | ;; | ||
73 | |||
74 | force-reload|restart) | ||
75 | echo "Running $0 $1 is deprecated because it may not enable again some interfaces" | ||
76 | echo "Reconfiguring network interfaces... " | ||
77 | ifdown -a || true | ||
78 | ifup -a | ||
79 | echo "done." | ||
80 | ;; | ||
81 | |||
82 | *) | ||
83 | echo "Usage: /etc/init.d/networking {start|stop}" | ||
84 | exit 1 | ||
85 | ;; | ||
86 | esac | ||
87 | |||
88 | exit 0 | ||
89 | |||