Skip to content

Commit

Permalink
SickBeard-custom - Generic Service approach
Browse files Browse the repository at this point in the history
  • Loading branch information
Safihre committed Feb 23, 2018
1 parent 9849b30 commit a8859cd
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 363 deletions.
24 changes: 11 additions & 13 deletions spk/sickbeard-custom/Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
SPK_NAME = sickbeard-custom
SPK_VERS = $(shell date +%Y%m%d)
SPK_REV = 4
SPK_REV = 5
SPK_ICON = src/sickbeard-custom.png
DSM_UI_DIR = app

DEPENDS =
SPK_DEPENDS = "python>2.7.3-3:git"

MAINTAINER = Diaoul
DESCRIPTION = SickBeard Custom allows you to run the fork of your choice of SickBeard. You will be asked for the fork\'s git URL during install.
DESCRIPTION_FRE = SickBeard Custom vous permet d\\\'exécuter le fork de votre choix de SickBeard. Vous aurez besoin de saisir l\\\'URL git du fork durant l\\\'installation.
ADMIN_PORT = 8083
RELOAD_UI = yes
STARTABLE = yes
DISPLAY_NAME = SickBeard Custom
CHANGELOG = "Maintenance release"
CHANGELOG = "Integrate with DSM5+6 Generic Service support for correct permissions."

HOMEPAGE = http://sickbeard.com
LICENSE = GPL

INSTALLER_SCRIPT = src/installer.sh
SSS_SCRIPT = src/dsm-control.sh
FWPORTS = src/${SPK_NAME}.sc
CONF_DIR = src/conf/
WIZARDS_DIR = src/wizard/
SERVICE_USER = auto
SERVICE_SETUP = src/service-setup.sh
SERVICE_PORT = 8083
SERVICE_PORT_TITLE = $(DISPLAY_NAME)

INSTALL_PREFIX = /usr/local/$(SPK_NAME)
# Admin link for in DSM UI
ADMIN_PORT = $(SERVICE_PORT)

WIZARDS_DIR = src/wizard/

COPY_TARGET = nop
POST_STRIP_TARGET = sickbeard-custom_extra_install
Expand All @@ -38,5 +38,3 @@ include ../../mk/spksrc.spk.mk
sickbeard-custom_extra_install:
install -m 755 -d $(STAGING_DIR)/var
install -m 600 src/config.ini $(STAGING_DIR)/var/config.ini
install -m 755 -d $(STAGING_DIR)/app
install -m 644 src/app/config $(STAGING_DIR)/app/config
15 changes: 0 additions & 15 deletions spk/sickbeard-custom/src/app/config

This file was deleted.

31 changes: 0 additions & 31 deletions spk/sickbeard-custom/src/conf/privilege

This file was deleted.

91 changes: 0 additions & 91 deletions spk/sickbeard-custom/src/dsm-control.sh

This file was deleted.

149 changes: 0 additions & 149 deletions spk/sickbeard-custom/src/installer.sh

This file was deleted.

43 changes: 43 additions & 0 deletions spk/sickbeard-custom/src/service-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
PYTHON_DIR="/usr/local/python"
GIT_DIR="/usr/local/git"
PATH="${SYNOPKG_PKGDEST}/bin:${SYNOPKG_PKGDEST}/env/bin:${PYTHON_DIR}/bin:${GIT_DIR}/bin:${PATH}"
HOME="${SYNOPKG_PKGDEST}/var"
VIRTUALENV="${PYTHON_DIR}/bin/virtualenv"
GIT="${GIT_DIR}/bin/git"
PYTHON="${SYNOPKG_PKGDEST}/env/bin/python"
SICKBEARD="${SYNOPKG_PKGDEST}/var/SickBeard/SickBeard.py"
CFG_FILE="${SYNOPKG_PKGDEST}/var/config.ini"

GROUP="sc-download"
LEGACY_GROUP="sc-media"

SERVICE_COMMAND="${PYTHON} ${SICKBEARD} --daemon --pidfile ${PID_FILE} --config ${CFG_FILE} --datadir ${SYNOPKG_PKGDEST}/var/"

service_preinst ()
{
# Check fork
if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ] && ! ${GIT} ls-remote --heads --exit-code ${wizard_fork_url:=git://github.com/midgetspy/Sick-Beard.git} ${wizard_fork_branch:=master} > /dev/null 2>&1; then
echo "Incorrect fork"
exit 1
fi
}

service_postinst ()
{
# Create a Python virtualenv
${VIRTUALENV} --system-site-packages ${SYNOPKG_PKGDEST}/env >> ${INST_LOG}

if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then
# Clone the repository
${GIT} clone --depth 10 --recursive -q -b ${wizard_fork_branch:=master} ${wizard_fork_url:=git://github.com/midgetspy/Sick-Beard.git} ${SYNOPKG_PKGDEST}/var/SickBeard > /dev/null 2>&1
cp ${SYNOPKG_PKGDEST}/var/SickBeard/autoProcessTV/autoProcessTV.cfg.sample ${SYNOPKG_PKGDEST}/var/SickBeard/autoProcessTV/autoProcessTV.cfg
fi

# If nessecary, add user also to the old group before removing it
syno_user_add_to_legacy_group "${EFF_USER}" "${USER}" "${LEGACY_GROUP}"

# Remove legacy user
# Commands of busybox from spk/python
delgroup "${USER}" "users" >> ${INST_LOG}
deluser "${USER}" >> ${INST_LOG}
}
Loading

0 comments on commit a8859cd

Please sign in to comment.