3
Fork 0

Added systemd generators for tellus

This commit is contained in:
PD0ZRY Rudy 2017-03-11 22:33:00 +01:00
parent fea8c89343
commit 2cb0dd36d3
4 changed files with 57 additions and 3 deletions

View file

@ -44,10 +44,12 @@ install:
install -o root -g root tellusagent $(PREFIX)
install -o root -g root tellusagent.sh $(PREFIX)
install -o root -g root tellusagent.conf $(PREFIX)
install -D -d $(DESTDIR)/lib/systemd/system/
ifeq ($(OS), Linux)
# install -o root -g root tellusagent-init $(PREFIX)
# install -m 644 -o root -g root tellusagent-monit $(PREFIX)
# install -m 644 -o root -g root tellusagent.service $(PREFIX)
install -o root -g root systemd/tellusagent.service $(DESTDIR)/lib/systemd/system/
install -o root -g root systemd/tellusagent\@.service $(DESTDIR)/lib/systemd/system/
install -D -d $(DESTDIR)/lib/systemd/system-generators/
install -o root -g root systemd/tellusagent-generator $(DESTDIR)/lib/systemd/system-generators/
endif
ifeq ($(OS), Darwin)
# install -m 644 -o root -g root tellusagent.plist $(DESTDIR)/Library/LaunchDaemons

View file

@ -0,0 +1,22 @@
#!/bin/sh
# This systemd generator creates dependency symlinks that make all OpenVPN
# tunnels listed in /etc/default/openvpn's AUTOSTART be started/stopped/reloaded
# when openvpn.service is started/stopped/reloaded.
set -eu
GENDIR="$1"
WANTDIR="$1/tellusagent.service.wants"
SERVICEFILE="/lib/systemd/system/tellusagent@.service"
CONFIG_DIR=/opt/TellusAgent/
mkdir -p "$WANTDIR"
for CONFIG in `cd $CONFIG_DIR; ls *.conf 2> /dev/null`; do
NAME=${CONFIG%%.conf}
ln -s "$SERVICEFILE" "$WANTDIR/tellusagent@$NAME.service"
done
exit 0

View file

@ -0,0 +1,16 @@
# This service is actually a systemd target,
# but we are using a service since targets cannot be reloaded.
[Unit]
Description=TellusAgent service
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/true
ExecReload=/bin/true
WorkingDirectory=/opt/TellusAgent/
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,14 @@
[Unit]
Description=TellusAgent for %i
PartOf=tellusagent.service
ReloadPropagatedFrom=tellusagent.service
[Service]
Type=forking
EnvironmentFile=/opt/TellusAgent/%i.conf
ExecStart=/opt/TellusAgent/tellusagent --connect-port ${CONNECT_PORT} --control-port ${CONTROL_PORT} --media-port ${MEDIA_PORT} --server-address ${SERVER_ADDRESS} --service-mode ${SERVICE_MODE}
ExecReload=/bin/kill -HUP $MAINPID
WorkingDirectory=/opt/TellusAgent/
[Install]
WantedBy=multi-user.target