From 5807d7e142cdb20dc78b87d2848274aa0d237c49 Mon Sep 17 00:00:00 2001 From: Nik Lutz Date: Sat, 17 Jun 2017 05:46:03 +0200 Subject: Implementing postup/postdown for systemd-networkd by creating systemd units in /etc/systemd/system. Signed-off-by: Daniel Baumann --- share/scripts/debconf | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'share/scripts') diff --git a/share/scripts/debconf b/share/scripts/debconf index 8fc7223..8ad2e51 100755 --- a/share/scripts/debconf +++ b/share/scripts/debconf @@ -810,8 +810,6 @@ EOF Configure_systemd_networkd () { - # FIXME: postup/postdown: multi-interface route - DIRECTORY="${1}" # Enable systemd-networkd @@ -829,8 +827,8 @@ Configure_systemd_networkd () eval IPV4_ADDRESS="$`echo NETWORK${NUMBER}_IPV4_ADDRESS`" eval IPV4_GATEWAY="$`echo NETWORK${NUMBER}_IPV4_GATEWAY`" eval IPV4_NETMASK="$`echo NETWORK${NUMBER}_IPV4_NETMASK`" -# eval IPV4_POST_UP="$`echo NETWORK${NUMBER}_IPV4_POST_UP`" -# eval IPV4_POST_DOWN="$`echo NETWORK${NUMBER}_IPV4_POST_DOWN`" + eval IPV4_POST_UP="$`echo NETWORK${NUMBER}_IPV4_POST_UP`" + eval IPV4_POST_DOWN="$`echo NETWORK${NUMBER}_IPV4_POST_DOWN`" if [ -z "${IPV4_METHOD}" ] then @@ -878,6 +876,46 @@ EOF fi esac + if [ -n "${IPV4_POST_UP}" ] + then + +cat > "${DIRECTORY}/etc/systemd/system/cnt-ipv4-post-up-eth${NUMBER}.service" << EOF +[Unit] +Description=container-tools IPV4_POST_UP +After=network-online.target +Wants=network-online.target + +[Service] +Type=oneshot +ExecStart=/bin/sh -c "${IPV4_POST_UP}" + +[Install] +WantedBy=multi-user.target +EOF + + chroot "${DIRECTORY}" systemctl enable cnt-ipv4-post-up-eth${NUMBER}.service + fi + + if [ -n "${IPV4_POST_DOWN}" ] + then + +cat > "${DIRECTORY}/etc/systemd/system/cnt-ipv4-post-down-eth${NUMBER}.service" << EOF +[Unit] +Description=container-tools IPV4_POST_DOWN +After=network.target +Wants=network.target + +[Service] +Type=oneshot +ExecStart=/bin/sh -c "${IPV4_POST_DOWN}" + +[Install] +WantedBy=multi-user.target +EOF + + chroot "${DIRECTORY}" systemctl enable cnt-ipv4-post-down-eth${NUMBER}.service + fi + NUMBER="$((${NUMBER} + 1))" done } -- cgit v1.2.3