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
|
|
|
CONF_FILE=/etc/${NAME}.conf
|
|
|
|
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
|
|
|
|
|
2018-12-09 21:41:49 +00:00
|
|
|
# Source Jellyfin user configuration overrides
|
2018-08-08 05:18:59 +00:00
|
|
|
if [[ -f $CONF_FILE ]]; then
|
|
|
|
. $CONF_FILE
|
|
|
|
fi
|
|
|
|
|
2018-12-10 00:09:43 +00:00
|
|
|
# Data directory where Jellyfin database, cache and logs are stored
|
2018-12-09 21:41:49 +00:00
|
|
|
PROGRAMDATA=${JELLYFIN_DATA-/var/lib/$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
|
2018-12-09 21:41:49 +00:00
|
|
|
# ensure jellyfin binary has appropriate permissions
|
|
|
|
chmod 755 /usr/bin/jellyfin
|
2018-08-08 05:18:59 +00:00
|
|
|
|
2018-12-09 21:41:49 +00:00
|
|
|
chmod +x ${JELLYFIN_DIR}/restart.sh > /dev/null 2>&1 || true
|
2018-08-08 05:18:59 +00:00
|
|
|
|
2018-12-10 01:10:05 +00:00
|
|
|
# Link hardcoded /var/lib/emby to /var/lib/jellyfin (TEMPORARY)
|
|
|
|
ln -sf /var/lib/jellyfin /var/lib/emby
|
|
|
|
|
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
|