Update DEB install scripts to use systemd scriptlets

This commit is contained in:
Gamerboy59 2024-09-10 21:59:34 +02:00 committed by GitHub
commit 9a1fbe8bee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 41 additions and 23 deletions

View file

@ -1,20 +1,35 @@
#!/bin/bash #!/bin/sh
set -e set -e
# Source debconf library
. /usr/share/debconf/confmodule
# Create rpxy user if it doesn't exist # Create rpxy user if it doesn't exist
if ! id rpxy >/dev/null 2>&1; then if ! getent passwd rpxy > /dev/null; then
useradd --system --no-create-home --shell /usr/sbin/nologin rpxy adduser --system --group --no-create-home --shell /usr/sbin/nologin rpxy
fi fi
# Set correct user for config directory # Set correct ownership for config directory
if [ -d /etc/rpxy ]; then if [ -d /etc/rpxy ]; then
chown -R rpxy:rpxy /etc/rpxy chown -R rpxy:rpxy /etc/rpxy
fi fi
# Reload systemd, enable and start the service # Reload systemd, enable and start the service
systemctl daemon-reload if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
systemctl enable rpxy deb-systemd-helper unmask rpxy.service >/dev/null || true
systemctl start rpxy if deb-systemd-helper --quiet was-enabled rpxy.service; then
deb-systemd-helper enable rpxy.service >/dev/null || true
else
deb-systemd-helper update-state rpxy.service >/dev/null || true
fi
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
if [ -n "$2" ]; then
deb-systemd-invoke try-restart rpxy.service >/dev/null || true
else
deb-systemd-invoke start rpxy.service >/dev/null || true
fi
fi
fi
exit 0 exit 0

View file

@ -1,17 +1,22 @@
#!/bin/bash #!/bin/sh
set -e set -e
# Remove the rpxy user and configuration directory only if purging the package
if [ "$1" = "purge" ]; then if [ "$1" = "purge" ]; then
if id rpxy >/dev/null 2>&1; then # Remove the rpxy user
userdel rpxy if getent passwd rpxy >/dev/null; then
deluser --quiet --system rpxy >/dev/null || true
fi fi
# Remove config directory # Remove config directory
if [ -d /etc/rpxy ]; then rm -rf /etc/rpxy
rm -rf /etc/rpxy
fi # Remove systemd service state
deb-systemd-helper purge rpxy.service >/dev/null || true
deb-systemd-helper unmask rpxy.service >/dev/null || true
fi
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
fi fi
exit 0 exit 0

View file

@ -1,10 +1,8 @@
#!/bin/bash #!/bin/sh
set -e set -e
# Stop and disable the service before removing if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
systemctl stop rpxy || true deb-systemd-invoke stop rpxy.service >/dev/null || true
systemctl disable rpxy || true fi
systemctl daemon-reload
exit 0 exit 0

View file

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
set -e set -e