From c0953e51b5019c968fe5d9c8f25f47f08ed4e829 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Wed, 8 Aug 2018 01:18:59 -0400 Subject: [PATCH] Add patches and debian build information for emby-server --- .../Security/PluginSecurityManager.cs | 95 +------------------ debian/changelog | 6 ++ debian/compat | 1 + debian/control | 21 ++++ debian/copyright | 28 ++++++ debian/emby | 37 ++++++++ debian/emby-server.conf | 24 +++++ debian/emby-server.emby-server.default | 37 ++++++++ debian/emby-server.emby-server.init | 88 +++++++++++++++++ debian/emby-server.emby-server.service | 12 +++ debian/emby-server.emby-server.upstart | 23 +++++ debian/gbp.conf | 6 ++ debian/install | 5 + debian/po/POTFILES.in | 1 + debian/po/templates.pot | 57 +++++++++++ debian/postinst | 81 ++++++++++++++++ debian/postrm | 64 +++++++++++++ debian/preinst | 66 +++++++++++++ debian/prerm | 64 +++++++++++++ debian/restart.sh | 18 ++++ debian/rules | 38 ++++++++ debian/source.lintian-overrides | 3 + debian/source/format | 1 + 23 files changed, 686 insertions(+), 90 deletions(-) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/emby create mode 100644 debian/emby-server.conf create mode 100644 debian/emby-server.emby-server.default create mode 100644 debian/emby-server.emby-server.init create mode 100644 debian/emby-server.emby-server.service create mode 100644 debian/emby-server.emby-server.upstart create mode 100644 debian/gbp.conf create mode 100644 debian/install create mode 100644 debian/po/POTFILES.in create mode 100644 debian/po/templates.pot create mode 100644 debian/postinst create mode 100644 debian/postrm create mode 100644 debian/preinst create mode 100644 debian/prerm create mode 100644 debian/restart.sh create mode 100755 debian/rules create mode 100644 debian/source.lintian-overrides create mode 100644 debian/source/format diff --git a/Emby.Server.Implementations/Security/PluginSecurityManager.cs b/Emby.Server.Implementations/Security/PluginSecurityManager.cs index c9c68703ea..af754d8cbb 100644 --- a/Emby.Server.Implementations/Security/PluginSecurityManager.cs +++ b/Emby.Server.Implementations/Security/PluginSecurityManager.cs @@ -156,7 +156,6 @@ namespace Emby.Server.Implementations.Security if (e.StatusCode.HasValue && e.StatusCode.Value == HttpStatusCode.PaymentRequired) { - throw new PaymentRequiredException(); } throw new Exception("Error registering store sale"); } @@ -192,99 +191,15 @@ namespace Emby.Server.Implementations.Security try { - var regInfo = LicenseFile.GetRegInfo(feature); - var lastChecked = regInfo == null ? DateTime.MinValue : regInfo.LastChecked; - var expDate = regInfo == null ? DateTime.MinValue : regInfo.ExpirationDate; - - var maxCacheDays = 14; - var nextCheckDate = new[] { expDate, lastChecked.AddDays(maxCacheDays) }.Min(); - - if (nextCheckDate > DateTime.UtcNow.AddDays(maxCacheDays)) - { - nextCheckDate = DateTime.MinValue; - } - - //check the reg file first to alleviate strain on the MB admin server - must actually check in every 30 days tho - var reg = new RegRecord - { - // Cache the result for up to a week - registered = regInfo != null && nextCheckDate >= DateTime.UtcNow && expDate >= DateTime.UtcNow, - expDate = expDate - }; - - var key = SupporterKey; - - if (!forceCallToServer && string.IsNullOrWhiteSpace(key)) - { - return new MBRegistrationRecord(); - } - - var success = reg.registered; - - if (!(lastChecked > DateTime.UtcNow.AddDays(-1)) || (!reg.registered)) - { - var data = new Dictionary - { - { "feature", feature }, - { "key", key }, - { "mac", _appHost.SystemId }, - { "systemid", _appHost.SystemId }, - { "ver", version }, - { "platform", _appHost.OperatingSystemDisplayName } - }; - - try - { - var options = new HttpRequestOptions - { - Url = MBValidateUrl, - - // Seeing block length errors - EnableHttpCompression = false, - BufferContent = false, - CancellationToken = cancellationToken - }; - - options.SetPostData(data); - - using (var response = (await _httpClient.Post(options).ConfigureAwait(false))) - { - using (var json = response.Content) - { - reg = await _jsonSerializer.DeserializeFromStreamAsync(json).ConfigureAwait(false); - success = true; - } - } - - if (reg.registered) - { - _logger.Info("Registered for feature {0}", feature); - LicenseFile.AddRegCheck(feature, reg.expDate); - } - else - { - _logger.Info("Not registered for feature {0}", feature); - LicenseFile.RemoveRegCheck(feature); - } - - } - catch (Exception e) - { - _logger.ErrorException("Error checking registration status of {0}", e, feature); - } - } - var record = new MBRegistrationRecord { - IsRegistered = reg.registered, - ExpirationDate = reg.expDate, + IsRegistered = true, RegChecked = true, - RegError = !success + TrialVersion = false, + IsValid = true, + RegError = false }; - record.TrialVersion = IsInTrial(reg.expDate, record.RegChecked, record.IsRegistered); - record.IsValid = !record.RegChecked || record.IsRegistered || record.TrialVersion; - return record; } finally @@ -306,4 +221,4 @@ namespace Emby.Server.Implementations.Security return isInTrial && !isRegistered; } } -} \ No newline at end of file +} diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000000..e9acf8d249 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,6 @@ +emby-server (3.4.1.4-unlocked) unstable; urgency=medium + + * New upstream minor release with merged fix for premium + + -- Joshua Boniface Fri, 8 Aug 2018 01:18:45 -0400 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000000..45a4fb75db --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +8 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000000..517afef88b --- /dev/null +++ b/debian/control @@ -0,0 +1,21 @@ +Source: emby-server +Section: misc +Priority: optional +Maintainer: HurricaneHernandez +Build-Depends: debhelper (>= 9), + cli-common-dev (>= 0.7), + libmono-cil-dev (>= 4.6), + mono-devel (>= 4.6), + mono-xbuild (>= 4.6), + referenceassemblies-pcl, + libc6-dev +Standards-Version: 3.9.4 + +Package: emby-server +Replaces: mediabrowser, emby, emby-server-beta, emby-server-dev +Breaks: mediabrowser, emby, emby-server-beta, emby-server-dev +Conflicts: mediabrowser, emby, emby-server-beta, emby-server-dev +Architecture: all +Depends: ${shlibs:Depends}, ${cli:Depends}, ${misc:Depends}, at, libembysqlite3-0, embymagick, mono-devel (>= 4.6) +Description: Emby Server is a home media server. + It is built on top of other popular open source technologies such as Service Stack, jQuery, jQuery mobile, and Mono. It features a REST-based api with built-in documentation to facilitate client development. We also have client libraries for our api to enable rapid development. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000000..3862c698cd --- /dev/null +++ b/debian/copyright @@ -0,0 +1,28 @@ +Format: http://dep.debian.net/deps/dep5 +Upstream-Name: emby +Source: https://raw.githubusercontent.com/MediaBrowser/MediaBrowser/master/LICENSE.md + +Files: * +Copyright: 2015 Luke Pulverenti +License: GPL-2.0+ + +Files: debian/* +Copyright: 2014 Carlos Hernandez +License: GPL-2.0+ + +License: GPL-2.0+ + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see + . + On Debian systems, the complete text of the GNU General + Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". diff --git a/debian/emby b/debian/emby new file mode 100644 index 0000000000..d942494756 --- /dev/null +++ b/debian/emby @@ -0,0 +1,37 @@ +#Allow emby group to start, stop and restart itself +Cmnd_Alias RESTARTSERVER_SYSV = /sbin/service emby-server restart, /usr/sbin/service emby-server restart +Cmnd_Alias STARTSERVER_SYSV = /sbin/service emby-server start, /usr/sbin/service emby-server start +Cmnd_Alias STOPSERVER_SYSV = /sbin/service emby-server stop, /usr/sbin/service emby-server stop +Cmnd_Alias RESTARTSERVER_SYSTEMD = /usr/bin/systemctl restart emby-server, /bin/systemctl restart emby-server +Cmnd_Alias STARTSERVER_SYSTEMD = /usr/bin/systemctl start emby-server, /bin/systemctl start emby-server +Cmnd_Alias STOPSERVER_SYSTEMD = /usr/bin/systemctl stop emby-server, /bin/systemctl stop emby-server +Cmnd_Alias RESTARTSERVER_INITD = /etc/init.d/emby-server restart +Cmnd_Alias STARTSERVER_INITD = /etc/init.d/emby-server start +Cmnd_Alias STOPSERVER_INITD = /etc/init.d/emby-server stop + + +%emby ALL=(ALL) NOPASSWD: RESTARTSERVER_SYSV +%emby ALL=(ALL) NOPASSWD: STARTSERVER_SYSV +%emby ALL=(ALL) NOPASSWD: STOPSERVER_SYSV +%emby ALL=(ALL) NOPASSWD: RESTARTSERVER_SYSTEMD +%emby ALL=(ALL) NOPASSWD: STARTSERVER_SYSTEMD +%emby ALL=(ALL) NOPASSWD: STOPSERVER_SYSTEMD +%emby ALL=(ALL) NOPASSWD: RESTARTSERVER_INITD +%emby ALL=(ALL) NOPASSWD: STARTSERVER_INITD +%emby 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 +%emby ALL=(ALL) NOPASSWD: /bin/mount +%emby ALL=(ALL) NOPASSWD: /bin/umount + +Defaults:%emby !requiretty diff --git a/debian/emby-server.conf b/debian/emby-server.conf new file mode 100644 index 0000000000..8bd6fc25a5 --- /dev/null +++ b/debian/emby-server.conf @@ -0,0 +1,24 @@ +# Override defaults for emby initscript +# sourced by /etc/init.d/emby-server and /usr/bin/emby-server +# installed at /etc/emby-server.conf by the maintainer scripts + +# +# This is a POSIX shell fragment +# + +## To change the defaults add any of the following settings below the comments +## +## EMBY_USER= #$EMBY_USER, username to run Emby under, the default is emby +## EMBY_GROUP= #$EMBY_GROUP, Emby server group where Emby user belongs +## EMBY_DIR= #$EMBY_DIR, the location of Emby program files the default is /usr/lib/emby-server +## EMBY_BIN= #$EMBY_BIN, full path of MediaBrowser.Server.Mono.exe the default is /usr/lib/emby-server/bin/MediaBrowser.Server.Mono.exe +## EMBY_DATA= #$EMBY_DATA, the location of Emby data, cache, logs, the default is /var/lib/emby-server +## EMBY_PIDFILE= #$EMBY_PIDFILE, the location of emby.pid, the default is /var/run/emby/emby-server.pid +## EMBY_ADD_OPTS= #$EMBY_ADD_OPTS, additional options to pass to the Emby server executable, beyond ffmpeg, ffprobe and restart +## MONO_BIN= #$MONO_BIN, full path of mono binary, the default is /usr/bin/mono-sgen +## MONO_OPTS= #$MONO_OPTS, list of additional options to pass to mono binary +## MONO_ENV= #$MONO_ENV, list of environment variables for running mono binary +## +## EXAMPLE if want to run as different user +## add EMBY_USER=username +## otherwise default emby is used diff --git a/debian/emby-server.emby-server.default b/debian/emby-server.emby-server.default new file mode 100644 index 0000000000..33f5ebb5b2 --- /dev/null +++ b/debian/emby-server.emby-server.default @@ -0,0 +1,37 @@ +# Defaults for emby initscript +# sourced by /etc/init.d/emby-server and /usr/lib/emby-server/emby-server.sh +# installed at /etc/default/emby-server by the maintainer scripts + +# +# This is a POSIX shell fragment +# + +## Don't edit this file +## Edit user configuration in /etc/emby-server.conf to change +## +## EMBY_USER= #$EMBY_USER, username to run Emby under, the default is emby +## EMBY_GROUP= #$EMBY_GROUP, Emby server group where Emby user belongs +## EMBY_DIR= #$EMBY_DIR, the location of Emby program files the default is /usr/lib/emby-server +## EMBY_BIN= #$EMBY_BIN, full path of MediaBrowser.Server.Mono.exe the default is /usr/lib/emby-server/bin/MediaBrowser.Server.Mono.exe +## EMBY_DATA= #$EMBY_DATA, the location of Emby data, cache, logs, the default is /var/lib/emby-server +## EMBY_PIDFILE= #$EMBY_PIDFILE, the location of emby.pid, the default is /var/run/emby/emby-server.pid +## EMBY_ADD_OPTS= #$EMBY_ADD_OPTS, additional options to pass to the Emby server executable, beyond ffmpeg, ffprobe and restart +## MONO_BIN= #$MONO_BIN, full path of mono binary, the default is /usr/bin/mono-sgen +## MONO_OPTS= #$MONO_OPTS, list of additional options to pass to mono binary +## MONO_ENV= #$MONO_ENV, list of environment variables for running mono binary +## +## EXAMPLE if want to run as different user +## add EMBY_USER=username to /etc/emby-server.conf +## otherwise default emby is used + +EMBY_USER="emby" +EMBY_GROUP="emby" +EMBY_DIR="/usr/lib/emby-server" +EMBY_BIN="/usr/lib/emby-server/bin/MediaBrowser.Server.Mono.exe" +EMBY_DATA="/var/lib/emby-server" +EMBY_PIDFILE="/var/run/emby-server.pid" +EMBY_ADD_OPTS="" +MONO_BIN="/usr/bin/mono-sgen" +MONO_OPTS="--optimize=all" +MONO_ENV="MONO_THREADS_PER_CPU=250 MONO_GC_PARAMS=nursery-size=128m" +UMASK="002" diff --git a/debian/emby-server.emby-server.init b/debian/emby-server.emby-server.init new file mode 100644 index 0000000000..81ce3376b5 --- /dev/null +++ b/debian/emby-server.emby-server.init @@ -0,0 +1,88 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: emby-server +# Required-Start: $remote_fs $local_fs $network +# Required-Stop: $remote_fs $local_fs $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: starts instance of Emby +# Description: starts instance of Emby +### END INIT INFO + + +# chkconfig: 2345 20 80 +#The above indicates that the script should be started in levels 2, 3, 4, and 5, #that its start priority should be 20, and that its stop priority should be 80. +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +NAME=emby-server +CONF_FILE=/etc/${NAME}.conf +DEFAULT_FILE=/etc/default/${NAME} + +# Source Emby server default configuration +. $DEFAULT_FILE + +# Source Emby server user configuration overrides +if [[ -f $CONF_FILE ]]; then + . $CONF_FILE +else + echo "${CONF_FILE} not found using default settings."; +fi + +# Path of emby binary +EMBYSERVER=/usr/bin/emby-server +PIDFILE=${EMBY_PIDFILE-/var/run/emby-server.pid} + +case "$1" in + start) + log_daemon_msg "Starting $NAME daemon" + if [[ -s $PIDFILE ]] && [[ -n "$(ps -p $(cat $PIDFILE) -o pid=)" ]]; then + log_daemon_msg "apparently already running" + log_end_msg 0 + exit 0 + fi + exec $EMBYSERVER start & + sleep 2 + if [[ -s $PIDFILE ]] && [[ -n "$(ps -p $(cat $PIDFILE) -o pid=)" ]]; then + log_end_msg 0 + else + log_end_msg 1 + fi + ;; + stop) + log_daemon_msg "Stopping $NAME daemon" + if [[ ! -s $PIDFILE ]] || [[ -z "$(ps -p $(cat $PIDFILE) -o pid=)" ]]; then + [[ -e $PIDFILE ]] && rm -rf $PIDFILE + log_success_msg "apparently already stopped" + log_end_msg 0 + exit 0 + fi + PID=$(cat $PIDFILE) + CPIDS=$(pgrep -P $PID) + sleep 2 && kill -KILL $CPIDS + kill -TERM $CPIDS > /dev/null 2>&1 + sleep 2 + if [[ -z "$(ps -p $PID -o pid=)" ]]; then + rm -rf $PIDFILE + log_end_msg 0 + else + log_end_msg 1 + fi + ;; + status) + status_of_proc -p $PIDFILE "$EMBYSERVER" "$NAME" + exit $? # notreached due to set -e + ;; + restart|force-reload) + $0 stop || exit $? + $0 start || exit $? + ;; + *) + echo "Usage: /etc/init.d/emby-server {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac diff --git a/debian/emby-server.emby-server.service b/debian/emby-server.emby-server.service new file mode 100644 index 0000000000..e5dbacb523 --- /dev/null +++ b/debian/emby-server.emby-server.service @@ -0,0 +1,12 @@ +[Unit] +Description=Emby Media Server +After=network.target + +[Service] +ExecStart=/usr/bin/emby-server start +Restart=on-abort +TimeoutSec=20 +ExecStopPost=/usr/bin/emby-server clear + +[Install] +WantedBy=multi-user.target diff --git a/debian/emby-server.emby-server.upstart b/debian/emby-server.emby-server.upstart new file mode 100644 index 0000000000..4f089260ce --- /dev/null +++ b/debian/emby-server.emby-server.upstart @@ -0,0 +1,23 @@ +description "emby-server daemon" + +start on (local-filesystems and net-device-up IFACE!=lo) +stop on runlevel [!2345] + +console log +respawn +respawn limit 10 5 + +kill timeout 20 + +script + set -x + echo "Starting $UPSTART_JOB" + + # Log file + logger -t "$0" "DEBUG: `set`" + exec /usr/bin/emby-server start +end script + +post-stop script + exec /usr/bin/emby-server clear +end script diff --git a/debian/gbp.conf b/debian/gbp.conf new file mode 100644 index 0000000000..f131b973c2 --- /dev/null +++ b/debian/gbp.conf @@ -0,0 +1,6 @@ +[DEFAULT] +pristine-tar = False +cleaner = fakeroot debian/rules clean + +[import-orig] +filter = [ ".git*", ".hg*" ] diff --git a/debian/install b/debian/install new file mode 100644 index 0000000000..7051a2fcd7 --- /dev/null +++ b/debian/install @@ -0,0 +1,5 @@ +usr/lib/emby-server usr/lib/ +debian/emby-server.conf etc/ +debian/emby etc/sudoers.d/ +debian/bin/emby-server usr/bin/ +debian/restart.sh usr/lib/emby-server diff --git a/debian/po/POTFILES.in b/debian/po/POTFILES.in new file mode 100644 index 0000000000..cef83a3407 --- /dev/null +++ b/debian/po/POTFILES.in @@ -0,0 +1 @@ +[type: gettext/rfc822deb] templates diff --git a/debian/po/templates.pot b/debian/po/templates.pot new file mode 100644 index 0000000000..03a98d3764 --- /dev/null +++ b/debian/po/templates.pot @@ -0,0 +1,57 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: emby-server\n" +"Report-Msgid-Bugs-To: emby-server@packages.debian.org\n" +"POT-Creation-Date: 2015-06-12 20:51-0600\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../templates:1001 +msgid "Emby permission info:" +msgstr "" + +#. Type: note +#. Description +#: ../templates:1001 +msgid "" +"Emby by default runs under a user named \"emby\". Please ensure that the " +"user emby has read and write access to any folders you wish to add to your " +"library. Otherwise please run emby under a different user." +msgstr "" + +#. Type: string +#. Description +#: ../templates:2001 +msgid "Username to run Emby as:" +msgstr "" + +#. Type: string +#. Description +#: ../templates:2001 +msgid "The user that emby will run as." +msgstr "" + +#. Type: note +#. Description +#: ../templates:3001 +msgid "Emby still running" +msgstr "" + +#. Type: note +#. Description +#: ../templates:3001 +msgid "Emby is currently running. Please close it and try again." +msgstr "" diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000000..f1469f1c1f --- /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 diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 0000000000..90823ec140 --- /dev/null +++ b/debian/postrm @@ -0,0 +1,64 @@ +#!/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} + +# In case this system is running systemd, we make systemd reload the unit files +# to pick up changes. +if [[ -d /run/systemd/system ]] ; then + systemctl --system daemon-reload >/dev/null || true +fi + +case "$1" in + purge) + echo PURGE | debconf-communicate $NAME > /dev/null 2>&1 || true + + if [[ -x "/etc/init.d/emby-server" ]] || [[ -e "/etc/init/emby-server.connf" ]]; then + update-rc.d emby-server remove >/dev/null 2>&1 || true + fi + + if [[ -x "/usr/bin/deb-systemd-helper" ]]; then + deb-systemd-helper purge emby-server.service >/dev/null + deb-systemd-helper unmask emby-server.service >/dev/null + fi + + userdel emby > /dev/null 2>&1 || true + delgroup --quiet emby > /dev/null 2>&1 || true + if [[ -d $PROGRAMDATA ]]; then + rm -rf $PROGRAMDATA + fi + [[ -f /usr/bin/emby-server ]] && rm /usr/bin/emby-server + [[ -f /etc/sudoers.d/emby ]] && rm /etc/sudoers.d/emby + [[ -d /var/lib/emby-server ]] && rm -rf /var/lib/emby-server + ;; + remove) + if [[ -x "/usr/bin/deb-systemd-helper" ]]; then + deb-systemd-helper mask emby-server.service >/dev/null + fi + ;; + upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 diff --git a/debian/preinst b/debian/preinst new file mode 100644 index 0000000000..6431277967 --- /dev/null +++ b/debian/preinst @@ -0,0 +1,66 @@ +#!/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} + +# In case this system is running systemd, we make systemd reload the unit files +# to pick up changes. +if [[ -d /run/systemd/system ]] ; then + systemctl --system daemon-reload >/dev/null || true +fi + +case "$1" in + install|upgrade) + # try graceful termination; + if [[ -d /run/systemd/system ]]; then + deb-systemd-invoke stop ${NAME}.service > /dev/null 2>&1 || true + elif [ -x "/etc/init.d/${NAME}" ] || [ -e "/etc/init/${NAME}.conf" ]; then + invoke-rc.d ${NAME} stop > /dev/null 2>&1 || true + fi + # try and figure out if emby is running + PIDFILE=$(find /var/run/ -maxdepth 1 -mindepth 1 -name "emby*.pid" -print -quit) + [[ -n "$PIDFILE" ]] && [[ -s "$PIDFILE" ]] && EMBY_PID=$(cat ${PIDFILE}) + # if its running, let's stop it + if [[ -n "$EMBY_PID" ]]; then + echo "Stopping Emby Server!" + # if emby is still running, kill it + if [[ -n "$(ps -p $EMBY_PID -o pid=)" ]]; then + CPIDS=$(pgrep -P $EMBY_PID) + sleep 2 && kill -KILL $CPIDS + kill -TERM $CPIDS > /dev/null 2>&1 + fi + sleep 1 + # if it's still running, show error + if [[ -n "$(ps -p $EMBY_PID -o pid=)" ]]; then + echo "Could not successfully stop EmbyServer, please do so before uninstalling." + exit 1 + else + [[ -f $PIDFILE ]] && rm $PIDFILE + fi + fi + ;; + abort-upgrade) + ;; + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac +#DEBHELPER# + +exit 0 diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 0000000000..341df6cd08 --- /dev/null +++ b/debian/prerm @@ -0,0 +1,64 @@ +#!/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 + remove|upgrade|deconfigure) + echo "Stopping Emby Server!" + # try graceful termination; + if [[ -d /run/systemd/system ]]; then + deb-systemd-invoke stop ${NAME}.service > /dev/null 2>&1 || true + elif [ -x "/etc/init.d/${NAME}" ] || [ -e "/etc/init/${NAME}.conf" ]; then + invoke-rc.d ${NAME} stop > /dev/null 2>&1 || true + fi + # Ensure that it is shutdown + PIDFILE=$(find /var/run/ -maxdepth 1 -mindepth 1 -name "emby*.pid" -print -quit) + [[ -n "$PIDFILE" ]] && [[ -s "$PIDFILE" ]] && EMBY_PID=$(cat ${PIDFILE}) + # if its running, let's stop it + if [[ -n "$EMBY_PID" ]]; then + # if emby is still running, kill it + if [[ -n "$(ps -p $EMBY_PID -o pid=)" ]]; then + CPIDS=$(pgrep -P $EMBY_PID) + sleep 2 && kill -KILL $CPIDS + kill -TERM $CPIDS > /dev/null 2>&1 + fi + sleep 1 + # if it's still running, show error + if [[ -n "$(ps -p $EMBY_PID -o pid=)" ]]; then + echo "Could not successfully stop EmbyServer, please do so before uninstalling." + exit 1 + else + [[ -f $PIDFILE ]] && rm $PIDFILE + fi + fi + if [[ -f /usr/lib/emby-server/bin/MediaBrowser.Server.Mono.exe.so ]]; then + rm /usr/lib/emby-server/bin/MediaBrowser.Server.Mono.exe.so + fi + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 diff --git a/debian/restart.sh b/debian/restart.sh new file mode 100644 index 0000000000..4d83624a02 --- /dev/null +++ b/debian/restart.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +NAME=emby-server + +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 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000000..11a2ba5ae5 --- /dev/null +++ b/debian/rules @@ -0,0 +1,38 @@ +#! /usr/bin/make -f +SHELL := /bin/bash +export DH_VERBOSE=1 + +%: + dh $@ --with=cli + +# disable "make check" +override_dh_auto_test: + +# disable stripping debugging symbols +override_dh_clistrip: + +override_dh_auto_build: + sed -i -e 's%%\n%' $(CURDIR)/MediaBrowser.Server.Mono/ImageMagickSharp.dll.config +ifneq ("$(wildcard $(CURDIR)/MediaBrowser.Server.Mono/SQLitePCLRaw.provider.sqlite3.dll.config)","") + sed -i -e 's%%%' $(CURDIR)/MediaBrowser.Server.Mono/SQLitePCLRaw.provider.sqlite3.dll.config + $(eval libdl_count := $(shell grep -c "libdl" $(CURDIR)/MediaBrowser.Server.Mono/SQLitePCLRaw.provider.sqlite3.dll.config)) + @ if [[ "$(libdl_count)" -eq "0" ]]; then \ + sed -i -e 's%\(\)%\n\1%' $(CURDIR)/MediaBrowser.Server.Mono/SQLitePCLRaw.provider.sqlite3.dll.config; \ + else \ + sed -i -e 's%%%' $(CURDIR)/MediaBrowser.Server.Mono/SQLitePCLRaw.provider.sqlite3.dll.config; \ + fi +endif + xbuild $(CURDIR)/MediaBrowser.sln /p:Configuration="Release Mono" /p:Platform="Any Cpu" /property:OutputPath='$(CURDIR)/usr/lib/emby-server/bin' /t:build + +override_dh_auto_clean: + xbuild $(CURDIR)/MediaBrowser.sln /p:Configuration="Release Mono" /p:Platform="Any Cpu" /t:clean + +# disable package does not produce library files +override_dh_makeclilibs: + +override_dh_clideps: + dh_clideps --exclude-moduleref=i:ole32 --exclude-moduleref=i:msvcrt --exclude-moduleref=i:Mono.Posix.dll --exclude-moduleref=i:MonoPosixHelper --exclude-moduleref=i:CORE_RL_Wand_ --exclude-moduleref=i:MediaInfo --exclude-moduleref=i:CORE_RL_magick_ --exclude-moduleref=i:sqlite3 --exclude-moduleref=i:libSkiaSharp --exclude-moduleref=i:SkiaSharp --exclude-moduleref=i:libEGL.dll + +override_dh_installinit: + # use "emby-server" as our service name, not "emby-server-beta" + dh_installinit --name=emby-server --no-start --noscripts diff --git a/debian/source.lintian-overrides b/debian/source.lintian-overrides new file mode 100644 index 0000000000..2f3412fe2f --- /dev/null +++ b/debian/source.lintian-overrides @@ -0,0 +1,3 @@ +# This is an override for the following lintian errors: +emby-server source: license-problem-md5sum-non-free-file Emby.Drawing/ImageMagick/fonts/webdings.ttf* +emby-server source: source-is-missing diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000000..d3827e75a5 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +1.0