Skip to content

Commit

Permalink
CouchPotato-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 34cefff commit 072cdeb
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 364 deletions.
21 changes: 10 additions & 11 deletions spk/couchpotatoserver-custom/Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
SPK_NAME = couchpotatoserver-custom
SPK_VERS = $(shell date +%Y%m%d)
SPK_REV = 4
SPK_REV = 5
SPK_ICON = src/couchpotatoserver-custom.png
DSM_UI_DIR = app

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

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

HOMEPAGE = http://couchpota.to/
LICENSE = GPL
STARTABLE = yes

INSTALLER_SCRIPT = src/installer.sh
SSS_SCRIPT = src/dsm-control.sh
FWPORTS = src/${SPK_NAME}.sc
CONF_DIR = src/conf/
WIZARDS_DIR = src/wizard/

INSTALL_PREFIX = /usr/local/$(SPK_NAME)
SERVICE_USER = auto
SERVICE_SETUP = src/service-setup.sh
SERVICE_PORT = 5053
SERVICE_PORT_TITLE = $(DISPLAY_NAME)

# Admin link for in DSM UI
ADMIN_PORT = $(SERVICE_PORT)

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

This file was deleted.

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

This file was deleted.

6 changes: 0 additions & 6 deletions spk/couchpotatoserver-custom/src/couchpotatoserver-custom.sc

This file was deleted.

90 changes: 0 additions & 90 deletions spk/couchpotatoserver-custom/src/dsm-control.sh

This file was deleted.

146 changes: 0 additions & 146 deletions spk/couchpotatoserver-custom/src/installer.sh

This file was deleted.

41 changes: 41 additions & 0 deletions spk/couchpotatoserver-custom/src/service-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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}"
PYTHON="${SYNOPKG_PKGDEST}/env/bin/python"
VIRTUALENV="${PYTHON_DIR}/bin/virtualenv"
GIT="${GIT_DIR}/bin/git"
COUCHPOTATOSERVER="${SYNOPKG_PKGDEST}/var/CouchPotatoServer/CouchPotato.py"
CFG_FILE="${SYNOPKG_PKGDEST}/var/settings.conf"

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

SERVICE_COMMAND="${PYTHON} ${COUCHPOTATOSERVER} --daemon --pid_file ${PID_FILE} --config_file ${CFG_FILE}"

service_preinst ()
{
# Check fork
if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ] && ! ${GIT} ls-remote --heads --exit-code ${wizard_fork_url:=git://github.com/CouchPotato/CouchPotatoServer.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} 2>&1

if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then
# Clone the repository
${GIT} clone -q -b ${wizard_fork_branch:=master} ${wizard_fork_url:=git://github.com/CouchPotato/CouchPotatoServer.git} ${SYNOPKG_PKGDEST}/var/CouchPotatoServer >> ${INST_LOG} 2>&1
fi

# If nessecary, add user also to the old group
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 072cdeb

Please sign in to comment.