Merge pull request 'Closes #34' (#35) from systemd-fix into main
All checks were successful
Run Tests on Code / run-tests (push) Successful in 8s

Reviewed-on: #35
This commit is contained in:
Neshura 2024-01-08 08:46:26 +00:00
commit 9dfd21ce8d
6 changed files with 3 additions and 94 deletions

View file

@ -16,12 +16,7 @@ assets = [
"target/release/cloudflare-dns-updater",
"/usr/local/bin/cloudflare-dns-updater",
"755",
],
[
"debian/cloudflare-dns-updater-user.service",
"/lib/systemd/user/cloudflare-dns-updater.service",
"755",
],
]
]
systemd-units = { enable = false }

View file

@ -1,13 +0,0 @@
[Unit]
Description="Application for automatically updating Cloudflare DNS records"
After=syslog.target
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/cloudflare-dns-updater
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target

View file

@ -5,9 +5,10 @@ After=network-online.target
[Service]
Type=simple
User=%i
ExecStart=/usr/local/bin/cloudflare-dns-updater
Restart=always
RestartSec=3
[Install]
WantedBy=default.target
WantedBy=multi-user.target

36
debian/postinst vendored
View file

@ -1,36 +0,0 @@
#!/bin/sh
#DEBHELPER#
# Also enable User Service
# Automatically added by cargo-deb
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if deb-systemd-helper --user debian-installed cloudflare-dns-updater.service; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper --user unmask cloudflare-dns-updater.service >/dev/null || true
if deb-systemd-helper --user --quiet was-enabled cloudflare-dns-updater.service; then
# Create new symlinks, if any.
deb-systemd-helper --user enable cloudflare-dns-updater.service >/dev/null || true
fi
fi
# Update the statefile to add new symlinks (if any), which need to be cleaned
# up on purge. Also remove old symlinks.
deb-systemd-helper --user update-state cloudflare-dns-updater.service >/dev/null || true
fi
# End automatically added section
# Automatically added by cargo-deb
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if [ -d /run/systemd/system ]; then
USER="$(who | head -1 | awk '{print $1;}')"
runuser -l $USER -c "XDG_RUNTIME_DIR=/run/user/$(id -u $USER) systemctl --user daemon-reload >/dev/null || true"
if [ -n "$2" ]; then
_dh_action=restart
else
_dh_action=start
fi
runuser -l $USER -c "XDG_RUNTIME_DIR=/run/user/$(id -u $USER) deb-systemd-invoke --user $_dh_action cloudflare-dns-updater.service >/dev/null || true"
fi
fi
# End automatically added section

27
debian/postrm vendored
View file

@ -1,27 +0,0 @@
#!/bin/sh
#DEBHELPER#
# Also enable User Service
# Automatically added by cargo-deb
if [ -d /run/systemd/system ]; then
USER="$(who | head -1 | awk '{print $1;}')"
runuser -l $USER -c "XDG_RUNTIME_DIR=/run/user/$(id -u $USER) systemctl --user daemon-reload >/dev/null || true"
fi
# End automatically added section
# Automatically added by cargo-deb
if [ "$1" = "remove" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
USER="$(who | head -1 | awk '{print $1;}')"
runuser -l $USER -c "XDG_RUNTIME_DIR=/run/user/$(id -u $USER) deb-systemd-helper --user mask cloudflare-dns-updater.service >/dev/null || true"
fi
fi
if [ "$1" = "purge" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
USER="$(who | head -1 | awk '{print $1;}')"
runuser -l $USER -c "XDG_RUNTIME_DIR=/run/user/$(id -u $USER) deb-systemd-helper --user purge cloudflare-dns-updater.service >/dev/null || true"
runuser -l $USER -c "XDG_RUNTIME_DIR=/run/user/$(id -u $USER) deb-systemd-helper --user unmask cloudflare-dns-updater.service >/dev/null || true"
fi
fi
# End automatically added section

11
debian/prerm vendored
View file

@ -1,11 +0,0 @@
#!/bin/sh
#DEBHELPER#
# Also enable User Service
# Automatically added by cargo-deb
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
USER="$(who | head -1 | awk '{print $1;}')"
runuser -l $USER -c "XDG_RUNTIME_DIR=/run/user/$(id -u $USER) deb-systemd-invoke --user stop cloudflare-dns-updater.service >/dev/null || true"
fi
# End automatically added section