Use dh_systemd to configure systemd unit installation.

pull/2789/head
Taloth Saldono 6 years ago
parent a0ce2d7cdf
commit c63186a798

@ -5,6 +5,8 @@ Source: sonarr
Homepage: https://sonarr.tv
Vcs-Git: git@github.com:Sonarr/Sonarr.git
Vcs-Browser: https://github.com/Sonarr/Sonarr
Build-Depends: debhelper (>= 9),
dh-systemd (>= 1.5)
Package: sonarr
Architecture: all

@ -1,2 +1 @@
sonarr_bin/* /opt/sonarr
debian/sonarr.service /lib/systemd/system

@ -1,7 +1,9 @@
#!/bin/sh
set -e
USER="sonarr"
# Add User
if ! getent passwd "$USER" >/dev/null; then
adduser --quiet --system --shell /bin/bash --home /var/opt/sonarr --group "$USER"
@ -10,24 +12,14 @@ if ! getent passwd "$USER" >/dev/null; then
usermod -a -G "$USER" "$USER"
fi
fi
# Create home directory
# Create home directory
if [ ! -d /var/opt/sonarr ]; then
mkdir -p /var/opt/sonarr
chown $USER:$USER /var/opt/sonarr
chown -R $USER: /var/opt/sonarr
fi
# Set permissions on /opt/sonarr
chown -R $USER: /opt/sonarr
chown -R $USER:$USER /opt/sonarr
# Start Sonarr automatically
if [ -f /proc/1/comm ]; then
if [ "`cat /proc/1/comm`" = "systemd" ]; then
# Enable and start systemd service
systemctl enable sonarr.service
systemctl start sonarr.service
fi
fi
#DEBHELPER#

@ -1,9 +0,0 @@
#!/bin/sh
set -e
# In case this system is running systemd, we make systemd reload the unit files
# to pick up changes.
if [ -d /run/systemd/system ] ; then
systemctl --system daemon-reload >/dev/null || true
fi
# End automatically added section

@ -1,6 +0,0 @@
#!/bin/sh
if [ -f /proc/1/comm ] && [ "`cat /proc/1/comm`" = "systemd" ]; then
rm -f /etc/init.d/sonarr
systemctl stop sonarr.service
systemctl disable sonarr.service
fi

@ -10,4 +10,8 @@
#export DH_VERBOSE=1
%:
dh $@
dh $@ --with=systemd
# No init script, only systemd
override_dh_installinit:
true

Loading…
Cancel
Save