From 0bb08b3f8d530525b19c7967bcbd1d7ab81e91ee Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Fri, 11 Jan 2019 23:35:14 +0100 Subject: [PATCH] Added debian bin folder. --- .gitignore | 14 +++---- .../pkg-src/bin/jellyfin-sudoers | 37 +++++++++++++++++++ .../debian-package-x64/pkg-src/bin/restart.sh | 18 +++++++++ 3 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 deployment/debian-package-x64/pkg-src/bin/jellyfin-sudoers create mode 100644 deployment/debian-package-x64/pkg-src/bin/restart.sh diff --git a/.gitignore b/.gitignore index b4b928ef27..a719ec32b1 100644 --- a/.gitignore +++ b/.gitignore @@ -249,14 +249,14 @@ pip-log.txt ######################### # Artifacts for debian-x64 -deployment/debian-x64/pkg-src/.debhelper/ -deployment/debian-x64/pkg-src/*.debhelper -deployment/debian-x64/pkg-src/debhelper-build-stamp -deployment/debian-x64/pkg-src/files -deployment/debian-x64/pkg-src/jellyfin.substvars -deployment/debian-x64/pkg-src/jellyfin/ +deployment/debian-package-x64/pkg-src/.debhelper/ +deployment/debian-package-x64/pkg-src/*.debhelper +deployment/debian-package-x64/pkg-src/debhelper-build-stamp +deployment/debian-package-x64/pkg-src/files +deployment/debian-package-x64/pkg-src/jellyfin.substvars +deployment/debian-package-x64/pkg-src/jellyfin/ # Don't ignore the debian/bin folder -!deployment/debian-x64/pkg-src/bin/ +!deployment/debian-package-x64/pkg-src/bin/ deployment/**/dist/ deployment/**/pkg-dist/ diff --git a/deployment/debian-package-x64/pkg-src/bin/jellyfin-sudoers b/deployment/debian-package-x64/pkg-src/bin/jellyfin-sudoers new file mode 100644 index 0000000000..4eb91366b4 --- /dev/null +++ b/deployment/debian-package-x64/pkg-src/bin/jellyfin-sudoers @@ -0,0 +1,37 @@ +#Allow jellyfin group to start, stop and restart itself +Cmnd_Alias RESTARTSERVER_SYSV = /sbin/service jellyfin restart, /usr/sbin/service jellyfin restart +Cmnd_Alias STARTSERVER_SYSV = /sbin/service jellyfin start, /usr/sbin/service jellyfin start +Cmnd_Alias STOPSERVER_SYSV = /sbin/service jellyfin stop, /usr/sbin/service jellyfin stop +Cmnd_Alias RESTARTSERVER_SYSTEMD = /usr/bin/systemctl restart jellyfin, /bin/systemctl restart jellyfin +Cmnd_Alias STARTSERVER_SYSTEMD = /usr/bin/systemctl start jellyfin, /bin/systemctl start jellyfin +Cmnd_Alias STOPSERVER_SYSTEMD = /usr/bin/systemctl stop jellyfin, /bin/systemctl stop jellyfin +Cmnd_Alias RESTARTSERVER_INITD = /etc/init.d/jellyfin restart +Cmnd_Alias STARTSERVER_INITD = /etc/init.d/jellyfin start +Cmnd_Alias STOPSERVER_INITD = /etc/init.d/jellyfin stop + + +%jellyfin ALL=(ALL) NOPASSWD: RESTARTSERVER_SYSV +%jellyfin ALL=(ALL) NOPASSWD: STARTSERVER_SYSV +%jellyfin ALL=(ALL) NOPASSWD: STOPSERVER_SYSV +%jellyfin ALL=(ALL) NOPASSWD: RESTARTSERVER_SYSTEMD +%jellyfin ALL=(ALL) NOPASSWD: STARTSERVER_SYSTEMD +%jellyfin ALL=(ALL) NOPASSWD: STOPSERVER_SYSTEMD +%jellyfin ALL=(ALL) NOPASSWD: RESTARTSERVER_INITD +%jellyfin ALL=(ALL) NOPASSWD: STARTSERVER_INITD +%jellyfin ALL=(ALL) NOPASSWD: STOPSERVER_INITD + +Defaults!RESTARTSERVER_SYSV !requiretty +Defaults!STARTSERVER_SYSV !requiretty +Defaults!STOPSERVER_SYSV !requiretty +Defaults!RESTARTSERVER_SYSTEMD !requiretty +Defaults!STARTSERVER_SYSTEMD !requiretty +Defaults!STOPSERVER_SYSTEMD !requiretty +Defaults!RESTARTSERVER_INITD !requiretty +Defaults!STARTSERVER_INITD !requiretty +Defaults!STOPSERVER_INITD !requiretty + +#Allow the server to mount iso images +%jellyfin ALL=(ALL) NOPASSWD: /bin/mount +%jellyfin ALL=(ALL) NOPASSWD: /bin/umount + +Defaults:%jellyfin !requiretty diff --git a/deployment/debian-package-x64/pkg-src/bin/restart.sh b/deployment/debian-package-x64/pkg-src/bin/restart.sh new file mode 100644 index 0000000000..a6f4632ba7 --- /dev/null +++ b/deployment/debian-package-x64/pkg-src/bin/restart.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +NAME=jellyfin + +restart_cmds=("s6-svc -t /var/run/s6/services/${NAME}" \ + "systemctl restart ${NAME}" \ + "service ${NAME} restart" \ + "/etc/init.d/${NAME} restart") + +for restart_cmd in "${restart_cmds[@]}"; do + cmd=$(echo "$restart_cmd" | awk '{print $1}') + cmd_loc=$(command -v ${cmd}) + if [[ -n "$cmd_loc" ]]; then + restart_cmd=$(echo "$restart_cmd" | sed -e "s%${cmd}%${cmd_loc}%") + echo "sleep 2; sudo $restart_cmd > /dev/null 2>&1" | at now > /dev/null 2>&1 + exit 0 + fi +done