From c63186a798d5a213ca247046726e3ace2c9b8752 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sat, 27 Oct 2018 19:43:41 +0200 Subject: [PATCH] Use dh_systemd to configure systemd unit installation. --- distribution/debian/control | 2 ++ distribution/debian/install | 1 - distribution/debian/postinst | 22 +++++++--------------- distribution/debian/postrm | 9 --------- distribution/debian/prerm | 6 ------ distribution/debian/rules | 6 +++++- 6 files changed, 14 insertions(+), 32 deletions(-) delete mode 100644 distribution/debian/postrm delete mode 100644 distribution/debian/prerm diff --git a/distribution/debian/control b/distribution/debian/control index 02e041e2e..e3e63dbe0 100644 --- a/distribution/debian/control +++ b/distribution/debian/control @@ -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 diff --git a/distribution/debian/install b/distribution/debian/install index 9900a5aa4..f2774956c 100644 --- a/distribution/debian/install +++ b/distribution/debian/install @@ -1,2 +1 @@ sonarr_bin/* /opt/sonarr -debian/sonarr.service /lib/systemd/system diff --git a/distribution/debian/postinst b/distribution/debian/postinst index eb0c8983c..6716dc239 100644 --- a/distribution/debian/postinst +++ b/distribution/debian/postinst @@ -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# \ No newline at end of file diff --git a/distribution/debian/postrm b/distribution/debian/postrm deleted file mode 100644 index e36cac680..000000000 --- a/distribution/debian/postrm +++ /dev/null @@ -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 diff --git a/distribution/debian/prerm b/distribution/debian/prerm deleted file mode 100644 index 6cc5f898f..000000000 --- a/distribution/debian/prerm +++ /dev/null @@ -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 diff --git a/distribution/debian/rules b/distribution/debian/rules index b760bee7f..a28409dd7 100644 --- a/distribution/debian/rules +++ b/distribution/debian/rules @@ -10,4 +10,8 @@ #export DH_VERBOSE=1 %: - dh $@ + dh $@ --with=systemd + +# No init script, only systemd +override_dh_installinit: + true