2018-08-08 05:18:59 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2018-12-09 21:41:49 +00:00
|
|
|
NAME=jellyfin
|
2018-08-08 05:18:59 +00:00
|
|
|
DEFAULT_FILE=/etc/default/${NAME}
|
|
|
|
|
2018-12-09 21:41:49 +00:00
|
|
|
# Source Jellyfin default configuration
|
2018-08-08 05:18:59 +00:00
|
|
|
if [[ -f $DEFAULT_FILE ]]; then
|
|
|
|
. $DEFAULT_FILE
|
|
|
|
fi
|
|
|
|
|
2019-01-06 00:55:55 +00:00
|
|
|
# Data directories for program data (cache, db), configs, and logs
|
|
|
|
PROGRAMDATA=${JELLYFIN_DATA_DIRECTORY-/var/lib/$NAME}
|
|
|
|
CONFIGDATA=${JELLYFIN_CONFIG_DIRECTORY-/etc/$NAME}
|
|
|
|
LOGDATA=${JELLYFIN_LOG_DIRECTORY-/var/log/$NAME}
|
2018-08-08 05:18:59 +00:00
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
configure)
|
2018-12-09 21:41:49 +00:00
|
|
|
# create jellyfin group if it does not exist
|
|
|
|
if [[ -z "$(getent group jellyfin)" ]]; then
|
|
|
|
addgroup --quiet --system jellyfin > /dev/null 2>&1
|
2018-08-08 05:18:59 +00:00
|
|
|
fi
|
2018-12-09 21:41:49 +00:00
|
|
|
# create jellyfin user if it does not exist
|
|
|
|
if [[ -z "$(getent passwd jellyfin)" ]]; then
|
|
|
|
adduser --system --ingroup jellyfin --shell /bin/false jellyfin --no-create-home --home ${PROGRAMDATA} \
|
|
|
|
--gecos "Jellyfin default user" > /dev/null 2>&1
|
2018-08-08 05:18:59 +00:00
|
|
|
fi
|
|
|
|
# ensure $PROGRAMDATA has appropriate permissions
|
|
|
|
if [[ ! -d $PROGRAMDATA ]]; then
|
|
|
|
mkdir $PROGRAMDATA
|
2018-12-09 21:41:49 +00:00
|
|
|
chown -R jellyfin:jellyfin $PROGRAMDATA
|
2018-08-08 05:18:59 +00:00
|
|
|
fi
|
2019-01-06 00:55:55 +00:00
|
|
|
# ensure $JELLYFIN_CONFIG_DIRECTORY has appropriate permissions
|
|
|
|
if [[ -n $JELLYFIN_CONFIG_DIRECTORY && ! -d $JELLYFIN_CONFIG_DIRECTORY ]]; then
|
|
|
|
mkdir $JELLYFIN_CONFIG_DIRECTORY
|
|
|
|
chown -R jellyfin:jellyfin $JELLYFIN_CONFIG_DIRECTORY
|
|
|
|
fi
|
|
|
|
# ensure $JELLYFIN_LOG_DIRECTORY has appropriate permissions
|
|
|
|
if [[ -n $JELLYFIN_LOG_DIRECTORY && ! -d $JELLYFIN_LOG_DIRECTORY ]]; then
|
|
|
|
mkdir $JELLYFIN_LOG_DIRECTORY
|
|
|
|
chown -R jellyfin:jellyfin $JELLYFIN_LOG_DIRECTORY
|
|
|
|
fi
|
2018-08-08 05:18:59 +00:00
|
|
|
|
2019-01-06 00:55:55 +00:00
|
|
|
chmod +x /usr/lib/jellyfin/restart.sh > /dev/null 2>&1 || true
|
2018-08-08 05:18:59 +00:00
|
|
|
|
2018-12-15 02:21:48 +00:00
|
|
|
# Install jellyfin symlink into /usr/bin
|
|
|
|
ln -sf /usr/lib/jellyfin/bin/jellyfin /usr/bin/jellyfin
|
|
|
|
|
2018-08-08 05:18:59 +00:00
|
|
|
;;
|
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "postinst called with unknown argument \`$1'" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
#DEBHELPER
|
|
|
|
|
|
|
|
if [[ -x "/usr/bin/deb-systemd-helper" ]]; then
|
|
|
|
# Manual init script handling
|
2018-12-09 21:41:49 +00:00
|
|
|
deb-systemd-helper unmask jellyfin.service >/dev/null || true
|
2018-08-08 05:18:59 +00:00
|
|
|
# was-enabled defaults to true, so new installations run enable.
|
2018-12-09 21:41:49 +00:00
|
|
|
if deb-systemd-helper --quiet was-enabled jellyfin.service; then
|
2018-08-08 05:18:59 +00:00
|
|
|
# Enables the unit on first installation, creates new
|
|
|
|
# symlinks on upgrades if the unit file has changed.
|
2018-12-09 21:41:49 +00:00
|
|
|
deb-systemd-helper enable jellyfin.service >/dev/null || true
|
2018-08-08 05:18:59 +00:00
|
|
|
else
|
|
|
|
# Update the statefile to add new symlinks (if any), which need to be
|
|
|
|
# cleaned up on purge. Also remove old symlinks.
|
2018-12-09 21:41:49 +00:00
|
|
|
deb-systemd-helper update-state jellyfin.service >/dev/null || true
|
2018-08-08 05:18:59 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# End automatically added section
|
|
|
|
# Automatically added by dh_installinit
|
|
|
|
if [[ "$1" == "configure" ]] || [[ "$1" == "abort-upgrade" ]]; then
|
|
|
|
if [[ -d "/run/systemd/systemd" ]]; then
|
|
|
|
systemctl --system daemon-reload >/dev/null || true
|
2018-12-09 21:41:49 +00:00
|
|
|
deb-systemd-invoke start jellyfin >/dev/null || true
|
|
|
|
elif [[ -x "/etc/init.d/jellyfin" ]] || [[ -e "/etc/init/jellyfin.conf" ]]; then
|
|
|
|
update-rc.d jellyfin defaults >/dev/null
|
|
|
|
invoke-rc.d jellyfin start || exit $?
|
2018-08-08 05:18:59 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
exit 0
|