Skip to content

Commit

Permalink
network.service: Use environment file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
donald committed May 16, 2019
1 parent 9e32b89 commit f86ef22
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions misc_systemd_units/network.service
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit f86ef22

Please sign in to comment.