Added debconf to allow user to set user, group and config dir. Only the group is high prio and thus asked for by default.

This commit is contained in:
Taloth Saldono 2018-11-10 00:51:45 +01:00
parent 9e909cafdd
commit 40a7cf32c5
6 changed files with 62 additions and 17 deletions

View File

@ -2,6 +2,7 @@ fromdos ./debian/*
echo Version: "$dependent_build_number" Branch: "$dependent_build_branch"
rm -r ./sonarr_bin/Sonarr.Update
chmod -R 664 ./sonarr_bin/*
echo Updating changelog
sed -i "s/{version}/$dependent_build_number/g" debian/changelog

View File

@ -0,0 +1,12 @@
#!/bin/sh -e
. /usr/share/debconf/confmodule
db_beginblock
db_input medium sonarr/owning_user || true
db_input high sonarr/owning_group || true
db_input low sonarr/config_directory || true
db_endblock
db_go
exit 0

View File

@ -9,14 +9,14 @@ Build-Depends: debhelper (>= 9),
dh-systemd (>= 1.5),
mono-devel (>= 4.6),
libmono-cil-dev (>= 4.6),
cli-common-dev (>= 0.9)
cli-common-dev (>= 0.5.7)
Package: sonarr
Architecture: all
Provides: nzbdrone
Conflicts: nzbdrone
Replaces: nzbdrone
Depends: libsqlite3-0 (>= 3.7), libmediainfo0v5 (>= 0.7.52), ${shlibs:Depends}, ${cli:Depends}, ${misc:Depends}
Depends: adduser, libsqlite3-0 (>= 3.7), libmediainfo0v5 (>= 0.7.52), mono-runtime (>= 5.4), ${shlibs:Depends}, ${cli:Depends}, ${misc:Depends}
Recommends: sqlite3 (>= 3.7), mediainfo (>= 0.7.52), ${shlibs:Recommends}, ${cli:Recommends}, ${misc:Recommends}
Suggests: ${shlibs:Suggests}, ${cli:Suggests}, ${misc:Suggests}
Description: Internet PVR

View File

@ -1,25 +1,37 @@
#!/bin/sh
set -e
USER="sonarr"
# Source debconf library.
. /usr/share/debconf/confmodule
# Add User
SYSTEMD_UNIT=/lib/systemd/system/sonarr.service
db_get sonarr/owning_user
USER="$RET"
db_get sonarr/owning_group
GROUP="$RET"
db_get sonarr/config_directory
CONFDIR="$RET"
# Add User and Group
if ! getent group "$GROUP" >/dev/null; then
groupadd "$GROUP"
fi
if ! getent passwd "$USER" >/dev/null; then
adduser --quiet --system --shell /bin/bash --home /var/opt/sonarr --group "$USER"
if ! getent group "$USER" >/dev/null; then
groupadd "$USER"
usermod -a -G "$USER" "$USER"
fi
adduser --system --no-create-home --ingroup "$GROUP" "$USER"
fi
# Create home directory
if [ ! -d /var/opt/sonarr ]; then
mkdir -p /var/opt/sonarr
chown -R $USER: /var/opt/sonarr
# Create data directory
if [ ! -d "$CONFDIR" ]; then
mkdir -p "$CONFDIR"
chown -R $USER:$GROUP "$CONFDIR"
fi
# Set permissions on /opt/sonarr
chown -R $USER: /opt/sonarr
chown -R $USER:$GROUP /opt/sonarr
#DEBHELPER#
# Update sonarr.service file
sed -i "s:User=sonarr:User=$USER:g; s:Group=sonarr:Group=$GROUP:g; s:-data=/var/opt/sonarr:-data=$CONFDIR:g" $SYSTEMD_UNIT
#DEBHELPER#
exit 0

View File

@ -5,9 +5,10 @@ After=network.target
[Service]
User=sonarr
Group=sonarr
UMask=002
Type=simple
ExecStart=/usr/bin/mono --debug /opt/sonarr/bin/Sonarr.exe -nobrowser
ExecStart=/usr/bin/mono --debug /opt/sonarr/bin/Sonarr.exe -nobrowser -data=/var/opt/sonarr
TimeoutStopSec=20
KillMode=process
Restart=on-failure

View File

@ -0,0 +1,19 @@
Template: sonarr/owning_user
Type: string
Default: sonarr
Description: Sonarr user:
Specify the user that Sonarr must run as. The user will be created if it does not already exist.
Template: sonarr/owning_group
Type: string
Default: sonarr
Description: Sonarr group:
Specify the group that Sonarr must run as. The group will be created if it does not already exist.
If the user doesn't already exist then this group will be specified as the user's primary group.
Any media files created by Sonarr will be writeable by this group.
Template: sonarr/config_directory
Type: string
Default: /var/lib/sonarr
Description: Config directory:
Specify the directory where Sonarr stores the internal database and metadata. Media content will be stored elsewhere.