From 06b6ebbe3cfe82b92d161c0ca0725a405b20558f Mon Sep 17 00:00:00 2001 From: m4tt075 Date: Tue, 14 Nov 2017 22:34:30 +0100 Subject: [PATCH] Update Tvheadend to 4.2.5 (maintenance release) and generic service support for DSM 5+6 --- cross/tvheadend/Makefile | 2 +- cross/tvheadend/digests | 6 +- .../patches/001-fix-version-number.patch | 2 +- spk/tvheadend/Makefile | 33 ++-- spk/tvheadend/src/conf/privilege | 31 ---- spk/tvheadend/src/{ => conf}/tvheadend.sc | 5 +- spk/tvheadend/src/dsm-control.sh | 89 ----------- spk/tvheadend/src/installer.sh | 145 ------------------ spk/tvheadend/src/service-setup.sh | 74 +++++++++ spk/tvheadend/src/wizard/install_uifile | 4 +- spk/tvheadend/src/wizard/install_uifile_enu | 4 +- spk/tvheadend/src/wizard/upgrade_uifile | 4 +- spk/tvheadend/src/wizard/upgrade_uifile_enu | 4 +- 13 files changed, 110 insertions(+), 293 deletions(-) delete mode 100644 spk/tvheadend/src/conf/privilege rename spk/tvheadend/src/{ => conf}/tvheadend.sc (68%) delete mode 100755 spk/tvheadend/src/dsm-control.sh delete mode 100755 spk/tvheadend/src/installer.sh create mode 100644 spk/tvheadend/src/service-setup.sh diff --git a/cross/tvheadend/Makefile b/cross/tvheadend/Makefile index 9d9ea7992904..dc3c31137505 100644 --- a/cross/tvheadend/Makefile +++ b/cross/tvheadend/Makefile @@ -1,5 +1,5 @@ PKG_NAME = tvheadend -PKG_VERS = 4.2.4 +PKG_VERS = 4.2.5 PKG_EXT = tar.gz PKG_DIST_NAME = v$(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://github.com/tvheadend/tvheadend/archive diff --git a/cross/tvheadend/digests b/cross/tvheadend/digests index eaca70830f05..bdbb7ac9ac2f 100644 --- a/cross/tvheadend/digests +++ b/cross/tvheadend/digests @@ -1,3 +1,3 @@ -tvheadend-4.2.4.tar.gz SHA1 1dc4442ef07a43232075ad886aca7f692c16e106 -tvheadend-4.2.4.tar.gz SHA256 231e487457a80adaaf097c4f2b84b981b86da40199ab186cf460061a97cd2269 -tvheadend-4.2.4.tar.gz MD5 7a0c6cc8ce84d9f8ddf47123b30ec167 +tvheadend-4.2.5.tar.gz SHA1 3799dcae34803a2f25e4ce730158028271d611f4 +tvheadend-4.2.5.tar.gz SHA256 36816c8b506af6b0f5df442bd96aa301223dc7c44d8b88eec53262e92956d740 +tvheadend-4.2.5.tar.gz MD5 d5f6065c1dcb1d3bc1a4cb757d2741c0 diff --git a/cross/tvheadend/patches/001-fix-version-number.patch b/cross/tvheadend/patches/001-fix-version-number.patch index bbd3d01dce93..8e9022e04f43 100644 --- a/cross/tvheadend/patches/001-fix-version-number.patch +++ b/cross/tvheadend/patches/001-fix-version-number.patch @@ -6,7 +6,7 @@ case $VER in [1-9]*\.[0-9]*) ;; - *) VER="0.0.0~unknown" ;; -+ *) VER="4.2.3" ;; ++ *) VER="4.2.5" ;; esac fi diff --git a/spk/tvheadend/Makefile b/spk/tvheadend/Makefile index 992ccbf302a8..284d849d96a3 100644 --- a/spk/tvheadend/Makefile +++ b/spk/tvheadend/Makefile @@ -1,6 +1,6 @@ SPK_NAME = tvheadend -SPK_VERS = 4.2.4 -SPK_REV = 11 +SPK_VERS = 4.2.5 +SPK_REV = 12 SPK_ICON = src/tvheadend.png DSM_UI_DIR = app BETA = 1 @@ -9,22 +9,24 @@ DEPENDS = cross/busybox cross/$(SPK_NAME) MAINTAINER = m4tt075 DESCRIPTION = Tvheadend is a TV streaming server and recorder for Linux, FreeBSD and Android supporting DVB-S, DVB-S2, DVB-C, DVB-T, ATSC, ISDB-T, IPTV, SAT IP and HDHomeRun as input sources. Tvheadend offers HTTP, HTSP and SAT IP streaming. -ADMIN_PORT = 9981 RELOAD_UI = yes DISPLAY_NAME = Tvheadend -CHANGELOG = "Update to Tvheadend 4.2.4 (Release), including update of libhdhomerun to 20170930" - +STARTABLE = yes +CHANGELOG = "1. Update TVH to 4.2.5 (maintenance release), 2. Use DSM 5+6 generic service" HOMEPAGE = https://www.lonelycoder.com/tvheadend/ -LICENSE = GPL v3 +LICENSE = GPL v3 -INSTALLER_SCRIPT = src/installer.sh -SSS_SCRIPT = src/dsm-control.sh -FWPORTS = src/${SPK_NAME}.sc -CONF_DIR = src/conf/ -WIZARDS_DIR = src/wizard/ +WIZARDS_DIR = src/wizard/ +CONF_DIR = src/conf/ -INSTALL_PREFIX = /usr/local/$(SPK_NAME) +# 'auto' reserved value grabs SPK_NAME +SERVICE_USER = auto +SERVICE_SETUP = src/service-setup.sh +# Admin link +ADMIN_PORT = 9981 + +PRE_COPY_TARGET = tvheadend_install POST_STRIP_TARGET = tvheadend_extra_install BUSYBOX_CONFIG = usrmng @@ -32,6 +34,13 @@ ENV += BUSYBOX_CONFIG="$(BUSYBOX_CONFIG)" include ../../mk/spksrc.spk.mk +.PHONY: tvheadend_install +# Replace standard copy/install targets +tvheadend_install: + rm -fr $(STAGING_DIR) + mkdir $(STAGING_DIR) + mkdir --parents $(STAGING_INSTALL_PREFIX) + .PHONY: tvheadend_extra_install tvheadend_extra_install: install -m 755 -d $(STAGING_DIR)/app diff --git a/spk/tvheadend/src/conf/privilege b/spk/tvheadend/src/conf/privilege deleted file mode 100644 index 7bbf54a39902..000000000000 --- a/spk/tvheadend/src/conf/privilege +++ /dev/null @@ -1,31 +0,0 @@ -{ - "defaults":{ - "run-as": "package" - }, - "username": "sc-tvheadend", - "ctrl-script": [{ - "action": "preinst", - "run-as": "root" - }, { - "action": "postinst", - "run-as": "root" - }, { - "action": "preuninst", - "run-as": "root" - }, { - "action": "postuninst", - "run-as": "root" - }, { - "action": "preupgrade", - "run-as": "root" - }, { - "action": "postupgrade", - "run-as": "root" - }, { - "action": "start", - "run-as": "root" - }, { - "action": "stop", - "run-as": "root" - }] -} \ No newline at end of file diff --git a/spk/tvheadend/src/tvheadend.sc b/spk/tvheadend/src/conf/tvheadend.sc similarity index 68% rename from spk/tvheadend/src/tvheadend.sc rename to spk/tvheadend/src/conf/tvheadend.sc index 4bbb4c529d22..7960a7bb7a0e 100644 --- a/spk/tvheadend/src/tvheadend.sc +++ b/spk/tvheadend/src/conf/tvheadend.sc @@ -1,6 +1,5 @@ [tvheadend] title="Tvheadend" -desc="Tvheadend" +desc="Tvheadend (http, htsp)" port_forward="yes" -dst.ports="9981,9982/tcp" - +dst.ports="9981,9982/tcp" diff --git a/spk/tvheadend/src/dsm-control.sh b/spk/tvheadend/src/dsm-control.sh deleted file mode 100755 index 0a0111d3d58b..000000000000 --- a/spk/tvheadend/src/dsm-control.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh - -# Package -PACKAGE="tvheadend" -DNAME="Tvheadend" - -# Others -INSTALL_DIR="/usr/local/${PACKAGE}" -PATH="${INSTALL_DIR}/bin:/usr/local/bin:/bin:/usr/bin:/usr/syno/bin" -BUILDNUMBER="$(/bin/get_key_value /etc.defaults/VERSION buildnumber)" -TVHEADEND="${INSTALL_DIR}/bin/tvheadend" -PID_FILE="${INSTALL_DIR}/var/tvheadend.pid" - -SC_USER="sc-tvheadend" -LEGACY_USER="tvheadend" -USER="$([ "${BUILDNUMBER}" -ge "7321" ] && echo -n ${SC_USER} || echo -n ${LEGACY_USER})" - - -start_daemon () -{ - ${TVHEADEND} -f -u ${USER} -c ${INSTALL_DIR}/var -p ${PID_FILE} -} - -stop_daemon () -{ - kill `cat ${PID_FILE}` - wait_for_status 1 20 - rm -f ${PID_FILE} -} - -daemon_status () -{ - if [ -f ${PID_FILE} ] && [ -d /proc/`cat ${PID_FILE}` ]; then - return - fi - return 1 -} - -wait_for_status () -{ - counter=$2 - while [ ${counter} -gt 0 ]; do - daemon_status - [ $? -eq $1 ] && break - let counter=counter-1 - sleep 1 - done -} - - -case $1 in - start) - if daemon_status; then - echo ${DNAME} is already running - exit 0 - else - echo Starting ${DNAME} ... - start_daemon - exit $? - fi - ;; - stop) - if daemon_status; then - echo Stopping ${DNAME} ... - stop_daemon - exit $? - else - echo ${DNAME} is not running - exit 0 - fi - ;; - restart) - stop_daemon - start_daemon - exit $? - ;; - status) - if daemon_status; then - echo ${DNAME} is running - exit 0 - else - echo ${DNAME} is not running - exit 1 - fi - ;; - *) - exit 1 - ;; -esac diff --git a/spk/tvheadend/src/installer.sh b/spk/tvheadend/src/installer.sh deleted file mode 100755 index e5c8281beb68..000000000000 --- a/spk/tvheadend/src/installer.sh +++ /dev/null @@ -1,145 +0,0 @@ -#!/bin/sh - -# Package -PACKAGE="tvheadend" -DNAME="Tvheadend" - -# Others -INSTALL_DIR="/usr/local/${PACKAGE}" -SSS="/var/packages/${PACKAGE}/scripts/start-stop-status" -PATH="${INSTALL_DIR}/bin:${PATH}" -TMP_DIR="${SYNOPKG_PKGDEST}/../../@tmp" -SERVICETOOL="/usr/syno/bin/servicetool" -BUILDNUMBER="$(/bin/get_key_value /etc.defaults/VERSION buildnumber)" -FWPORTS="/var/packages/${PACKAGE}/scripts/${PACKAGE}.sc" - -DSM6_UPGRADE="${INSTALL_DIR}/var/.dsm6_upgrade" -SC_USER="sc-tvheadend" -SC_GROUP="sc-media" -SC_GROUP_DESC="SynoCommunity's media related group" -LEGACY_USER="tvheadend" -LEGACY_GROUP="users" -USER="$([ "${BUILDNUMBER}" -ge "7321" ] && echo -n ${SC_USER} || echo -n ${LEGACY_USER})" - -syno_group_create () -{ - # Create syno group - synogroup --add ${SC_GROUP} ${USER} > /dev/null - # Set description of the syno group - synogroup --descset ${SC_GROUP} "${SC_GROUP_DESC}" - # Add user to syno group - addgroup ${USER} ${SC_GROUP} -} - -syno_group_remove () -{ - # Remove user from syno group - delgroup ${USER} ${SC_GROUP} - # Check if syno group is empty - if ! synogroup --get ${SC_GROUP} | grep -q "0:"; then - # Remove syno group - synogroup --del ${SC_GROUP} > /dev/null - fi -} - -preinst () -{ - exit 0 -} - -postinst () -{ - # Link - ln -s ${SYNOPKG_PKGDEST} ${INSTALL_DIR} - - # Install busybox stuff - ${INSTALL_DIR}/bin/busybox --install ${INSTALL_DIR}/bin - - # Create legacy user - if [ "${BUILDNUMBER}" -lt "7321" ]; then - adduser -h ${INSTALL_DIR}/var -g "${DNAME} User" -G ${LEGACY_GROUP} -s /bin/sh -S -D ${LEGACY_USER} - fi - - syno_group_create - - wizard_password=`echo -n "TVHeadend-Hide-${wizard_password:=admin}" | openssl enc -a` - - # Edit the configuration according to the wizard - sed -i -e "s/@username@/${wizard_username:=admin}/g" ${INSTALL_DIR}/var/accesscontrol/d80ccc09630261ffdcae1497a690acc8 - - sed -i -e "s/@username@/${wizard_username:=admin}/g" ${INSTALL_DIR}/var/passwd/a927e30a755504f9784f23a4efac5109 - sed -i -e "s/@password@/${wizard_password}/g" ${INSTALL_DIR}/var/passwd/a927e30a755504f9784f23a4efac5109 - - # Correct the files ownership - chown -R ${USER}:root ${SYNOPKG_PKGDEST} - - chown -R ${USER}:root ${SYNOPKG_PKGDEST}/var/accesscontrol/* - chmod 700 ${SYNOPKG_PKGDEST}/var/accesscontrol/* - - chown -R ${USER}:root ${SYNOPKG_PKGDEST}/var/passwd/* - chmod 700 ${SYNOPKG_PKGDEST}/var/passwd/* - - # Add firewall config - ${SERVICETOOL} --install-configure-file --package ${FWPORTS} >> /dev/null - - exit 0 -} - -preuninst () -{ - # Stop the package - ${SSS} stop > /dev/null - - if [ "${SYNOPKG_PKG_STATUS}" != "UPGRADE" ]; then - # Remove the user (if not upgrading) - syno_group_remove - delgroup ${LEGACY_USER} ${LEGACY_GROUP} - deluser ${USER} - - # Remove firewall configuration - ${SERVICETOOL} --remove-configure-file --package ${PACKAGE}.sc >> /dev/null - fi - - exit 0 -} - -postuninst () -{ - # Remove link - rm -f ${INSTALL_DIR} - - exit 0 -} - -preupgrade () -{ - # Stop the package - ${SSS} stop > /dev/null - - # DSM6 Upgrade handling - if [ "${BUILDNUMBER}" -ge "7321" ] && [ ! -f ${DSM6_UPGRADE} ]; then - echo "Deleting legacy user" > ${DSM6_UPGRADE} - delgroup ${LEGACY_USER} ${LEGACY_GROUP} - deluser ${LEGACY_USER} - fi - - # Save some stuff - rm -fr ${TMP_DIR}/${PACKAGE} - mkdir -p ${TMP_DIR}/${PACKAGE} - mv ${INSTALL_DIR}/var ${TMP_DIR}/${PACKAGE}/ - - exit 0 -} - -postupgrade () -{ - # Restore some stuff - rm -fr ${INSTALL_DIR}/var - mv ${TMP_DIR}/${PACKAGE}/var ${INSTALL_DIR}/ - rm -fr ${TMP_DIR}/${PACKAGE} - - # Ensure file ownership is correct after upgrade - chown -R ${USER}:root ${SYNOPKG_PKGDEST} - - exit 0 -} diff --git a/spk/tvheadend/src/service-setup.sh b/spk/tvheadend/src/service-setup.sh new file mode 100644 index 000000000000..3b4f8ecd50b5 --- /dev/null +++ b/spk/tvheadend/src/service-setup.sh @@ -0,0 +1,74 @@ + +# Package specific behaviors +# Sourced script by generic installer and start-stop-status scripts + +service_prestart () +{ + # Replace generic service startup, run service as daemon + + # Service configuration. Change http and htsp ports here and in conf/tvheadend.sc for non-standard ports + HTTPP=9981 + HTSPP=9982 + + GRPN=`id -gn ${EFF_USER}` + HOME_DIR="${SYNOPKG_PKGDEST}/var" + + echo "Starting Tvheadend as daemon under user ${EFF_USER} in group ${GRPN} with configuration directory ${HOME_DIR} on http port ${HTTPP} and htsp port ${HTSPP}" >> ${LOG_FILE} + COMMAND="${SYNOPKG_PKGDEST}/bin/tvheadend -f -u ${EFF_USER} -g ${GRPN} --http_port ${HTTPP} --htsp_port ${HTSPP} -c ${HOME_DIR} -l ${LOG_FILE} -p ${PID_FILE}" + + if [ $SYNOPKG_DSM_VERSION_MAJOR -lt 6 ]; then + su ${EFF_USER} -s /bin/sh -c "cd ${SYNOPKG_PKGDEST}; ${COMMAND}" >> ${LOG_FILE} 2>&1 & + else + cd ${SYNOPKG_PKGDEST} + ${COMMAND} >> ${LOG_FILE} 2>&1 & + fi +} + +service_preinst () +{ + echo "service_preinst ${SYNOPKG_PKG_STATUS}" >> $INST_LOG +} + +service_postinst () +{ + # Encrypt password + wizard_password=`echo -n "TVHeadend-Hide-${wizard_password:=admin}" | openssl enc -a` + + # Edit the configuration according to the wizard + sed -i -e "s/@username@/${wizard_username:=admin}/g" ${SYNOPKG_PKGDEST}/var/accesscontrol/d80ccc09630261ffdcae1497a690acc8 + sed -i -e "s/@username@/${wizard_username:=admin}/g" ${SYNOPKG_PKGDEST}/var/passwd/a927e30a755504f9784f23a4efac5109 + sed -i -e "s/@password@/${wizard_password}/g" ${SYNOPKG_PKGDEST}/var/passwd/a927e30a755504f9784f23a4efac5109 + + # Discard legacy obsolete busybox user account + BIN=${SYNOPKG_PKGDEST}/bin + $BIN/busybox --install $BIN + $BIN/delgroup "${USER}" "users" >> ${INST_LOG} + $BIN/deluser "${USER}" >> ${INST_LOG} + + echo "service_postinst ${SYNOPKG_PKG_STATUS}" >> $INST_LOG +} + +service_preuninst () +{ + echo "service_preuninst ${SYNOPKG_PKG_STATUS}" >> $INST_LOG +} + +service_postuninst () +{ + echo "service_postuninst ${SYNOPKG_PKG_STATUS}" >> $INST_LOG +} + +service_preupgrade () +{ + echo "service_preupgrade ${SYNOPKG_PKG_STATUS}" >> $INST_LOG +} + +service_postupgrade () +{ + echo "service_postupgrade ${SYNOPKG_PKG_STATUS}" >> $INST_LOG +} + +service_poststop () +{ + echo "After stop" >> $LOG_FILE +} diff --git a/spk/tvheadend/src/wizard/install_uifile b/spk/tvheadend/src/wizard/install_uifile index 8f4dbd7e7114..26d9b909b0c9 100644 --- a/spk/tvheadend/src/wizard/install_uifile +++ b/spk/tvheadend/src/wizard/install_uifile @@ -16,8 +16,8 @@ }] }] }, { - "step_title": "Attention! DSM6 Premissions", + "step_title": "Attention! DSM Permissions", "items": [{ - "desc": "Permissions are managed with the group 'sc-media' in DSM." + "desc": "Permissions are managed with the group 'tvheadend' in DSM.
The group 'users' is no longer used as of DSM 6.
Package user (= svc-tvheadend on DSM5 and sc-tvheadend on DSM6+) will not appear on most UI settings.
Including the following:
- Application privilege's permission viewer
- FTP's chroot user selector
- File Stations's
- Change owner
- Shared Links Manager -> Enable secure sharing

The only exceptions are:
- Control Panel > Shared Folder > Edit > Permission > System internal user
- ACL editor
" }] }] diff --git a/spk/tvheadend/src/wizard/install_uifile_enu b/spk/tvheadend/src/wizard/install_uifile_enu index 8f4dbd7e7114..26d9b909b0c9 100644 --- a/spk/tvheadend/src/wizard/install_uifile_enu +++ b/spk/tvheadend/src/wizard/install_uifile_enu @@ -16,8 +16,8 @@ }] }] }, { - "step_title": "Attention! DSM6 Premissions", + "step_title": "Attention! DSM Permissions", "items": [{ - "desc": "Permissions are managed with the group 'sc-media' in DSM." + "desc": "Permissions are managed with the group 'tvheadend' in DSM.
The group 'users' is no longer used as of DSM 6.
Package user (= svc-tvheadend on DSM5 and sc-tvheadend on DSM6+) will not appear on most UI settings.
Including the following:
- Application privilege's permission viewer
- FTP's chroot user selector
- File Stations's
- Change owner
- Shared Links Manager -> Enable secure sharing

The only exceptions are:
- Control Panel > Shared Folder > Edit > Permission > System internal user
- ACL editor
" }] }] diff --git a/spk/tvheadend/src/wizard/upgrade_uifile b/spk/tvheadend/src/wizard/upgrade_uifile index a671a1a1c126..df36085e8caf 100644 --- a/spk/tvheadend/src/wizard/upgrade_uifile +++ b/spk/tvheadend/src/wizard/upgrade_uifile @@ -1,6 +1,6 @@ [{ - "step_title": "Attention! DSM6 Premissions", + "step_title": "Attention! DSM Permissions", "items": [{ - "desc": "Permissions are managed with the group 'sc-media' in DSM." + "desc": "Permissions are managed with the group 'tvheadend' in DSM.
The group 'users' is no longer used as of DSM 6.
Package user (= svc-tvheadend on DSM5 and sc-tvheadend on DSM6+) will not appear on most UI settings.
Including the following:
- Application privilege's permission viewer
- FTP's chroot user selector
- File Stations's
- Change owner
- Shared Links Manager -> Enable secure sharing

The only exceptions are:
- Control Panel > Shared Folder > Edit > Permission > System internal user
- ACL editor
" }] }] diff --git a/spk/tvheadend/src/wizard/upgrade_uifile_enu b/spk/tvheadend/src/wizard/upgrade_uifile_enu index a671a1a1c126..df36085e8caf 100644 --- a/spk/tvheadend/src/wizard/upgrade_uifile_enu +++ b/spk/tvheadend/src/wizard/upgrade_uifile_enu @@ -1,6 +1,6 @@ [{ - "step_title": "Attention! DSM6 Premissions", + "step_title": "Attention! DSM Permissions", "items": [{ - "desc": "Permissions are managed with the group 'sc-media' in DSM." + "desc": "Permissions are managed with the group 'tvheadend' in DSM.
The group 'users' is no longer used as of DSM 6.
Package user (= svc-tvheadend on DSM5 and sc-tvheadend on DSM6+) will not appear on most UI settings.
Including the following:
- Application privilege's permission viewer
- FTP's chroot user selector
- File Stations's
- Change owner
- Shared Links Manager -> Enable secure sharing

The only exceptions are:
- Control Panel > Shared Folder > Edit > Permission > System internal user
- ACL editor
" }] }]