summaryrefslogtreecommitdiffstats
path: root/share/scripts/debconf
diff options
context:
space:
mode:
authorNik Lutz <nik@netstyle.ch>2017-06-17 03:46:03 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2017-06-24 14:03:53 +0000
commit5807d7e142cdb20dc78b87d2848274aa0d237c49 (patch)
tree7d66deb26f3b72da7d11e0d58a3c31b90e59b958 /share/scripts/debconf
parentCorrecting typo in systemd parts of the Makefile's uninstall target. (diff)
downloadcompute-tools-5807d7e142cdb20dc78b87d2848274aa0d237c49.tar.xz
compute-tools-5807d7e142cdb20dc78b87d2848274aa0d237c49.zip
Implementing postup/postdown for systemd-networkd by creating systemd units in /etc/systemd/system.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to 'share/scripts/debconf')
-rwxr-xr-xshare/scripts/debconf46
1 files changed, 42 insertions, 4 deletions
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
}