aboutsummaryrefslogtreecommitdiff
path: root/debian/postinst
diff options
context:
space:
mode:
authorJoshua Boniface <joshua@boniface.me>2018-08-08 01:18:59 -0400
committerVasily <just.one.man@yandex.ru>2018-10-22 01:56:13 +0300
commitc0953e51b5019c968fe5d9c8f25f47f08ed4e829 (patch)
treebd8a44c47c18050550e17a2ffd1dd9bed56e5d88 /debian/postinst
parent48facb797ed912e4ea6b04b17d1ff190ac2daac4 (diff)
Add patches and debian build information for emby-server
Diffstat (limited to 'debian/postinst')
-rw-r--r--debian/postinst81
1 files changed, 81 insertions, 0 deletions
diff --git a/debian/postinst b/debian/postinst
new file mode 100644
index 000000000..f1469f1c1
--- /dev/null
+++ b/debian/postinst
@@ -0,0 +1,81 @@
+#!/bin/bash
+set -e
+
+NAME=emby-server
+CONF_FILE=/etc/${NAME}.conf
+DEFAULT_FILE=/etc/default/${NAME}
+
+# Source Emby server default configuration
+if [[ -f $DEFAULT_FILE ]]; then
+ . $DEFAULT_FILE
+fi
+
+# Source Emby server user configuration overrides
+if [[ -f $CONF_FILE ]]; then
+ . $CONF_FILE
+fi
+
+# Data directory where Emby database, cache and logs are stored
+PROGRAMDATA=${EMBY_DATA-/var/lib/$NAME}
+
+case "$1" in
+ configure)
+ # create emby group if it does not exist
+ if [[ -z "$(getent group emby)" ]]; then
+ addgroup --quiet --system emby > /dev/null 2>&1
+ fi
+ # create emby user if it does not exist
+ if [[ -z "$(getent passwd emby)" ]]; then
+ adduser --system --ingroup emby --shell /bin/false emby --no-create-home --home ${PROGRAMDATA} \
+ --gecos "Emby Server default user" > /dev/null 2>&1
+ fi
+ # ensure $PROGRAMDATA has appropriate permissions
+ if [[ ! -d $PROGRAMDATA ]]; then
+ mkdir $PROGRAMDATA
+ chown -R emby:emby $PROGRAMDATA
+ fi
+ # ensure emby-server binary has appropriate permissions
+ chmod 755 /usr/bin/emby-server
+
+ /usr/bin/mono --aot=full -O=all $EMBY_BIN > /dev/null 2>&1 || true
+
+ chmod +x ${EMBY_DIR}/restart.sh > /dev/null 2>&1 || true
+
+ ;;
+ 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
+ deb-systemd-helper unmask emby-server.service >/dev/null || true
+ # was-enabled defaults to true, so new installations run enable.
+ if deb-systemd-helper --quiet was-enabled emby-server.service; then
+ # Enables the unit on first installation, creates new
+ # symlinks on upgrades if the unit file has changed.
+ deb-systemd-helper enable emby-server.service >/dev/null || true
+ else
+ # Update the statefile to add new symlinks (if any), which need to be
+ # cleaned up on purge. Also remove old symlinks.
+ deb-systemd-helper update-state emby-server.service >/dev/null || true
+ 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
+ deb-systemd-invoke start emby-server >/dev/null || true
+ elif [[ -x "/etc/init.d/emby-server" ]] || [[ -e "/etc/init/emby-server.conf" ]]; then
+ update-rc.d emby-server defaults >/dev/null
+ invoke-rc.d emby-server start || exit $?
+ fi
+fi
+exit 0