Create a networking service script, so we can run it after switchd
Ticket: CM-8790
Reviewed By: wkok,roopa
Testing Done: built, installed, rebooted
jessie's networking starts as an init.d service. Trying to force ordering
between init.d and systemd services when there are dependencies doesn't work
well (especially since the init.d/networking service is forced very early
because of the remote filesystem requirement in jesie).
Converting networking to a script run as a systemd service allows us to start
networking after switchd. The new script is /sbin/start-networking. I chose
to keep it in /sbin, rather than put it in /usr/cumulus/bin, because it's core
functionaity.
I am not removing /etc/init.d/networking, it just gets ignored unless somebody
types it manually. If somebody does that, systemctl runs through the lsb
hooks. The two lost abilities below are just ignored if passed. I'm
also preventing creating the rc.d symlinks to the init.d/networking
script to reduce future confusion.
We lose some init.d "convenience" functionality because it's not available
through systemd. What we lose are:
reload-currently-up - can still be done with ifreload --currently-up
force-reload - can still be done with ifreload -f -a
We keep start, stop, reload, restart
2016-01-20 11:57:41 -08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-02-08 12:41:41 -08:00
|
|
|
# This replaces the old init.d script, and is run from the networking.service
|
Create a networking service script, so we can run it after switchd
Ticket: CM-8790
Reviewed By: wkok,roopa
Testing Done: built, installed, rebooted
jessie's networking starts as an init.d service. Trying to force ordering
between init.d and systemd services when there are dependencies doesn't work
well (especially since the init.d/networking service is forced very early
because of the remote filesystem requirement in jesie).
Converting networking to a script run as a systemd service allows us to start
networking after switchd. The new script is /sbin/start-networking. I chose
to keep it in /sbin, rather than put it in /usr/cumulus/bin, because it's core
functionaity.
I am not removing /etc/init.d/networking, it just gets ignored unless somebody
types it manually. If somebody does that, systemctl runs through the lsb
hooks. The two lost abilities below are just ignored if passed. I'm
also preventing creating the rc.d symlinks to the init.d/networking
script to reduce future confusion.
We lose some init.d "convenience" functionality because it's not available
through systemd. What we lose are:
reload-currently-up - can still be done with ifreload --currently-up
force-reload - can still be done with ifreload -f -a
We keep start, stop, reload, restart
2016-01-20 11:57:41 -08:00
|
|
|
# Only has start, stop, reload, because that's all systemd has.
|
|
|
|
# restart is implemented in systemd by stop then start.
|
|
|
|
|
|
|
|
RUN_DIR="/run/network"
|
2016-02-29 15:31:52 -08:00
|
|
|
IFSTATE_LOCKFILE="${RUN_DIR}/ifstatelock"
|
|
|
|
|
|
|
|
STATE_DIR="/var/tmp/network"
|
|
|
|
IFSTATE_FILE="${STATE_DIR}/ifstatenew"
|
Create a networking service script, so we can run it after switchd
Ticket: CM-8790
Reviewed By: wkok,roopa
Testing Done: built, installed, rebooted
jessie's networking starts as an init.d service. Trying to force ordering
between init.d and systemd services when there are dependencies doesn't work
well (especially since the init.d/networking service is forced very early
because of the remote filesystem requirement in jesie).
Converting networking to a script run as a systemd service allows us to start
networking after switchd. The new script is /sbin/start-networking. I chose
to keep it in /sbin, rather than put it in /usr/cumulus/bin, because it's core
functionaity.
I am not removing /etc/init.d/networking, it just gets ignored unless somebody
types it manually. If somebody does that, systemctl runs through the lsb
hooks. The two lost abilities below are just ignored if passed. I'm
also preventing creating the rc.d symlinks to the init.d/networking
script to reduce future confusion.
We lose some init.d "convenience" functionality because it's not available
through systemd. What we lose are:
reload-currently-up - can still be done with ifreload --currently-up
force-reload - can still be done with ifreload -f -a
We keep start, stop, reload, restart
2016-01-20 11:57:41 -08:00
|
|
|
|
|
|
|
NAME=networking
|
|
|
|
|
|
|
|
[ -x /sbin/ifup ] || exit 0
|
|
|
|
[ -x /sbin/ifdown ] || exit 0
|
|
|
|
|
|
|
|
CONFIGURE_INTERFACES=yes
|
|
|
|
|
|
|
|
EXTRA_ARGS=
|
|
|
|
|
|
|
|
[ -f /etc/default/networking ] && . /etc/default/networking
|
|
|
|
|
|
|
|
[ "$VERBOSE" = yes ] && EXTRA_ARGS=-v
|
|
|
|
[ "$DEBUG" = yes ] && EXTRA_ARGS="$EXTRA_ARGS -d"
|
|
|
|
[ "$SYSLOG" = yes ] && EXTRA_ARGS="$EXTRA_ARGS --syslog"
|
|
|
|
|
|
|
|
perf_options() {
|
|
|
|
# At bootup lets set perfmode
|
2016-02-29 15:31:52 -08:00
|
|
|
[ -f ${IFSTATE_LOCKFILE} ] && echo -n "" && return
|
Create a networking service script, so we can run it after switchd
Ticket: CM-8790
Reviewed By: wkok,roopa
Testing Done: built, installed, rebooted
jessie's networking starts as an init.d service. Trying to force ordering
between init.d and systemd services when there are dependencies doesn't work
well (especially since the init.d/networking service is forced very early
because of the remote filesystem requirement in jesie).
Converting networking to a script run as a systemd service allows us to start
networking after switchd. The new script is /sbin/start-networking. I chose
to keep it in /sbin, rather than put it in /usr/cumulus/bin, because it's core
functionaity.
I am not removing /etc/init.d/networking, it just gets ignored unless somebody
types it manually. If somebody does that, systemctl runs through the lsb
hooks. The two lost abilities below are just ignored if passed. I'm
also preventing creating the rc.d symlinks to the init.d/networking
script to reduce future confusion.
We lose some init.d "convenience" functionality because it's not available
through systemd. What we lose are:
reload-currently-up - can still be done with ifreload --currently-up
force-reload - can still be done with ifreload -f -a
We keep start, stop, reload, restart
2016-01-20 11:57:41 -08:00
|
|
|
|
|
|
|
echo -n "--perfmode"
|
|
|
|
}
|
|
|
|
|
|
|
|
process_exclusions() {
|
|
|
|
set -- $EXCLUDE_INTERFACES
|
|
|
|
exclusions=""
|
|
|
|
for d
|
|
|
|
do
|
|
|
|
exclusions="-X $d $exclusions"
|
|
|
|
done
|
|
|
|
echo $exclusions
|
|
|
|
}
|
|
|
|
|
|
|
|
check_network_file_systems() {
|
|
|
|
[ -e /proc/mounts ] || return 0
|
|
|
|
|
|
|
|
if [ -e /etc/iscsi/iscsi.initramfs ]; then
|
|
|
|
echo ${NAME}':' "not deconfiguring network interfaces: iSCSI root is mounted."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
while read DEV MTPT FSTYPE REST; do
|
|
|
|
case $DEV in
|
|
|
|
/dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
|
|
|
|
echo ${NAME}':' "not deconfiguring network interfaces: network devices still mounted."
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
case $FSTYPE in
|
|
|
|
nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs)
|
|
|
|
echo ${NAME}':' "not deconfiguring network interfaces: network file systems still mounted."
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done < /proc/mounts
|
|
|
|
}
|
|
|
|
|
|
|
|
check_network_swap() {
|
|
|
|
[ -e /proc/swaps ] || return 0
|
|
|
|
|
|
|
|
while read DEV MTPT FSTYPE REST; do
|
|
|
|
case $DEV in
|
|
|
|
/dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
|
|
|
|
echo ${NAME}':' "not deconfiguring network interfaces: network swap still mounted."
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done < /proc/swaps
|
|
|
|
}
|
|
|
|
|
|
|
|
ifup_hotplug () {
|
|
|
|
if [ -d /sys/class/net ]
|
|
|
|
then
|
|
|
|
ifaces=$(for iface in $(ifquery --list --allow=hotplug 2>/dev/null)
|
|
|
|
do
|
|
|
|
link=${iface##:*}
|
|
|
|
link=${link##.*}
|
2018-12-13 11:43:32 -08:00
|
|
|
if [ -e "/sys/class/net/$link" ]
|
Create a networking service script, so we can run it after switchd
Ticket: CM-8790
Reviewed By: wkok,roopa
Testing Done: built, installed, rebooted
jessie's networking starts as an init.d service. Trying to force ordering
between init.d and systemd services when there are dependencies doesn't work
well (especially since the init.d/networking service is forced very early
because of the remote filesystem requirement in jesie).
Converting networking to a script run as a systemd service allows us to start
networking after switchd. The new script is /sbin/start-networking. I chose
to keep it in /sbin, rather than put it in /usr/cumulus/bin, because it's core
functionaity.
I am not removing /etc/init.d/networking, it just gets ignored unless somebody
types it manually. If somebody does that, systemctl runs through the lsb
hooks. The two lost abilities below are just ignored if passed. I'm
also preventing creating the rc.d symlinks to the init.d/networking
script to reduce future confusion.
We lose some init.d "convenience" functionality because it's not available
through systemd. What we lose are:
reload-currently-up - can still be done with ifreload --currently-up
force-reload - can still be done with ifreload -f -a
We keep start, stop, reload, restart
2016-01-20 11:57:41 -08:00
|
|
|
then
|
2017-07-26 23:45:52 +00:00
|
|
|
echo "$iface"
|
Create a networking service script, so we can run it after switchd
Ticket: CM-8790
Reviewed By: wkok,roopa
Testing Done: built, installed, rebooted
jessie's networking starts as an init.d service. Trying to force ordering
between init.d and systemd services when there are dependencies doesn't work
well (especially since the init.d/networking service is forced very early
because of the remote filesystem requirement in jesie).
Converting networking to a script run as a systemd service allows us to start
networking after switchd. The new script is /sbin/start-networking. I chose
to keep it in /sbin, rather than put it in /usr/cumulus/bin, because it's core
functionaity.
I am not removing /etc/init.d/networking, it just gets ignored unless somebody
types it manually. If somebody does that, systemctl runs through the lsb
hooks. The two lost abilities below are just ignored if passed. I'm
also preventing creating the rc.d symlinks to the init.d/networking
script to reduce future confusion.
We lose some init.d "convenience" functionality because it's not available
through systemd. What we lose are:
reload-currently-up - can still be done with ifreload --currently-up
force-reload - can still be done with ifreload -f -a
We keep start, stop, reload, restart
2016-01-20 11:57:41 -08:00
|
|
|
fi
|
|
|
|
done)
|
|
|
|
if [ -n "$ifaces" ]
|
|
|
|
then
|
|
|
|
ifup $ifaces "$@" || true
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-04-21 12:58:53 -07:00
|
|
|
ifup_mgmt () {
|
|
|
|
ifaces=$(ifquery --list --allow=mgmt 2>/dev/null)
|
|
|
|
if [ -n "$ifaces" ]; then
|
|
|
|
echo "bringing up mgmt class interfaces"
|
|
|
|
ifup --allow=mgmt
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
Create a networking service script, so we can run it after switchd
Ticket: CM-8790
Reviewed By: wkok,roopa
Testing Done: built, installed, rebooted
jessie's networking starts as an init.d service. Trying to force ordering
between init.d and systemd services when there are dependencies doesn't work
well (especially since the init.d/networking service is forced very early
because of the remote filesystem requirement in jesie).
Converting networking to a script run as a systemd service allows us to start
networking after switchd. The new script is /sbin/start-networking. I chose
to keep it in /sbin, rather than put it in /usr/cumulus/bin, because it's core
functionaity.
I am not removing /etc/init.d/networking, it just gets ignored unless somebody
types it manually. If somebody does that, systemctl runs through the lsb
hooks. The two lost abilities below are just ignored if passed. I'm
also preventing creating the rc.d symlinks to the init.d/networking
script to reduce future confusion.
We lose some init.d "convenience" functionality because it's not available
through systemd. What we lose are:
reload-currently-up - can still be done with ifreload --currently-up
force-reload - can still be done with ifreload -f -a
We keep start, stop, reload, restart
2016-01-20 11:57:41 -08:00
|
|
|
ifupdown_init() {
|
2016-02-29 15:31:52 -08:00
|
|
|
# remove state file at boot
|
|
|
|
[ ! -e ${IFSTATE_LOCKFILE} ] && rm -f ${IFSTATE_FILE}
|
|
|
|
|
Create a networking service script, so we can run it after switchd
Ticket: CM-8790
Reviewed By: wkok,roopa
Testing Done: built, installed, rebooted
jessie's networking starts as an init.d service. Trying to force ordering
between init.d and systemd services when there are dependencies doesn't work
well (especially since the init.d/networking service is forced very early
because of the remote filesystem requirement in jesie).
Converting networking to a script run as a systemd service allows us to start
networking after switchd. The new script is /sbin/start-networking. I chose
to keep it in /sbin, rather than put it in /usr/cumulus/bin, because it's core
functionaity.
I am not removing /etc/init.d/networking, it just gets ignored unless somebody
types it manually. If somebody does that, systemctl runs through the lsb
hooks. The two lost abilities below are just ignored if passed. I'm
also preventing creating the rc.d symlinks to the init.d/networking
script to reduce future confusion.
We lose some init.d "convenience" functionality because it's not available
through systemd. What we lose are:
reload-currently-up - can still be done with ifreload --currently-up
force-reload - can still be done with ifreload -f -a
We keep start, stop, reload, restart
2016-01-20 11:57:41 -08:00
|
|
|
[ ! -e /run/network ] && mkdir -p /run/network &>/dev/null
|
|
|
|
[ ! -e /etc/network/run ] && \
|
|
|
|
ln -sf /run/network /etc/network/run &>/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
ifupdown_init
|
|
|
|
if [ "$CONFIGURE_INTERFACES" = no ]
|
|
|
|
then
|
|
|
|
echo ${NAME}':' "Not configuring network interfaces, see /etc/default/networking"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
set -f
|
|
|
|
exclusions=$(process_exclusions)
|
|
|
|
perfoptions=$(perf_options)
|
|
|
|
echo ${NAME}':' "Configuring network interfaces"
|
2016-04-21 12:58:53 -07:00
|
|
|
ifup_mgmt
|
Create a networking service script, so we can run it after switchd
Ticket: CM-8790
Reviewed By: wkok,roopa
Testing Done: built, installed, rebooted
jessie's networking starts as an init.d service. Trying to force ordering
between init.d and systemd services when there are dependencies doesn't work
well (especially since the init.d/networking service is forced very early
because of the remote filesystem requirement in jesie).
Converting networking to a script run as a systemd service allows us to start
networking after switchd. The new script is /sbin/start-networking. I chose
to keep it in /sbin, rather than put it in /usr/cumulus/bin, because it's core
functionaity.
I am not removing /etc/init.d/networking, it just gets ignored unless somebody
types it manually. If somebody does that, systemctl runs through the lsb
hooks. The two lost abilities below are just ignored if passed. I'm
also preventing creating the rc.d symlinks to the init.d/networking
script to reduce future confusion.
We lose some init.d "convenience" functionality because it's not available
through systemd. What we lose are:
reload-currently-up - can still be done with ifreload --currently-up
force-reload - can still be done with ifreload -f -a
We keep start, stop, reload, restart
2016-01-20 11:57:41 -08:00
|
|
|
ifup -a $EXTRA_ARGS $exclusions $perfoptions
|
2016-05-24 10:48:27 +02:00
|
|
|
ifup_hotplug $HOTPLUG_ARGS $EXTRA_ARGS $exclusions
|
Create a networking service script, so we can run it after switchd
Ticket: CM-8790
Reviewed By: wkok,roopa
Testing Done: built, installed, rebooted
jessie's networking starts as an init.d service. Trying to force ordering
between init.d and systemd services when there are dependencies doesn't work
well (especially since the init.d/networking service is forced very early
because of the remote filesystem requirement in jesie).
Converting networking to a script run as a systemd service allows us to start
networking after switchd. The new script is /sbin/start-networking. I chose
to keep it in /sbin, rather than put it in /usr/cumulus/bin, because it's core
functionaity.
I am not removing /etc/init.d/networking, it just gets ignored unless somebody
types it manually. If somebody does that, systemctl runs through the lsb
hooks. The two lost abilities below are just ignored if passed. I'm
also preventing creating the rc.d symlinks to the init.d/networking
script to reduce future confusion.
We lose some init.d "convenience" functionality because it's not available
through systemd. What we lose are:
reload-currently-up - can still be done with ifreload --currently-up
force-reload - can still be done with ifreload -f -a
We keep start, stop, reload, restart
2016-01-20 11:57:41 -08:00
|
|
|
;;
|
|
|
|
stop)
|
2016-03-03 21:29:53 -08:00
|
|
|
if [ "$SKIP_DOWN_AT_SYSRESET" = "yes" ]; then
|
|
|
|
SYSRESET=0
|
|
|
|
systemctl list-jobs | egrep -q '(shutdown|reboot|halt|poweroff)\.target'
|
|
|
|
[ $? -eq 0 ] && SYSRESET=1
|
|
|
|
if [ $SYSRESET -eq 1 ]; then
|
|
|
|
echo ${NAME}':' "Skipping deconfiguring network interfaces"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
Create a networking service script, so we can run it after switchd
Ticket: CM-8790
Reviewed By: wkok,roopa
Testing Done: built, installed, rebooted
jessie's networking starts as an init.d service. Trying to force ordering
between init.d and systemd services when there are dependencies doesn't work
well (especially since the init.d/networking service is forced very early
because of the remote filesystem requirement in jesie).
Converting networking to a script run as a systemd service allows us to start
networking after switchd. The new script is /sbin/start-networking. I chose
to keep it in /sbin, rather than put it in /usr/cumulus/bin, because it's core
functionaity.
I am not removing /etc/init.d/networking, it just gets ignored unless somebody
types it manually. If somebody does that, systemctl runs through the lsb
hooks. The two lost abilities below are just ignored if passed. I'm
also preventing creating the rc.d symlinks to the init.d/networking
script to reduce future confusion.
We lose some init.d "convenience" functionality because it's not available
through systemd. What we lose are:
reload-currently-up - can still be done with ifreload --currently-up
force-reload - can still be done with ifreload -f -a
We keep start, stop, reload, restart
2016-01-20 11:57:41 -08:00
|
|
|
ifupdown_init
|
|
|
|
check_network_file_systems
|
|
|
|
check_network_swap
|
|
|
|
exclusions=$(process_exclusions)
|
|
|
|
|
|
|
|
echo ${NAME}':' "Deconfiguring network interfaces"
|
2016-11-14 12:48:41 -08:00
|
|
|
ifdown -a $EXTRA_ARGS $exclusions
|
Create a networking service script, so we can run it after switchd
Ticket: CM-8790
Reviewed By: wkok,roopa
Testing Done: built, installed, rebooted
jessie's networking starts as an init.d service. Trying to force ordering
between init.d and systemd services when there are dependencies doesn't work
well (especially since the init.d/networking service is forced very early
because of the remote filesystem requirement in jesie).
Converting networking to a script run as a systemd service allows us to start
networking after switchd. The new script is /sbin/start-networking. I chose
to keep it in /sbin, rather than put it in /usr/cumulus/bin, because it's core
functionaity.
I am not removing /etc/init.d/networking, it just gets ignored unless somebody
types it manually. If somebody does that, systemctl runs through the lsb
hooks. The two lost abilities below are just ignored if passed. I'm
also preventing creating the rc.d symlinks to the init.d/networking
script to reduce future confusion.
We lose some init.d "convenience" functionality because it's not available
through systemd. What we lose are:
reload-currently-up - can still be done with ifreload --currently-up
force-reload - can still be done with ifreload -f -a
We keep start, stop, reload, restart
2016-01-20 11:57:41 -08:00
|
|
|
;;
|
|
|
|
|
|
|
|
reload)
|
|
|
|
|
|
|
|
ifupdown_init
|
2016-11-14 12:48:41 -08:00
|
|
|
exclusions=$(process_exclusions)
|
Create a networking service script, so we can run it after switchd
Ticket: CM-8790
Reviewed By: wkok,roopa
Testing Done: built, installed, rebooted
jessie's networking starts as an init.d service. Trying to force ordering
between init.d and systemd services when there are dependencies doesn't work
well (especially since the init.d/networking service is forced very early
because of the remote filesystem requirement in jesie).
Converting networking to a script run as a systemd service allows us to start
networking after switchd. The new script is /sbin/start-networking. I chose
to keep it in /sbin, rather than put it in /usr/cumulus/bin, because it's core
functionaity.
I am not removing /etc/init.d/networking, it just gets ignored unless somebody
types it manually. If somebody does that, systemctl runs through the lsb
hooks. The two lost abilities below are just ignored if passed. I'm
also preventing creating the rc.d symlinks to the init.d/networking
script to reduce future confusion.
We lose some init.d "convenience" functionality because it's not available
through systemd. What we lose are:
reload-currently-up - can still be done with ifreload --currently-up
force-reload - can still be done with ifreload -f -a
We keep start, stop, reload, restart
2016-01-20 11:57:41 -08:00
|
|
|
|
2016-11-14 12:48:41 -08:00
|
|
|
echo ${NAME}':' "Reloading network interfaces configuration"
|
|
|
|
ifreload -a $EXTRA_ARGS $exclusions
|
Create a networking service script, so we can run it after switchd
Ticket: CM-8790
Reviewed By: wkok,roopa
Testing Done: built, installed, rebooted
jessie's networking starts as an init.d service. Trying to force ordering
between init.d and systemd services when there are dependencies doesn't work
well (especially since the init.d/networking service is forced very early
because of the remote filesystem requirement in jesie).
Converting networking to a script run as a systemd service allows us to start
networking after switchd. The new script is /sbin/start-networking. I chose
to keep it in /sbin, rather than put it in /usr/cumulus/bin, because it's core
functionaity.
I am not removing /etc/init.d/networking, it just gets ignored unless somebody
types it manually. If somebody does that, systemctl runs through the lsb
hooks. The two lost abilities below are just ignored if passed. I'm
also preventing creating the rc.d symlinks to the init.d/networking
script to reduce future confusion.
We lose some init.d "convenience" functionality because it's not available
through systemd. What we lose are:
reload-currently-up - can still be done with ifreload --currently-up
force-reload - can still be done with ifreload -f -a
We keep start, stop, reload, restart
2016-01-20 11:57:41 -08:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo ${NAME}':' "Usage: $0 {start|stop|reload}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|