5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-09 16:20:26 +00:00

Merge pull request #607 from Arano-kai/feature/systemd_modular_unit

Systemd: move config generation to a separate unit
This commit is contained in:
Neil Alexander 2019-12-10 12:02:46 +00:00 committed by GitHub
commit 4b16c325a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -0,0 +1,13 @@
[Unit]
Description=yggdrasil default config generator
ConditionPathExists=|!/etc/yggdrasil.conf
ConditionFileNotEmpty=|!/etc/yggdrasil.conf
Wants=local-fs.target
After=local-fs.target
[Service]
Type=oneshot
Group=yggdrasil
StandardOutput=file:/etc/yggdrasil.conf
ExecStart=/usr/bin/yggdrasil -genconf
ExecStartPost=/usr/bin/chmod 0640 /etc/yggdrasil.conf

View File

@ -1,7 +1,9 @@
[Unit] [Unit]
Description=yggdrasil Description=yggdrasil
Wants=network.target Wants=network.target
Wants=yggdrasil-default-config.service
After=network.target After=network.target
After=yggdrasil-default-config.service
[Service] [Service]
Group=yggdrasil Group=yggdrasil
@ -10,11 +12,6 @@ ProtectSystem=true
SyslogIdentifier=yggdrasil SyslogIdentifier=yggdrasil
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW
ExecStartPre=+-/sbin/modprobe tun ExecStartPre=+-/sbin/modprobe tun
ExecStartPre=/bin/sh -ec "if ! test -s /etc/yggdrasil.conf; \
then umask 077; \
yggdrasil -genconf > /etc/yggdrasil.conf; \
echo 'WARNING: A new /etc/yggdrasil.conf file has been generated.'; \
fi"
ExecStart=/usr/bin/yggdrasil -useconffile /etc/yggdrasil.conf ExecStart=/usr/bin/yggdrasil -useconffile /etc/yggdrasil.conf
ExecReload=/bin/kill -HUP $MAINPID ExecReload=/bin/kill -HUP $MAINPID
Restart=always Restart=always