3 # This replaces the old init.d script, and is run from the networking.service
4 # Only has start, stop, reload, because that's all systemd has.
5 # restart is implemented in systemd by stop then start.
8 IFSTATE_LOCKFILE
="${RUN_DIR}/ifstatelock"
10 STATE_DIR
="/var/tmp/network"
11 IFSTATE_FILE
="${STATE_DIR}/ifstatenew"
15 [ -x /sbin
/ifup
] ||
exit 0
16 [ -x /sbin
/ifdown
] ||
exit 0
18 CONFIGURE_INTERFACES
=yes
22 [ -f /etc
/default
/networking
] && .
/etc
/default
/networking
24 [ "$VERBOSE" = yes ] && EXTRA_ARGS
=-v
25 [ "$DEBUG" = yes ] && EXTRA_ARGS
="$EXTRA_ARGS -d"
26 [ "$SYSLOG" = yes ] && EXTRA_ARGS
="$EXTRA_ARGS --syslog"
29 # At bootup lets set perfmode
30 [ -f ${IFSTATE_LOCKFILE} ] && echo -n "" && return
35 process_exclusions
() {
36 set -- $EXCLUDE_INTERFACES
40 exclusions
="-X $d $exclusions"
45 check_network_file_systems
() {
46 [ -e /proc
/mounts
] ||
return 0
48 if [ -e /etc
/iscsi
/iscsi.initramfs
]; then
49 echo ${NAME}':' "not deconfiguring network interfaces: iSCSI root is mounted."
53 while read DEV MTPT FSTYPE REST
; do
55 /dev
/nbd
*|
/dev
/nd
[a-z
]*|
/dev
/etherd
/e
*)
56 echo ${NAME}':' "not deconfiguring network interfaces: network devices still mounted."
61 nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs
)
62 echo ${NAME}':' "not deconfiguring network interfaces: network file systems still mounted."
69 check_network_swap
() {
70 [ -e /proc
/swaps
] ||
return 0
72 while read DEV MTPT FSTYPE REST
; do
74 /dev
/nbd
*|
/dev
/nd
[a-z
]*|
/dev
/etherd
/e
*)
75 echo ${NAME}':' "not deconfiguring network interfaces: network swap still mounted."
83 if [ -d /sys
/class
/net
]
85 ifaces
=$
(for iface
in $
(ifquery
--list --allow=hotplug
2>/dev
/null
)
89 if [ -e "/sys/class/net/$link" ]
96 ifup
$ifaces "$@" || true
102 ifaces
=$
(ifquery
--list --allow=mgmt
2>/dev
/null
)
103 if [ -n "$ifaces" ]; then
104 echo "bringing up mgmt class interfaces"
110 # remove state file at boot
111 [ ! -e ${IFSTATE_LOCKFILE} ] && rm -f ${IFSTATE_FILE}
113 [ ! -e /run
/network
] && mkdir
-p /run
/network
&>/dev
/null
114 [ ! -e /etc
/network
/run
] && \
115 ln -sf /run
/network
/etc
/network
/run
&>/dev
/null
121 if [ "$CONFIGURE_INTERFACES" = no
]
123 echo ${NAME}':' "Not configuring network interfaces, see /etc/default/networking"
127 exclusions
=$
(process_exclusions
)
128 perfoptions
=$
(perf_options
)
129 echo ${NAME}':' "Configuring network interfaces"
131 ifup
-a $EXTRA_ARGS $exclusions $perfoptions
132 ifup_hotplug
$HOTPLUG_ARGS $EXTRA_ARGS $exclusions
135 if [ "$SKIP_DOWN_AT_SYSRESET" = "yes" ]; then
137 systemctl list-jobs |
egrep -q '(shutdown|reboot|halt|poweroff)\.target'
138 [ $?
-eq 0 ] && SYSRESET
=1
139 if [ $SYSRESET -eq 1 ]; then
140 echo ${NAME}':' "Skipping deconfiguring network interfaces"
145 check_network_file_systems
147 exclusions
=$
(process_exclusions
)
149 echo ${NAME}':' "Deconfiguring network interfaces"
150 ifdown
-a $EXTRA_ARGS $exclusions
156 exclusions
=$
(process_exclusions
)
158 echo ${NAME}':' "Reloading network interfaces configuration"
159 ifreload
-a $EXTRA_ARGS $exclusions
163 echo ${NAME}':' "Usage: $0 {start|stop|reload}"