Update to go-sbot systemctl system service

This commit is contained in:
notplants 2022-04-14 12:38:54 -04:00
parent 0907c07c97
commit 336fc9536a
5 changed files with 19 additions and 23 deletions

17
conf/templates/go_sbot/DEBIAN/postinst Executable file → Normal file
View File

@ -1,7 +1,7 @@
#!/bin/sh
set -e
# create user which go-sbot runs as (if doesnt exist)
# create user which go-sbot runs as
id -u peach &>/dev/null || adduser --quiet peach
# set permissions
@ -11,33 +11,30 @@ chown peach /usr/bin/sbotcli
# Automatically added by cargo-deb
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper --user unmask go-sbot.service >/dev/null || true
deb-systemd-helper unmask go-sbot.service >/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --user --quiet was-enabled go-sbot.service; then
if deb-systemd-helper --quiet was-enabled go-sbot.service; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper --user enable go-sbot.service >/dev/null || true
deb-systemd-helper enable go-sbot.service >/dev/null || true
else
# 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 go-sbot.service >/dev/null || true
deb-systemd-helper update-state go-sbot.service >/dev/null || true
fi
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;}')"
USER="peach"
runuser -l $USER -c "XDG_RUNTIME_DIR=/run/user/$(id -u $USER) systemctl --user daemon-reload >/dev/null || true"
systemctl --system 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 go-sbot.service >/dev/null || true"
deb-systemd-invoke $_dh_action go-sbot.service >/dev/null || true
fi
fi
# End automatically added section

12
conf/templates/go_sbot/DEBIAN/postrm Executable file → Normal file
View File

@ -1,21 +1,21 @@
#!/bin/sh
set -e
# Automatically added by cargo-deb
if [ -d /run/systemd/system ]; then
# USER="$(who | head -1 | awk '{print $1;}')"
USER="peach"
runuser -l $USER -c "XDG_RUNTIME_DIR=/run/user/$(id -u $USER) systemctl --user daemon-reload >/dev/null || true"
systemctl --system 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
deb-systemd-helper --user mask service >/dev/null || true
deb-systemd-helper mask go-sbot.service >/dev/null || true
fi
fi
if [ "$1" = "purge" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper --user purge service >/dev/null || true
deb-systemd-helper --user unmask service >/dev/null || true
deb-systemd-helper purge go-sbot.service >/dev/null || true
deb-systemd-helper unmask go-sbot.service >/dev/null || true
fi
fi
# End automatically added section

6
conf/templates/go_sbot/DEBIAN/prerm Executable file → Normal file
View File

@ -1,7 +1,7 @@
#!/bin/sh
set -e
# Automatically added by cargo-deb
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
# USER="$(who | head -1 | awk '{print $1;}')"
USER="peach"
runuser -l $USER -c "XDG_RUNTIME_DIR=/run/user/$(id -u $USER) deb-systemd-invoke --user stop service >/dev/null || true"
deb-systemd-invoke stop go-sbot.service >/dev/null || true
fi
# End automatically added section

View File

@ -1,5 +1,5 @@
[Unit]
Description=peachs go-sbot
Description=peachcloud go-sbot
[Service]
Type=simple

View File

@ -14,7 +14,7 @@ from peach_package_builder.constants import *
from peach_package_builder.utils import render_template, add_deb_to_freight, update_freight_cache
# manually update this version when we want to build a new peach-go-sbot package
GO_SBOT_VERSION = '0.1.21'
GO_SBOT_VERSION = '0.1.24'
# constants
DEB_CONF_DIR = os.path.join(PROJECT_PATH, 'conf/templates/go_sbot')
@ -48,8 +48,7 @@ def package_go_sbot(version):
render_template(src=src, dest=dest, template_vars={"version": version})
# copy systemd service file
SERVICE_DIR = os.path.join(DEB_BUILD_DIR, 'home/peach/.config/systemd')
# SERVICE_DIR = os.path.join(DEB_BUILD_DIR, 'lib/systemd/system')
SERVICE_DIR = os.path.join(DEB_BUILD_DIR, 'lib/systemd/system')
os.makedirs(SERVICE_DIR)
shutil.copyfile(
os.path.join(DEB_CONF_DIR, 'go-sbot.service'),