Added debconf to allow user to set user, group and config dir. Only the group is high prio and thus asked for by default.
parent
9e909cafdd
commit
40a7cf32c5
@ -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
|
@ -1,25 +1,37 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
USER="sonarr"
|
||||
# Source debconf library.
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
# Add User
|
||||
if ! getent passwd "$USER" >/dev/null; then
|
||||
adduser --quiet --system --shell /bin/bash --home /var/opt/sonarr --group "$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"
|
||||
|
||||
if ! getent group "$USER" >/dev/null; then
|
||||
groupadd "$USER"
|
||||
usermod -a -G "$USER" "$USER"
|
||||
fi
|
||||
# Add User and Group
|
||||
if ! getent group "$GROUP" >/dev/null; then
|
||||
groupadd "$GROUP"
|
||||
fi
|
||||
if ! getent passwd "$USER" >/dev/null; then
|
||||
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
|
||||
|
||||
# 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#
|
||||
|
||||
#DEBHELPER#
|
||||
exit 0
|
@ -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.
|
Loading…
Reference in new issue