From f86ef2203f5260815d1ba38106570d7952a030fc Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 16 May 2019 14:53:56 +0200 Subject: [PATCH] network.service: Use environment file All systems now have a file /etc/local/mxhost.conf with the host specific IP address and network interface. Use that data in the unit file. Note, that this is not shell syntax. The difference between $VAR and ${VAR} is how the whitespaces inside VAR are handled. ${VAR} would be "$VAR" in shell syntax. We don't need the brackets, because the values are single words only. However, unlike the shell, systemd would parse $MX_IPADDR/20 as an environment variable named "MX_IPADDR/20". So we need the curlies at that point to terminate the variable name. Use it everywhere for readability and to avoid future errors. --- misc_systemd_units/network.service | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/misc_systemd_units/network.service b/misc_systemd_units/network.service index 53895f0..0de3e5d 100644 --- a/misc_systemd_units/network.service +++ b/misc_systemd_units/network.service @@ -3,12 +3,13 @@ Description=Network Connectivity DefaultDependencies=no [Service] +EnvironmentFile=/etc/local/mxhost.conf Type=oneshot RemainAfterExit=yes ExecStart=/usr/sbin/mxnetctl start -ExecStart=/sbin/ip addr add 141.14.31.7/20 broadcast 141.14.31.255 dev net00 -ExecStart=/sbin/ip link set up dev net00 -ExecStop=/sbin/ip addr del 141.14.31.7/20 dev net00 +ExecStart=/sbin/ip addr add ${MX_IPADDR}/20 broadcast 141.14.31.255 dev ${MX_NETDEV} +ExecStart=/sbin/ip link set up dev ${MX_NETDEV} +ExecStop=/sbin/ip addr del ${MX_IPADDR}/20 dev ${MX_NETDEV} StandardOutput=syslog [Install]