From 073e8d6347bdf872c6650d9287272bbc1bc2bd59 Mon Sep 17 00:00:00 2001 From: Smaarn Date: Mon, 26 Oct 2020 23:13:11 +0100 Subject: [PATCH 01/19] cross/sox: initial integration (14.4.2) --- cross/sox/Makefile | 18 ++++++++++++++++++ cross/sox/PLIST | 10 ++++++++++ cross/sox/digests | 3 +++ 3 files changed, 31 insertions(+) create mode 100644 cross/sox/Makefile create mode 100644 cross/sox/PLIST create mode 100644 cross/sox/digests diff --git a/cross/sox/Makefile b/cross/sox/Makefile new file mode 100644 index 00000000000..999b321b458 --- /dev/null +++ b/cross/sox/Makefile @@ -0,0 +1,18 @@ +PKG_NAME = sox +PKG_VERS = 14.4.2 +PKG_EXT = tar.gz +PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) +PKG_DIST_SITE = https://sourceforge.net/projects/$(PKG_NAME)/files/sox/$(PKG_VERS)/ +PKG_DIR = $(PKG_NAME)-$(PKG_VERS) + +DEPENDS = cross/flac +DEPENDS += cross/lame +DEPENDS += cross/opencore-amr + +HOMEPAGE = https://sourceforge.net/projects/sox/ +COMMENT = SoX is the Swiss Army Knife of sound processing utilities. It can convert audio files to other popular audio file types and also apply sound effects and filters during the conversion. +LICENSE = GPL & LGPL v2 + +GNU_CONFIGURE = 1 + +include ../../mk/spksrc.cross-cc.mk diff --git a/cross/sox/PLIST b/cross/sox/PLIST new file mode 100644 index 00000000000..d4b55dd2e71 --- /dev/null +++ b/cross/sox/PLIST @@ -0,0 +1,10 @@ +bin:bin/play +bin:bin/rec +bin:bin/sox +bin:bin/soxi +lib:lib/libsox.a +lib:lib/libsox.la +lnk:lib/libsox.so +lnk:lib/libsox.so.3 +lib:lib/libsox.so.3.0.0 +rsc:lib/pkgconfig/sox.pc \ No newline at end of file diff --git a/cross/sox/digests b/cross/sox/digests new file mode 100644 index 00000000000..da57a054875 --- /dev/null +++ b/cross/sox/digests @@ -0,0 +1,3 @@ +sox-14.4.2.tar.gz SHA1 f69f38f8a7ad6a88ecab3862d74db4edcd796695 +sox-14.4.2.tar.gz SHA256 b45f598643ffbd8e363ff24d61166ccec4836fea6d3888881b8df53e3bb55f6c +sox-14.4.2.tar.gz MD5 d04fba2d9245e661f245de0577f48a33 From 2c54d1b74181029c0fda35ba71c50af80c1f0440 Mon Sep 17 00:00:00 2001 From: Smaarn Date: Sat, 24 Oct 2020 11:55:29 +0200 Subject: [PATCH 02/19] spk/rutorrent: fix startup issues Refactored to use standard service-setup mechanism rtorrent upgrade followup: fixed invalid configuration clause for certificate path added: missing pgrep commandline tool (used by _tasks plugin) Added: php workers configuration (for webstation integration) fixed: automatic detection of binaries was broken because of rights on php/test.sh script Added: if python 3 installation is present also install cloudscraper wheel (required for _cloudflare plugin) Fixed: former configuration file was always lost upon upgrade Fixed: .htaccess file defined at root level wasn't backed up Fixed: permissions were lost on the tmp directory (which needed to be accessible to both web and rutorrent user) Added: sox integration Added explicit id, gzip, curl and php paths Fixed: grant full rights on all plugins folder contents Fixed: grant read and execute rights to sc-rutorrent on web installation directory Fixed: temp directory path should always end with a slash --- .../001-expanding-external-programs.patch | 17 + spk/rutorrent/Makefile | 20 +- spk/rutorrent/src/.rtorrent.rc | 2 +- spk/rutorrent/src/conf/resource | 8 + spk/rutorrent/src/dsm-control.sh | 8 +- .../conf.d/com.synocommunity.rutorrent.ini | 3 + spk/rutorrent/src/installer.sh | 230 ------------- spk/rutorrent/src/service-setup.sh | 310 ++++++++++++++++++ 8 files changed, 362 insertions(+), 236 deletions(-) create mode 100644 cross/rutorrent/patches/001-expanding-external-programs.patch create mode 100644 spk/rutorrent/src/conf/resource create mode 100644 spk/rutorrent/src/etc/php/conf.d/com.synocommunity.rutorrent.ini delete mode 100755 spk/rutorrent/src/installer.sh create mode 100644 spk/rutorrent/src/service-setup.sh diff --git a/cross/rutorrent/patches/001-expanding-external-programs.patch b/cross/rutorrent/patches/001-expanding-external-programs.patch new file mode 100644 index 00000000000..901d3cdaf2c --- /dev/null +++ b/cross/rutorrent/patches/001-expanding-external-programs.patch @@ -0,0 +1,17 @@ +Added entries corresponding to external programs which are also potentially used by plugins and +may therefore be configured +index b68c526c..604f6263 100644 +--- conf/config.php.orig ++++ conf/config.php +@@ -52,6 +52,10 @@ + "gzip" => '', // Something like /usr/bin/gzip. If empty, will be found in PATH. + "id" => '', // Something like /usr/bin/id. If empty, will be found in PATH. + "stat" => '', // Something like /usr/bin/stat. If empty, will be found in PATH. ++ "python"=> '', // Something like /usr/bin/python3. If empty, will be found in PATH ++ "pgrep" => '', // Something like /usr/bin/pgrep. If empty, will be found in PATH ++ "sox" => '', // Something like /usr/bin/sox. If empty, will be found in PATH ++ "mediainfo" => '', // Something like /usr/bin/mediainfo. If empty, will be found in PATH + ); + + $localhosts = array( // list of local interfaces +root@b1d8647331b2:/spksrc/spk/rutorrent/work-evansport-6.1/ruTorrent-3.10# diff --git a/spk/rutorrent/Makefile b/spk/rutorrent/Makefile index 6cf84a45c89..8e4dee7e60d 100644 --- a/spk/rutorrent/Makefile +++ b/spk/rutorrent/Makefile @@ -7,6 +7,7 @@ DSM_UI_DIR = app UNSUPPORTED_ARCHS = $(ARM5_ARCHES) $(PPC_ARCHES) DEPENDS = cross/busybox cross/curl cross/procps-ng cross/mediainfo cross/rtorrent cross/rutorrent cross/screen cross/unzip +DEPENDS += cross/sox MAINTAINER = moneytoo DESCRIPTION = ruTorrent is a front-end for the popular Bittorrent client rTorrent. rTorrent is a BitTorrent client for ncurses, using the libtorrent library. The client and library is written in C++ with emphasis on speed and efficiency, while delivering equivalent features to those found in GUI based clients in an ncurses client. @@ -14,13 +15,24 @@ ADMIN_URL = /rutorrent/ RELOAD_UI = yes STARTABLE = yes DISPLAY_NAME = ruTorrent -CHANGELOG ="1. Update rutorrent to 3.10
2. Update to rtorrent 0.9.8
3. Update to libtorrent 0.13.8
4. Update to xmlrpc-c 1.51.06
5. Update openssl to 1.1" +CHANGELOG = "1. Update rutorrent to 3.10
+CHANGELOG += 2. Update to rtorrent 0.9.8
+CHANGELOG += 3. Update to libtorrent 0.13.8
+CHANGELOG += 4. Update to xmlrpc-c 1.51.06
+CHANGELOG += 5. Update openssl to 1.1
+CHANGELOG += 6. Embed missing binary requirements
" BETA = 1 HOMEPAGE = https://github.com/Novik/ruTorrent LICENSE = GPLv3 -INSTALLER_SCRIPT = src/installer.sh +SERVICE_USER = auto + +SPK_USER = rutorrent + +SERVICE_SETUP = src/service-setup.sh +SERVICE_WIZARD_SHARE=wizard_download_dir + SSS_SCRIPT = src/dsm-control.sh FWPORTS = src/${SPK_NAME}.sc CONF_DIR = src/conf/ @@ -34,7 +46,7 @@ INSTALL_PREFIX = /usr/local/$(SPK_NAME) POST_STRIP_TARGET = rutorrent_extra_install -BUSYBOX_CONFIG = usrmng daemon nice +BUSYBOX_CONFIG = usrmng daemon nice procutils ENV += BUSYBOX_CONFIG="$(BUSYBOX_CONFIG)" include ../../mk/spksrc.spk.mk @@ -47,3 +59,5 @@ rutorrent_extra_install: install -m 775 -d $(STAGING_DIR)/tmp install -m 755 -d $(STAGING_DIR)/app install -m 644 src/app/config $(STAGING_DIR)/app/config + install -m 755 -d $(STAGING_DIR)/etc/php/conf.d/ + install -m 644 src/etc/php/conf.d/com.synocommunity.rutorrent.ini $(STAGING_DIR)/etc/php/conf.d/com.synocommunity.rutorrent.ini diff --git a/spk/rutorrent/src/.rtorrent.rc b/spk/rutorrent/src/.rtorrent.rc index aea46e67e44..a206895a076 100755 --- a/spk/rutorrent/src/.rtorrent.rc +++ b/spk/rutorrent/src/.rtorrent.rc @@ -5,6 +5,6 @@ schedule = watch_directory,5,5,load_start=@watch_dir@/*.torrent max_memory_usage = @max_memory@ log.open_file = "rtorrent.log", "/usr/local/rutorrent/var/rtorrent.log" log.add_output = "warn", "rtorrent.log" -http_cacert = /etc/ssl/certs/ca-certificates.crt +network.http.cacert = /etc/ssl/certs/ca-certificates.crt system.umask.set = 002 port_range = @port_range@ diff --git a/spk/rutorrent/src/conf/resource b/spk/rutorrent/src/conf/resource new file mode 100644 index 00000000000..88b09ee21cf --- /dev/null +++ b/spk/rutorrent/src/conf/resource @@ -0,0 +1,8 @@ +{ + "php56": { + "php-ini": [{ + "relpath": "etc/php/conf.d/com.synocommunity.rutorrent.ini", + "destpath": "/usr/local/etc/php56/conf.d" + }] + } +} \ No newline at end of file diff --git a/spk/rutorrent/src/dsm-control.sh b/spk/rutorrent/src/dsm-control.sh index adb91e83069..2d4ea1a1b88 100644 --- a/spk/rutorrent/src/dsm-control.sh +++ b/spk/rutorrent/src/dsm-control.sh @@ -19,8 +19,12 @@ USER="$([ "${BUILDNUMBER}" -ge "7321" ] && echo -n ${SC_USER} || echo -n ${LEGAC start_daemon () { - export HOME=${INSTALL_DIR}/var - start-stop-daemon -S -q -m -b -N 10 -x screen -c ${USER} -u ${USER} -p ${PID_FILE} -- -D -m ${RTORRENT} + start-stop-daemon -S -q -m -b -N 10 -x screen -c ${USER} -u ${USER} -p ${PID_FILE} -- \ + -D -m \ + /bin/bash -c "export HOME=${INSTALL_DIR}/var \ + && export PATH=\"${INSTALL_DIR}/env/bin:${INSTALL_DIR}/bin:${INSTALL_DIR}/usr/bin:\${PATH}\" \ + && export LD_LIBRARY_PATH=\"${INSTALL_DIR}/lib:\${LD_LIBRARY_PATH}\" \ + && ${RTORRENT}" } stop_daemon () diff --git a/spk/rutorrent/src/etc/php/conf.d/com.synocommunity.rutorrent.ini b/spk/rutorrent/src/etc/php/conf.d/com.synocommunity.rutorrent.ini new file mode 100644 index 00000000000..953e8e106f8 --- /dev/null +++ b/spk/rutorrent/src/etc/php/conf.d/com.synocommunity.rutorrent.ini @@ -0,0 +1,3 @@ + +[PATH=/var/services/web/rutorrent/] +open_basedir = Null diff --git a/spk/rutorrent/src/installer.sh b/spk/rutorrent/src/installer.sh deleted file mode 100755 index 810a27581c8..00000000000 --- a/spk/rutorrent/src/installer.sh +++ /dev/null @@ -1,230 +0,0 @@ -#!/bin/sh - -# Package -PACKAGE="rutorrent" -DNAME="ruTorrent" -PACKAGE_NAME="com.synocommunity.packages.${PACKAGE}" - -# Others -INSTALL_DIR="/usr/local/${PACKAGE}" -WEB_DIR="/var/services/web" -SSS="/var/packages/${PACKAGE}/scripts/start-stop-status" -PATH="${INSTALL_DIR}/bin:${INSTALL_DIR}/usr/bin:${PATH}" -APACHE_USER="$([ $(grep buildnumber /etc.defaults/VERSION | cut -d"\"" -f2) -ge 4418 ] && echo -n http || echo -n nobody)" -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-rutorrent" -SC_GROUP="sc-download" -SC_GROUP_DESC="SynoCommunity's download related group" -LEGACY_USER="rutorrent" -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 -} - -set_syno_permissions () -{ - # Sets recursive permissions for ${SC_GROUP} on specified directory - # Usage: set_syno_permissions "${wizard_download_dir}" - DIRNAME=$1 - VOLUME=`echo $1 | awk -F/ '{print "/"$2}'` - # Set read/write permissions for SC_GROUP on target directory - if [ ! "`synoacltool -get "${DIRNAME}"| grep "group:${SC_GROUP}:allow:rwxpdDaARWc--:fd--"`" ]; then - synoacltool -add "${DIRNAME}" "group:${SC_GROUP}:allow:rwxpdDaARWc--:fd--" > /dev/null 2>&1 - fi - # Walk up the tree and set traverse permissions up to VOLUME - DIRNAME="$(dirname "${DIRNAME}")" - while [ "${DIRNAME}" != "${VOLUME}" ]; do - if [ ! "`synoacltool -get "${DIRNAME}"| grep "group:${SC_GROUP}:allow:..x"`" ]; then - synoacltool -add "${DIRNAME}" "group:${SC_GROUP}:allow:--x----------:---n" > /dev/null 2>&1 - fi - DIRNAME="$(dirname "${DIRNAME}")" - done -} - - -preinst () -{ - if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then - if [ ! -d "${wizard_download_dir}" ]; then - echo "Download directory ${wizard_download_dir} does not exist." - exit 1 - fi - if [ -n "${wizard_watch_dir}" -a ! -d "${wizard_watch_dir}" ]; then - echo "Watch directory ${wizard_watch_dir} does not exist." - exit 1 - fi - fi - - exit 0 -} - -postinst () -{ - # Link - ln -s ${SYNOPKG_PKGDEST} ${INSTALL_DIR} - - # Install busybox stuff - ${INSTALL_DIR}/bin/busybox --install ${INSTALL_DIR}/bin - - # Install the web interface - cp -pR ${INSTALL_DIR}/share/${PACKAGE} ${WEB_DIR} - - # Configure open_basedir - if [ "${APACHE_USER}" == "nobody" ]; then - echo -e "\nphp_admin_value open_basedir none\n" > /usr/syno/etc/sites-enabled-user/${PACKAGE}.conf - else - echo -e "[PATH=${WEB_DIR}/${PACKAGE}]\nopen_basedir = Null" > /etc/php/conf.d/${PACKAGE_NAME}.ini - fi - - # 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 - - # Configure files - if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then - TOP_DIR=`echo "${wizard_download_dir:=/volume1/downloads}" | cut -d "/" -f 2` - MAX_MEMORY=`awk '/MemTotal/{memory=$2*1024*0.25; if (memory > 512*1024*1024) memory=512*1024*1024; printf "%0.f", memory}' /proc/meminfo` - - sed -i -e "s|scgi_port = 5000;|scgi_port = 8050;|g" \ - -e "s|topDirectory = '/';|topDirectory = '/${TOP_DIR}/';|g" \ - -e "s|tempDirectory = null;|tempDirectory = '${INSTALL_DIR}/tmp';|g" \ - ${WEB_DIR}/${PACKAGE}/conf/config.php - - sed -i -e "s|@download_dir@|${wizard_download_dir:=/volume1/downloads}|g" \ - -e "s|@max_memory@|$MAX_MEMORY|g" \ - -e "s|@port_range@|${wizard_port_range:=6881-6999}|g" \ - ${INSTALL_DIR}/var/.rtorrent.rc - - if [ -d "${wizard_watch_dir}" ]; then - sed -i -e "s|@watch_dir@|${wizard_watch_dir}|g" ${INSTALL_DIR}/var/.rtorrent.rc - else - sed -i -e "/@watch_dir@/d" ${INSTALL_DIR}/var/.rtorrent.rc - fi - - if [ "${wizard_disable_openbasedir}" == "true" ] && [ "${APACHE_USER}" == "http" ]; then - sed -i -e "s|^open_basedir.*|open_basedir = none|g" /etc/php/conf.d/user-settings.ini - initctl restart php-fpm > /dev/null 2>&1 - fi - # Permissions handling - if [ "${BUILDNUMBER}" -ge "4418" ]; then - set_syno_permissions "${wizard_download_dir:=/volume1/downloads}" - if [ -d "${wizard_watch_dir}" ]; then - set_syno_permissions "${wizard_watch_dir}" - fi - fi - fi - - # Correct the files ownership - chown -R ${USER}:root ${SYNOPKG_PKGDEST} - chown -R ${USER}:${APACHE_USER} ${INSTALL_DIR}/tmp - chown -R ${APACHE_USER}:${APACHE_USER} ${WEB_DIR}/${PACKAGE} - - # 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} - - # Remove open_basedir configuration - rm -f /usr/syno/etc/sites-enabled-user/${PACKAGE}.conf - rm -f /etc/php/conf.d/${PACKAGE_NAME}.ini - - # Remove the web interface - rm -fr ${WEB_DIR}/${PACKAGE} - - 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 - - # Revision 8 introduces backward incompatible changes - if [ `echo ${SYNOPKG_OLD_PKGVER} | sed -r "s/^.*-([0-9]+)$/\1/"` -le 8 ]; then - sed -i -e "s|http_cacert = .*|http_cacert = /etc/ssl/certs/ca-certificates.crt|g" ${INSTALL_DIR}/var/.rtorrent.rc - fi - - # Save the configuration file - rm -fr ${TMP_DIR}/${PACKAGE} - mkdir -p ${TMP_DIR}/${PACKAGE} - mv ${WEB_DIR}/${PACKAGE}/conf/config.php ${TMP_DIR}/${PACKAGE}/ - cp -pr ${WEB_DIR}/${PACKAGE}/share/ ${TMP_DIR}/${PACKAGE}/ - mv ${INSTALL_DIR}/var/.rtorrent.rc ${TMP_DIR}/${PACKAGE}/ - mv ${INSTALL_DIR}/var/.session ${TMP_DIR}/${PACKAGE}/ - - exit 0 -} - -postupgrade () -{ - # Restore the configuration file - mv ${TMP_DIR}/${PACKAGE}/config.php ${WEB_DIR}/${PACKAGE}/conf/ - cp -pr ${TMP_DIR}/${PACKAGE}/share/*/ ${WEB_DIR}/${PACKAGE}/share/ - mv ${TMP_DIR}/${PACKAGE}/.rtorrent.rc ${INSTALL_DIR}/var/ - mv ${TMP_DIR}/${PACKAGE}/.session ${INSTALL_DIR}/var/ - rm -fr ${TMP_DIR}/${PACKAGE} - - # Ensure file ownership is correct after upgrade - chown -R ${USER}:root ${SYNOPKG_PKGDEST} - - exit 0 -} diff --git a/spk/rutorrent/src/service-setup.sh b/spk/rutorrent/src/service-setup.sh new file mode 100644 index 00000000000..9d51ade80c6 --- /dev/null +++ b/spk/rutorrent/src/service-setup.sh @@ -0,0 +1,310 @@ +#!/bin/sh + +# Package +PACKAGE="rutorrent" +DNAME="ruTorrent" +PACKAGE_NAME="com.synocommunity.packages.${PACKAGE}" + +# Others +INSTALL_DIR="/usr/local/${PACKAGE}" +WEB_DIR="/var/services/web" +PATH="${INSTALL_DIR}/bin:${INSTALL_DIR}/usr/bin:${PATH}" +APACHE_USER="$([ $(grep buildnumber /etc.defaults/VERSION | cut -d"\"" -f2) -ge 4418 ] && echo -n http || echo -n nobody)" +BUILDNUMBER="$(/bin/get_key_value /etc.defaults/VERSION buildnumber)" + +GROUP="sc-download" +GROUP_DESC="SynoCommunity's download related group" +LEGACY_USER="rutorrent" +LEGACY_GROUP="users" + +PYTHON_DIR="/usr/local/python3" +VIRTUALENV="${PYTHON_DIR}/bin/virtualenv" + +# Sets recursive read / execute permissions for ${KEY} on specified directory +# Usage: grant_basic_permissions "${SHARE_FOLDER}" "user:" +# Usage: grant_basic_permissions "${SHARE_FOLDER}" "group:" +grant_basic_permissions () +{ + DIRNAME=`realpath "${1}"` + KEY="${2}" + + VOLUME=$(echo "${DIRNAME}" | awk -F/ '{print "/"$2}') + + # Ensure directory resides in /volumeX before setting GROUP permissions + if [ "`echo ${VOLUME} | cut -c2-7`" = "volume" ]; then + # Set read & execute permissions for KEY for folder and subfolders + if [ ! "`synoacltool -get \"${DIRNAME}\"| grep \"${KEY}:allow:r.x...a.R....:fd..\"`" ]; then + # First Unix permissions, but only if it's in Linux mode + if [ "`synoacltool -get \"${DIRNAME}\"| grep \"Linux mode\"`" ]; then + set_unix_permissions "${DIRNAME}" + # If it is linux mode (due to old package) we need to add "administrators"-group, + # otherwise the folder is not accessible from File Station anymore! + synoacltool -add "${DIRNAME}" "group:administrators:allow:rwxpdDaARWc:fd" >> ${INST_LOG} 2>&1 + fi + + # Then fix the Synology permissions + echo "Granting '${KEY}' basic permissions on ${DIRNAME}" >> ${INST_LOG} + synoacltool -add "${DIRNAME}" "${KEY}:allow:rxaR:fd" >> ${INST_LOG} 2>&1 + find "${DIRNAME}" -mindepth 1 -type d -exec synoacltool -enforce-inherit "{}" \; >> ${INST_LOG} 2>&1 + fi + + # Walk up the tree and set traverse execute permissions for GROUP up to VOLUME + while [ "${DIRNAME}" != "${VOLUME}" ]; do + if [ ! "`synoacltool -get \"${DIRNAME}\"| grep \"${KEY}:allow:r.x...a.R\"`" ]; then + # Here we also need to make sure the admin can access data via File Station + if [ "`synoacltool -get \"${DIRNAME}\"| grep \"Linux mode\"`" ]; then + synoacltool -add "${DIRNAME}" "group:administrators:allow:rwxpdDaARWc--:fd--" >> ${INST_LOG} 2>&1 + fi + # Add the new group permissions + echo "Granting '${KEY}' basic permissions on ${DIRNAME}" >> ${INST_LOG} + synoacltool -add "${DIRNAME}" "${KEY}:allow:rxaR:n" >> ${INST_LOG} 2>&1 + fi + DIRNAME="$(dirname "${DIRNAME}")" + done + else + echo "Skip granting '${KEY}' basic permissions on ${DIRNAME} as the directory does not reside in '/volumeX'. Set manually if needed." >> ${INST_LOG} + fi +} + +service_preinst () +{ + if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then + if [ ! -d "${wizard_download_dir}" ]; then + echo "Download directory ${wizard_download_dir} does not exist." + exit 1 + fi + if [ -n "${wizard_watch_dir}" -a ! -d "${wizard_watch_dir}" ]; then + echo "Watch directory ${wizard_watch_dir} does not exist." + exit 1 + fi + fi + + exit 0 +} + +fix_shared_folders_rights() +{ + local folder=$1 + echo "Fixing shared folder rights for ${folder}" >> "${INST_LOG}" + chown -R "${APACHE_USER}:${USER}" "${folder}" >> "${INST_LOG}" 2>&1 + chmod ug+rwx "${folder}" >> "${INST_LOG}" 2>&1 + synoacltool -add "${folder}" "user:${EFF_USER}:allow:rwxpdDaARWcC:fd" >> "${INST_LOG}" 2>&1 + synoacltool -add "${folder}" "user:${APACHE_USER}:allow:rwxpdDaARWcC:fd" >> "${INST_LOG}" 2>&1 + find "${folder}" -mindepth 1 -type d -exec synoacltool -enforce-inherit "{}" \; >> ${INST_LOG} 2>&1 +} + +service_postinst () +{ + + # Install busybox stuff + ${INSTALL_DIR}/bin/busybox --install ${INSTALL_DIR}/bin + + syno_user_add_to_legacy_group "${EFF_USER}" "${LEGACY_USER}" "${LEGACY_GROUP}" + + # Install the web interface + cp -pR ${INSTALL_DIR}/share/${PACKAGE} ${WEB_DIR} >>"${INST_LOG}" 2>&1 + + # Configure open_basedir + if [ "${APACHE_USER}" == "nobody" ]; then + echo -e "\nphp_admin_value open_basedir none\n" > /usr/syno/etc/sites-enabled-user/${PACKAGE}.conf + else + if [ -d "/etc/php/conf.d/" ]; then + echo -e "[PATH=${WEB_DIR}/${PACKAGE}]\nopen_basedir = Null" > /etc/php/conf.d/${PACKAGE_NAME}.ini + fi + fi + + # Configure files + if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then + TOP_DIR=`echo "${wizard_download_dir:=/volume1/downloads}" | cut -d "/" -f 2` + MAX_MEMORY=`awk '/MemTotal/{memory=$2*1024*0.25; if (memory > 512*1024*1024) memory=512*1024*1024; printf "%0.f", memory}' /proc/meminfo` + + sed -i -e "s|scgi_port = 5000;|scgi_port = 8050;|g" \ + -e "s|topDirectory = '/';|topDirectory = '/${TOP_DIR}/';|g" \ + -e "s|tempDirectory = null;|tempDirectory = '${INSTALL_DIR}/tmp/';|g" \ + -e "s|\"python\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"python\"\1=>\2'${INSTALL_DIR}/env/bin/python3'\3,\4|g" \ + -e "s|\"pgrep\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"pgrep\"\1=>\2'${INSTALL_DIR}/bin/pgrep'\3,\4|g" \ + -e "s|\"sox\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"sox\"\1=>\2'${INSTALL_DIR}/bin/sox'\3,\4|g" \ + -e "s|\"mediainfo\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"mediainfo\"\1=>\2'${INSTALL_DIR}/bin/mediainfo'\3,\4|g" \ + -e "s|\"stat\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"stat\"\1=>\2'/bin/stat'\3,\4|g" \ + -e "s|\"curl\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"curl\"\1=>\2'${INSTALL_DIR}/bin/curl'\3,\4|g" \ + -e "s|\"id\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"id\"\1=>\2'/bin/id'\3,\4|g" \ + -e "s|\"gzip\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"gzip\"\1=>\2'/bin/gzip'\3,\4|g" \ + -e "s|\"php\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"php\"\1=>\2'/bin/php'\3,\4|g" \ + ${WEB_DIR}/${PACKAGE}/conf/config.php >>"${INST_LOG}" 2>&1 + + sed -i -e "s|@download_dir@|${wizard_download_dir:=/volume1/downloads}|g" \ + -e "s|@max_memory@|$MAX_MEMORY|g" \ + -e "s|@port_range@|${wizard_port_range:=6881-6999}|g" \ + ${INSTALL_DIR}/var/.rtorrent.rc >>"${INST_LOG}" 2>&1 + + if [ -d "${wizard_watch_dir}" ]; then + sed -i -e "s|@watch_dir@|${wizard_watch_dir}|g" ${INSTALL_DIR}/var/.rtorrent.rc >>"${INST_LOG}" 2>&1 + else + sed -i -e "/@watch_dir@/d" ${INSTALL_DIR}/var/.rtorrent.rc >>"${INST_LOG}" 2>&1 + fi + + if [ "${wizard_disable_openbasedir}" == "true" ] && [ "${APACHE_USER}" == "http" ]; then + if [ -f "/etc/php/conf.d/user-settings.ini" ]; then + sed -i -e "s|^open_basedir.*|open_basedir = none|g" /etc/php/conf.d/user-settings.ini >>"${INST_LOG}" 2>&1 + initctl restart php-fpm > /dev/null 2>&1 + fi + fi + # Permissions handling + if [ "${BUILDNUMBER}" -ge "4418" ]; then + set_syno_permissions "${wizard_download_dir:=/volume1/downloads}" "${GROUP}" + if [ -d "${wizard_watch_dir}" ]; then + set_syno_permissions "${wizard_watch_dir}" "${GROUP}" + fi + fi + fi + + + #If python3 is available setup a virtual environment with cloudscraper + if [ -f "${PYTHON_DIR}/bin/python3" ]; then + # Create a Python virtualenv + ${VIRTUALENV} --system-site-packages ${INSTALL_DIR}/env >> "${INST_LOG}" 2>&1 + # Install the cloudscraper wheels + ${INSTALL_DIR}/env/bin/pip install -U cloudscraper==1.2.48 >> "${INST_LOG}" 2>&1 + fi + + # Ensure that the rutorrent group still owns the installation directory + set_syno_permissions "${INSTALL_DIR}" "rutorrent" + + # Ensure that the web user has read access to var/.session directory + grant_basic_permissions "${INSTALL_DIR}/var/.session" "user:${APACHE_USER}" + + # Ensure that the apache user has full rights on the web directory + set_syno_permissions "${WEB_DIR}/${PACKAGE}" "${APACHE_USER}" + + grant_basic_permissions "${INSTALL_DIR}/bin" "user:${APACHE_USER}" + grant_basic_permissions "${INSTALL_DIR}/lib" "user:${APACHE_USER}" + grant_basic_permissions "${INSTALL_DIR}/env" "user:${APACHE_USER}" + grant_basic_permissions "${WEB_DIR}/${PACKAGE}" "user:${EFF_USER}" + grant_basic_permissions "${WEB_DIR}/${PACKAGE}/php/test.sh" "user:${EFF_USER}" + + fix_shared_folders_rights "${INSTALL_DIR}/tmp" + fix_shared_folders_rights "${WEB_DIR}/${PACKAGE}/share" + + exit 0 +} + +service_preuninst () +{ + exit 0 +} + +service_postuninst () +{ + # Remove the web interface + log_step "Removing web interface" + rm -fr "${WEB_DIR}/${PACKAGE}" >>"${INST_LOG}" 2>&1 + + exit 0 +} + +service_save () +{ + # Revision 8 introduces backward incompatible changes + if [ `echo ${SYNOPKG_OLD_PKGVER} | sed -r "s/^.*-([0-9]+)$/\1/"` -le 8 ]; then + sed -i -e "s|http_cacert = .*|http_cacert = /etc/ssl/certs/ca-certificates.crt|g" ${INSTALL_DIR}/var/.rtorrent.rc + fi + + # Save the configuration file + mv ${WEB_DIR}/${PACKAGE}/conf/config.php ${TMP_DIR}/ >>"${INST_LOG}" 2>&1 + if [ -f "${WEB_DIR}/${PACKAGE}/.htaccess" ]; then + mv "${WEB_DIR}/${PACKAGE}/.htaccess" "${TMP_DIR}/" >>"${INST_LOG}" 2>&1 + fi + cp -pr ${WEB_DIR}/${PACKAGE}/share/ ${TMP_DIR}/ >>"${INST_LOG}" 2>&1 + mv ${INSTALL_DIR}/var/.rtorrent.rc ${TMP_DIR}/ >>"${INST_LOG}" 2>&1 + mv ${INSTALL_DIR}/var/.session ${TMP_DIR}/ >>"${INST_LOG}" 2>&1 + + exit 0 +} + +is_not_defined_external_program() +{ + program=$1 + php -r "require_once('${WEB_DIR}/${PACKAGE}/conf/config.php'); if (isset(\$pathToExternals['${program}']) && !empty(\$pathToExternals['${program}'])) { exit(1); } else { exit(0); }" >>"${INST_LOG}" 2>&1 + return $? +} + +define_external_program() +{ + program=$1 + value=$2 + like=$3 + echo "\$pathToExternals['${program}'] = '${value}'; // Something like $like. If empty, will be found in PATH" \ + >> "${WEB_DIR}/${PACKAGE}/conf/config.php" +} + +service_restore () +{ + # Restore the configuration file + mv -f "${TMP_DIR}/config.php" "${WEB_DIR}/${PACKAGE}/conf/" >>"${INST_LOG}" 2>&1 + + if [ -f "${TMP_DIR}/.htaccess" ]; then + mv -f "${TMP_DIR}/.htaccess" "${WEB_DIR}/${PACKAGE}/" >>"${INST_LOG}" 2>&1 + set_syno_permissions "${WEB_DIR}/${PACKAGE}/.htaccess" "${APACHE_USER}" + fi + + # In previous versions the python entry had nothing defined, + # here we define it if, and only if, python3 is actually installed + if [ -f "${PYTHON_DIR}/bin/python3" ] && `is_not_defined_external_program 'python'`; then + define_external_program 'python' "${INSTALL_DIR}/env/bin/python3" '/usr/bin/python3' + fi + + # In previous versions the pgrep entry had nothing defined + if `is_not_defined_external_program 'pgrep'`; then + define_external_program 'pgrep' "${INSTALL_DIR}/bin/pgrep" '/usr/bin/pgrep' + fi + + # In previous versions the sox entry had nothing defined + if `is_not_defined_external_program 'sox'`; then + define_external_program 'sox' "${INSTALL_DIR}/bin/sox" '/usr/bin/sox' + fi + + # In previous versions the mediainfo entry had nothing defined + if `is_not_defined_external_program 'mediainfo'`; then + define_external_program 'mediainfo' "${INSTALL_DIR}/bin/mediainfo" '/usr/bin/mediainfo' + fi + + # In previous versions the stat entry had nothing defined + if `is_not_defined_external_program 'stat'`; then + define_external_program 'stat' '/bin/stat' '/usr/bin/stat' + fi + + if `is_not_defined_external_program 'id'`; then + define_external_program 'id' '/bin/id' '/usr/bin/id' + fi + + if `is_not_defined_external_program 'gzip'`; then + define_external_program 'gzip' '/bin/gzip' '/usr/bin/gzip' + fi + + if `is_not_defined_external_program 'curl'`; then + define_external_program 'curl' "${INSTALL_DIR}/bin/curl" '/usr/bin/curl' + fi + + if `is_not_defined_external_program 'php'`; then + define_external_program 'php' '/bin/php' '/usr/bin/php' + fi + + set_syno_permissions "${WEB_DIR}/${PACKAGE}/conf/config.php" "${APACHE_USER}" + + cp -pr ${TMP_DIR}/share/*/ ${WEB_DIR}/${PACKAGE}/share/ >>"${INST_LOG}" 2>&1 + set_syno_permissions "${WEB_DIR}/${PACKAGE}/share/" "${APACHE_USER}" + + mv ${TMP_DIR}/.rtorrent.rc ${INSTALL_DIR}/var/ >>"${INST_LOG}" 2>&1 + + if [ ! `grep 'http_cacert = ' "${INSTALL_DIR}/var/.rtorrent.rc" | wc -l` -eq 0 ]; then + # http_cacert command has been moved to network.http.cacert + sed -i -e 's|http_cacert = \(.*\)|network.http.cacert = \1|g' ${INSTALL_DIR}/var/.rtorrent.rc >>"${INST_LOG}" 2>&1 + fi + + mv ${TMP_DIR}/.session ${INSTALL_DIR}/var/ >>"${INST_LOG}" 2>&1 + + # Restore appropriate rights on the var directory + set_unix_permissions "${INSTALL_DIR}/var/" + + exit 0 +} From 6175acc2db773b65b02e884dc928f441398785b9 Mon Sep 17 00:00:00 2001 From: hgy59 Date: Thu, 12 Nov 2020 21:27:08 +0100 Subject: [PATCH 03/19] enable build for qoriq - remove qoriq from unsupported archs as qoriq is supported - hi3535 arch is not supported by dependent cross/rtorrent - remove static libraries and pkgconfig from from sox/PLIST - fix cross/unzip/PLIST --- cross/rtorrent/Makefile | 7 +++++-- cross/sox/PLIST | 3 --- cross/unzip/PLIST | 2 +- spk/rutorrent/Makefile | 5 ++++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cross/rtorrent/Makefile b/cross/rtorrent/Makefile index 88a6326f8bf..6c997f074ac 100644 --- a/cross/rtorrent/Makefile +++ b/cross/rtorrent/Makefile @@ -6,8 +6,11 @@ PKG_DIST_SITE = https://github.com/rakshasa/rtorrent/archive PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) PKG_DIR = $(PKG_NAME)-$(PKG_VERS) -UNSUPPORTED_ARCHS = $(PPC_ARCHES) -# arm-cortexa9-linux-gnueabi-g++: internal compiler error: Segmentation fault (program cc1plus) +# PPC_ARCHES except qoriq +UNSUPPORTED_ARCHS = powerpc ppc824x ppc853x ppc854x + +# error: template instantiation depth exceeds maximum of 900 (requires gcc >= 4.9) +# see: https://github.com/rakshasa/rtorrent/issues/223 UNSUPPORTED_ARCHS += hi3535 DEPENDS = cross/ncursesw cross/libsigc++ cross/curl cross/libtorrent-rakshasa cross/xmlrpc-c diff --git a/cross/sox/PLIST b/cross/sox/PLIST index d4b55dd2e71..c06b5ccbd7a 100644 --- a/cross/sox/PLIST +++ b/cross/sox/PLIST @@ -2,9 +2,6 @@ bin:bin/play bin:bin/rec bin:bin/sox bin:bin/soxi -lib:lib/libsox.a -lib:lib/libsox.la lnk:lib/libsox.so lnk:lib/libsox.so.3 lib:lib/libsox.so.3.0.0 -rsc:lib/pkgconfig/sox.pc \ No newline at end of file diff --git a/cross/unzip/PLIST b/cross/unzip/PLIST index 8acaea3cbb0..b6c50e90535 100644 --- a/cross/unzip/PLIST +++ b/cross/unzip/PLIST @@ -1,5 +1,5 @@ bin:bin/funzip bin:bin/unzip bin:bin/unzipsfx -bin:bin/zipgrep +rsc:bin/zipgrep bin:bin/zipinfo diff --git a/spk/rutorrent/Makefile b/spk/rutorrent/Makefile index 8e4dee7e60d..a079f8d8566 100644 --- a/spk/rutorrent/Makefile +++ b/spk/rutorrent/Makefile @@ -4,7 +4,10 @@ SPK_REV = 3 SPK_ICON = src/rutorrent.png DSM_UI_DIR = app -UNSUPPORTED_ARCHS = $(ARM5_ARCHES) $(PPC_ARCHES) +# some dependents require C++11 support +UNSUPPORTED_ARCHS = $(ARM5_ARCHES) powerpc ppc824x ppc853x ppc854x +# unsupported with cross/rtorrent +UNSUPPORTED_ARCHS += hi3535 DEPENDS = cross/busybox cross/curl cross/procps-ng cross/mediainfo cross/rtorrent cross/rutorrent cross/screen cross/unzip DEPENDS += cross/sox From 9bcfc036ea28787bd438e7b4742051e57ab7caed Mon Sep 17 00:00:00 2001 From: Vincent Fortier Date: Tue, 17 Nov 2020 02:19:29 +0000 Subject: [PATCH 04/19] rutorrent: Configuration API change for load.start --- spk/rutorrent/src/.rtorrent.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spk/rutorrent/src/.rtorrent.rc b/spk/rutorrent/src/.rtorrent.rc index a206895a076..ffeee3bfeb2 100755 --- a/spk/rutorrent/src/.rtorrent.rc +++ b/spk/rutorrent/src/.rtorrent.rc @@ -1,7 +1,7 @@ scgi_port = localhost:8050 directory = @download_dir@ session = /usr/local/rutorrent/var/.session -schedule = watch_directory,5,5,load_start=@watch_dir@/*.torrent +schedule = watch_directory,5,5,load.start=@watch_dir@/*.torrent max_memory_usage = @max_memory@ log.open_file = "rtorrent.log", "/usr/local/rutorrent/var/rtorrent.log" log.add_output = "warn", "rtorrent.log" From 0c59e7e8e1236a2b39f19250c0c34e4534e50e99 Mon Sep 17 00:00:00 2001 From: Vincent Fortier Date: Tue, 17 Nov 2020 02:26:24 +0000 Subject: [PATCH 05/19] rutorrent: Enforce encryption by default --- spk/rutorrent/src/.rtorrent.rc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spk/rutorrent/src/.rtorrent.rc b/spk/rutorrent/src/.rtorrent.rc index ffeee3bfeb2..4c3c3a085a6 100755 --- a/spk/rutorrent/src/.rtorrent.rc +++ b/spk/rutorrent/src/.rtorrent.rc @@ -7,4 +7,8 @@ log.open_file = "rtorrent.log", "/usr/local/rutorrent/var/rtorrent.log" log.add_output = "warn", "rtorrent.log" network.http.cacert = /etc/ssl/certs/ca-certificates.crt system.umask.set = 002 +protocol.encryption.set = require,require_RC4,allow_incoming,try_outgoing +dht.mode.set = auto +dht.port.set = 6881 +protocol.pex.set= yes port_range = @port_range@ From c57099fc0b912bbb87b17c470206e910a022f8ee Mon Sep 17 00:00:00 2001 From: Vincent Fortier Date: Tue, 17 Nov 2020 02:28:12 +0000 Subject: [PATCH 06/19] rutorrent: Change maintainer for smaarn --- spk/rutorrent/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spk/rutorrent/Makefile b/spk/rutorrent/Makefile index a079f8d8566..25ce20fc42d 100644 --- a/spk/rutorrent/Makefile +++ b/spk/rutorrent/Makefile @@ -12,7 +12,7 @@ UNSUPPORTED_ARCHS += hi3535 DEPENDS = cross/busybox cross/curl cross/procps-ng cross/mediainfo cross/rtorrent cross/rutorrent cross/screen cross/unzip DEPENDS += cross/sox -MAINTAINER = moneytoo +MAINTAINER = smaarn DESCRIPTION = ruTorrent is a front-end for the popular Bittorrent client rTorrent. rTorrent is a BitTorrent client for ncurses, using the libtorrent library. The client and library is written in C++ with emphasis on speed and efficiency, while delivering equivalent features to those found in GUI based clients in an ncurses client. ADMIN_URL = /rutorrent/ RELOAD_UI = yes From 11d5d041983a7dc5a4384a282e4d1937f412bb53 Mon Sep 17 00:00:00 2001 From: Vincent Fortier Date: Tue, 17 Nov 2020 02:28:59 +0000 Subject: [PATCH 07/19] rutorrent: Remove beta flag --- spk/rutorrent/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/spk/rutorrent/Makefile b/spk/rutorrent/Makefile index 25ce20fc42d..184467cab41 100644 --- a/spk/rutorrent/Makefile +++ b/spk/rutorrent/Makefile @@ -24,7 +24,6 @@ CHANGELOG += 3. Update to libtorrent 0.13.8
CHANGELOG += 4. Update to xmlrpc-c 1.51.06
CHANGELOG += 5. Update openssl to 1.1
CHANGELOG += 6. Embed missing binary requirements
" -BETA = 1 HOMEPAGE = https://github.com/Novik/ruTorrent LICENSE = GPLv3 From 0fc1ce9029523b4f43bce061d47d9c321bcc5c52 Mon Sep 17 00:00:00 2001 From: Smaarn Date: Tue, 17 Nov 2020 23:34:17 +0100 Subject: [PATCH 08/19] fixed: icon was lost because app directory was no longer accessible to "everyone" ... or at least to the user which is supposed to maintain DSM Web links I guess ? --- spk/rutorrent/src/service-setup.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spk/rutorrent/src/service-setup.sh b/spk/rutorrent/src/service-setup.sh index 9d51ade80c6..d7f47a44738 100644 --- a/spk/rutorrent/src/service-setup.sh +++ b/spk/rutorrent/src/service-setup.sh @@ -176,6 +176,10 @@ service_postinst () # Ensure that the apache user has full rights on the web directory set_syno_permissions "${WEB_DIR}/${PACKAGE}" "${APACHE_USER}" + # Ensure that the app directory (which contains DSM Web integration resources) + # are accessible in read and execute mode to everyone + grant_basic_permissions "${INSTALL_DIR}/app" "everyone:\*" + grant_basic_permissions "${INSTALL_DIR}/bin" "user:${APACHE_USER}" grant_basic_permissions "${INSTALL_DIR}/lib" "user:${APACHE_USER}" grant_basic_permissions "${INSTALL_DIR}/env" "user:${APACHE_USER}" From 0910d88bc541497379b5bc3e10f575efba7cbe4f Mon Sep 17 00:00:00 2001 From: Smaarn Date: Sun, 22 Nov 2020 11:54:21 +0100 Subject: [PATCH 09/19] rutorrent: reworked privileges to use standards and use SERVICE_COMMAND shortcut --- spk/rutorrent/Makefile | 8 +-- spk/rutorrent/src/bin/rutorrent-daemon | 13 ++++ spk/rutorrent/src/conf/privilege | 31 ---------- spk/rutorrent/src/dsm-control.sh | 86 -------------------------- spk/rutorrent/src/service-setup.sh | 5 ++ 5 files changed, 22 insertions(+), 121 deletions(-) create mode 100644 spk/rutorrent/src/bin/rutorrent-daemon delete mode 100644 spk/rutorrent/src/conf/privilege delete mode 100644 spk/rutorrent/src/dsm-control.sh diff --git a/spk/rutorrent/Makefile b/spk/rutorrent/Makefile index 184467cab41..2ea7dceb2ea 100644 --- a/spk/rutorrent/Makefile +++ b/spk/rutorrent/Makefile @@ -30,12 +30,10 @@ LICENSE = GPLv3 SERVICE_USER = auto -SPK_USER = rutorrent - SERVICE_SETUP = src/service-setup.sh SERVICE_WIZARD_SHARE=wizard_download_dir -SSS_SCRIPT = src/dsm-control.sh +SERVICE_COMMAND = /usr/local/$(SPK_NAME)/bin/$(SPK_NAME)-daemon FWPORTS = src/${SPK_NAME}.sc CONF_DIR = src/conf/ WIZARDS_DIR = src/wizard/ @@ -48,13 +46,15 @@ INSTALL_PREFIX = /usr/local/$(SPK_NAME) POST_STRIP_TARGET = rutorrent_extra_install -BUSYBOX_CONFIG = usrmng daemon nice procutils +BUSYBOX_CONFIG = usrmng nice procutils ENV += BUSYBOX_CONFIG="$(BUSYBOX_CONFIG)" include ../../mk/spksrc.spk.mk .PHONY: rutorrent_extra_install rutorrent_extra_install: + install -m 755 -d $(STAGING_DIR)/bin + install -m 755 src/bin/rutorrent-daemon $(STAGING_DIR)/bin/rutorrent-daemon install -m 755 -d $(STAGING_DIR)/var install -m 644 src/.rtorrent.rc $(STAGING_DIR)/var/ install -m 755 -d $(STAGING_DIR)/var/.session diff --git a/spk/rutorrent/src/bin/rutorrent-daemon b/spk/rutorrent/src/bin/rutorrent-daemon new file mode 100644 index 00000000000..9ca771521ee --- /dev/null +++ b/spk/rutorrent/src/bin/rutorrent-daemon @@ -0,0 +1,13 @@ +#!/bin/bash + +# Package +PACKAGE="rutorrent" + +INSTALL_DIR="/usr/local/${PACKAGE}" + +export HOME=${INSTALL_DIR}/var +export PATH="${INSTALL_DIR}/env/bin:${INSTALL_DIR}/bin:${INSTALL_DIR}/usr/bin:${PATH}" +export LD_LIBRARY_PATH="${INSTALL_DIR}/lib:${LD_LIBRARY_PATH}" +RTORRENT="${INSTALL_DIR}/bin/rtorrent" + +exec screen -D -m ${RTORRENT} diff --git a/spk/rutorrent/src/conf/privilege b/spk/rutorrent/src/conf/privilege deleted file mode 100644 index 1a514dd7901..00000000000 --- a/spk/rutorrent/src/conf/privilege +++ /dev/null @@ -1,31 +0,0 @@ -{ - "defaults":{ - "run-as": "package" - }, - "username": "sc-rutorrent", - "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/rutorrent/src/dsm-control.sh b/spk/rutorrent/src/dsm-control.sh deleted file mode 100644 index 2d4ea1a1b88..00000000000 --- a/spk/rutorrent/src/dsm-control.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/sh - -# Package -PACKAGE="rutorrent" -DNAME="ruTorrent" - -# Others -INSTALL_DIR="/usr/local/${PACKAGE}" -PATH="${INSTALL_DIR}/bin:${INSTALL_DIR}/usr/bin:${PATH}" -BUILDNUMBER="$(/bin/get_key_value /etc.defaults/VERSION buildnumber)" -RTORRENT="${INSTALL_DIR}/bin/rtorrent" -PID_FILE="${INSTALL_DIR}/var/rtorrent.pid" -LOG_FILE="${INSTALL_DIR}/var/rtorrent.log" - -SC_USER="sc-rutorrent" -LEGACY_USER="rutorrent" -USER="$([ "${BUILDNUMBER}" -ge "7321" ] && echo -n ${SC_USER} || echo -n ${LEGACY_USER})" - - -start_daemon () -{ - start-stop-daemon -S -q -m -b -N 10 -x screen -c ${USER} -u ${USER} -p ${PID_FILE} -- \ - -D -m \ - /bin/bash -c "export HOME=${INSTALL_DIR}/var \ - && export PATH=\"${INSTALL_DIR}/env/bin:${INSTALL_DIR}/bin:${INSTALL_DIR}/usr/bin:\${PATH}\" \ - && export LD_LIBRARY_PATH=\"${INSTALL_DIR}/lib:\${LD_LIBRARY_PATH}\" \ - && ${RTORRENT}" -} - -stop_daemon () -{ - start-stop-daemon -K -q -u ${USER} -p ${PID_FILE} - wait_for_status 1 20 || start-stop-daemon -K -s 9 -q -p ${PID_FILE} -} - -daemon_status () -{ - start-stop-daemon -K -q -t -u ${USER} -p ${PID_FILE} -} - -wait_for_status () -{ - counter=$2 - while [ ${counter} -gt 0 ]; do - daemon_status - [ $? -eq $1 ] && return - let counter=counter-1 - sleep 1 - done - return 1 -} - - -case $1 in - start) - if daemon_status; then - echo ${DNAME} is already running - else - echo Starting ${DNAME} ... - start_daemon - fi - ;; - stop) - if daemon_status; then - echo Stopping ${DNAME} ... - stop_daemon - else - echo ${DNAME} is not running - fi - ;; - status) - if daemon_status; then - echo ${DNAME} is running - exit 0 - else - echo ${DNAME} is not running - exit 1 - fi - ;; - log) - echo ${LOG_FILE} - ;; - *) - exit 1 - ;; -esac diff --git a/spk/rutorrent/src/service-setup.sh b/spk/rutorrent/src/service-setup.sh index d7f47a44738..c17dc3f50bc 100644 --- a/spk/rutorrent/src/service-setup.sh +++ b/spk/rutorrent/src/service-setup.sh @@ -20,6 +20,11 @@ LEGACY_GROUP="users" PYTHON_DIR="/usr/local/python3" VIRTUALENV="${PYTHON_DIR}/bin/virtualenv" +SVC_BACKGROUND=y +PID_FILE="${INSTALL_DIR}/var/rtorrent.pid" +LOG_FILE="${INSTALL_DIR}/var/rtorrent.log" +SVC_WRITE_PID=y + # Sets recursive read / execute permissions for ${KEY} on specified directory # Usage: grant_basic_permissions "${SHARE_FOLDER}" "user:" # Usage: grant_basic_permissions "${SHARE_FOLDER}" "group:" From e23e8547fce96cb96c621f7800337df0027786c7 Mon Sep 17 00:00:00 2001 From: Smaarn Date: Tue, 24 Nov 2020 21:24:07 +0100 Subject: [PATCH 10/19] rutorrent: removed unnecessary and ACL setting logics --- spk/rutorrent/src/service-setup.sh | 65 ------------------------------ 1 file changed, 65 deletions(-) diff --git a/spk/rutorrent/src/service-setup.sh b/spk/rutorrent/src/service-setup.sh index c17dc3f50bc..5cdf1388b98 100644 --- a/spk/rutorrent/src/service-setup.sh +++ b/spk/rutorrent/src/service-setup.sh @@ -25,52 +25,6 @@ PID_FILE="${INSTALL_DIR}/var/rtorrent.pid" LOG_FILE="${INSTALL_DIR}/var/rtorrent.log" SVC_WRITE_PID=y -# Sets recursive read / execute permissions for ${KEY} on specified directory -# Usage: grant_basic_permissions "${SHARE_FOLDER}" "user:" -# Usage: grant_basic_permissions "${SHARE_FOLDER}" "group:" -grant_basic_permissions () -{ - DIRNAME=`realpath "${1}"` - KEY="${2}" - - VOLUME=$(echo "${DIRNAME}" | awk -F/ '{print "/"$2}') - - # Ensure directory resides in /volumeX before setting GROUP permissions - if [ "`echo ${VOLUME} | cut -c2-7`" = "volume" ]; then - # Set read & execute permissions for KEY for folder and subfolders - if [ ! "`synoacltool -get \"${DIRNAME}\"| grep \"${KEY}:allow:r.x...a.R....:fd..\"`" ]; then - # First Unix permissions, but only if it's in Linux mode - if [ "`synoacltool -get \"${DIRNAME}\"| grep \"Linux mode\"`" ]; then - set_unix_permissions "${DIRNAME}" - # If it is linux mode (due to old package) we need to add "administrators"-group, - # otherwise the folder is not accessible from File Station anymore! - synoacltool -add "${DIRNAME}" "group:administrators:allow:rwxpdDaARWc:fd" >> ${INST_LOG} 2>&1 - fi - - # Then fix the Synology permissions - echo "Granting '${KEY}' basic permissions on ${DIRNAME}" >> ${INST_LOG} - synoacltool -add "${DIRNAME}" "${KEY}:allow:rxaR:fd" >> ${INST_LOG} 2>&1 - find "${DIRNAME}" -mindepth 1 -type d -exec synoacltool -enforce-inherit "{}" \; >> ${INST_LOG} 2>&1 - fi - - # Walk up the tree and set traverse execute permissions for GROUP up to VOLUME - while [ "${DIRNAME}" != "${VOLUME}" ]; do - if [ ! "`synoacltool -get \"${DIRNAME}\"| grep \"${KEY}:allow:r.x...a.R\"`" ]; then - # Here we also need to make sure the admin can access data via File Station - if [ "`synoacltool -get \"${DIRNAME}\"| grep \"Linux mode\"`" ]; then - synoacltool -add "${DIRNAME}" "group:administrators:allow:rwxpdDaARWc--:fd--" >> ${INST_LOG} 2>&1 - fi - # Add the new group permissions - echo "Granting '${KEY}' basic permissions on ${DIRNAME}" >> ${INST_LOG} - synoacltool -add "${DIRNAME}" "${KEY}:allow:rxaR:n" >> ${INST_LOG} 2>&1 - fi - DIRNAME="$(dirname "${DIRNAME}")" - done - else - echo "Skip granting '${KEY}' basic permissions on ${DIRNAME} as the directory does not reside in '/volumeX'. Set manually if needed." >> ${INST_LOG} - fi -} - service_preinst () { if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then @@ -172,25 +126,6 @@ service_postinst () ${INSTALL_DIR}/env/bin/pip install -U cloudscraper==1.2.48 >> "${INST_LOG}" 2>&1 fi - # Ensure that the rutorrent group still owns the installation directory - set_syno_permissions "${INSTALL_DIR}" "rutorrent" - - # Ensure that the web user has read access to var/.session directory - grant_basic_permissions "${INSTALL_DIR}/var/.session" "user:${APACHE_USER}" - - # Ensure that the apache user has full rights on the web directory - set_syno_permissions "${WEB_DIR}/${PACKAGE}" "${APACHE_USER}" - - # Ensure that the app directory (which contains DSM Web integration resources) - # are accessible in read and execute mode to everyone - grant_basic_permissions "${INSTALL_DIR}/app" "everyone:\*" - - grant_basic_permissions "${INSTALL_DIR}/bin" "user:${APACHE_USER}" - grant_basic_permissions "${INSTALL_DIR}/lib" "user:${APACHE_USER}" - grant_basic_permissions "${INSTALL_DIR}/env" "user:${APACHE_USER}" - grant_basic_permissions "${WEB_DIR}/${PACKAGE}" "user:${EFF_USER}" - grant_basic_permissions "${WEB_DIR}/${PACKAGE}/php/test.sh" "user:${EFF_USER}" - fix_shared_folders_rights "${INSTALL_DIR}/tmp" fix_shared_folders_rights "${WEB_DIR}/${PACKAGE}/share" From 9ff1a889c21dec5b020cbda5c039401a1334e50a Mon Sep 17 00:00:00 2001 From: Vincent Fortier Date: Thu, 26 Nov 2020 01:31:00 +0000 Subject: [PATCH 11/19] rutorrent: Fix directory permissions using ACL Directory permissions where first set using Linux type and after superseeded with ACL. Permissions on http user was too wide leading the ability to the application to change ownership to default 0777. Following changes only uses ACL and reduce permissions to http user and group to only what it needs to work. --- spk/rutorrent/src/service-setup.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spk/rutorrent/src/service-setup.sh b/spk/rutorrent/src/service-setup.sh index 5cdf1388b98..b165aff5a7c 100644 --- a/spk/rutorrent/src/service-setup.sh +++ b/spk/rutorrent/src/service-setup.sh @@ -45,10 +45,12 @@ fix_shared_folders_rights() { local folder=$1 echo "Fixing shared folder rights for ${folder}" >> "${INST_LOG}" - chown -R "${APACHE_USER}:${USER}" "${folder}" >> "${INST_LOG}" 2>&1 - chmod ug+rwx "${folder}" >> "${INST_LOG}" 2>&1 - synoacltool -add "${folder}" "user:${EFF_USER}:allow:rwxpdDaARWcC:fd" >> "${INST_LOG}" 2>&1 - synoacltool -add "${folder}" "user:${APACHE_USER}:allow:rwxpdDaARWcC:fd" >> "${INST_LOG}" 2>&1 + chown -R "${EFF_USER}:${APACHE_USER}" "${folder}" >> "${INST_LOG}" 2>&1 + synoacltool -add "${folder}" "everyone::allow:r-x----------:fd--" >> "${INST_LOG}" 2>&1 + synoacltool -add "${folder}" "user:${EFF_USER}:allow:rwxpdDaARWc--:fd" >> "${INST_LOG}" 2>&1 + synoacltool -add "${folder}" "group:${USER}:allow:rwxpdDaARWc--:fd" >> "${INST_LOG}" 2>&1 + synoacltool -add "${folder}" "user:${APACHE_USER}:allow:rwxp-D------:fd" >> "${INST_LOG}" 2>&1 + synoacltool -add "${folder}" "group:${APACHE_USER}:allow:rwxp-D------:fd--" >> "${INST_LOG}" 2>&1 find "${folder}" -mindepth 1 -type d -exec synoacltool -enforce-inherit "{}" \; >> ${INST_LOG} 2>&1 } From 224079a57626e4ea94faf4a6fd92a27f6e2804a2 Mon Sep 17 00:00:00 2001 From: Vincent Fortier Date: Thu, 26 Nov 2020 01:35:07 +0000 Subject: [PATCH 12/19] rutorrent: Bump package version to superseed latest online --- spk/rutorrent/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spk/rutorrent/Makefile b/spk/rutorrent/Makefile index 2ea7dceb2ea..f76355189a2 100644 --- a/spk/rutorrent/Makefile +++ b/spk/rutorrent/Makefile @@ -1,6 +1,6 @@ SPK_NAME = rutorrent SPK_VERS = 3.10 -SPK_REV = 3 +SPK_REV = 9 SPK_ICON = src/rutorrent.png DSM_UI_DIR = app From e6221a86825ac437f95c45a1f5fec591aac06fa2 Mon Sep 17 00:00:00 2001 From: Smaarn Date: Thu, 26 Nov 2020 23:09:47 +0100 Subject: [PATCH 13/19] rutorrent: removing dependency on /usr/local/${PACKAGE} --- spk/rutorrent/Makefile | 15 ++--- spk/rutorrent/src/bin/rutorrent-daemon | 2 +- spk/rutorrent/src/service-setup.sh | 76 ++++++++++++-------------- 3 files changed, 40 insertions(+), 53 deletions(-) diff --git a/spk/rutorrent/Makefile b/spk/rutorrent/Makefile index f76355189a2..6ec84b54ba8 100644 --- a/spk/rutorrent/Makefile +++ b/spk/rutorrent/Makefile @@ -18,22 +18,17 @@ ADMIN_URL = /rutorrent/ RELOAD_UI = yes STARTABLE = yes DISPLAY_NAME = ruTorrent -CHANGELOG = "1. Update rutorrent to 3.10
-CHANGELOG += 2. Update to rtorrent 0.9.8
-CHANGELOG += 3. Update to libtorrent 0.13.8
-CHANGELOG += 4. Update to xmlrpc-c 1.51.06
-CHANGELOG += 5. Update openssl to 1.1
-CHANGELOG += 6. Embed missing binary requirements
" +CHANGELOG = 9. Update rutorrent to 3.10
HOMEPAGE = https://github.com/Novik/ruTorrent LICENSE = GPLv3 SERVICE_USER = auto -SERVICE_SETUP = src/service-setup.sh -SERVICE_WIZARD_SHARE=wizard_download_dir +SERVICE_SETUP = src/service-setup.sh +SERVICE_WIZARD_SHARE = wizard_download_dir -SERVICE_COMMAND = /usr/local/$(SPK_NAME)/bin/$(SPK_NAME)-daemon +SERVICE_COMMAND = /var/packages/${SPK_NAME}/target/bin/$(SPK_NAME)-daemon FWPORTS = src/${SPK_NAME}.sc CONF_DIR = src/conf/ WIZARDS_DIR = src/wizard/ @@ -42,8 +37,6 @@ INSTALL_DEP_SERVICES = apache-web START_DEP_SERVICES = apache-web INSTUNINST_RESTART_SERVICES = apache-web -INSTALL_PREFIX = /usr/local/$(SPK_NAME) - POST_STRIP_TARGET = rutorrent_extra_install BUSYBOX_CONFIG = usrmng nice procutils diff --git a/spk/rutorrent/src/bin/rutorrent-daemon b/spk/rutorrent/src/bin/rutorrent-daemon index 9ca771521ee..ef355b2d94e 100644 --- a/spk/rutorrent/src/bin/rutorrent-daemon +++ b/spk/rutorrent/src/bin/rutorrent-daemon @@ -3,7 +3,7 @@ # Package PACKAGE="rutorrent" -INSTALL_DIR="/usr/local/${PACKAGE}" +INSTALL_DIR="/var/packages/${SPK_NAME}/target/" export HOME=${INSTALL_DIR}/var export PATH="${INSTALL_DIR}/env/bin:${INSTALL_DIR}/bin:${INSTALL_DIR}/usr/bin:${PATH}" diff --git a/spk/rutorrent/src/service-setup.sh b/spk/rutorrent/src/service-setup.sh index b165aff5a7c..307f790a7aa 100644 --- a/spk/rutorrent/src/service-setup.sh +++ b/spk/rutorrent/src/service-setup.sh @@ -6,9 +6,8 @@ DNAME="ruTorrent" PACKAGE_NAME="com.synocommunity.packages.${PACKAGE}" # Others -INSTALL_DIR="/usr/local/${PACKAGE}" WEB_DIR="/var/services/web" -PATH="${INSTALL_DIR}/bin:${INSTALL_DIR}/usr/bin:${PATH}" +PATH="${SYNOPKG_PKGDEST}/bin:${SYNOPKG_PKGDEST}/usr/bin:${PATH}" APACHE_USER="$([ $(grep buildnumber /etc.defaults/VERSION | cut -d"\"" -f2) -ge 4418 ] && echo -n http || echo -n nobody)" BUILDNUMBER="$(/bin/get_key_value /etc.defaults/VERSION buildnumber)" @@ -21,8 +20,8 @@ PYTHON_DIR="/usr/local/python3" VIRTUALENV="${PYTHON_DIR}/bin/virtualenv" SVC_BACKGROUND=y -PID_FILE="${INSTALL_DIR}/var/rtorrent.pid" -LOG_FILE="${INSTALL_DIR}/var/rtorrent.log" +PID_FILE="${SYNOPKG_PKGDEST}/var/rtorrent.pid" +LOG_FILE="${SYNOPKG_PKGDEST}/var/rtorrent.log" SVC_WRITE_PID=y service_preinst () @@ -38,7 +37,7 @@ service_preinst () fi fi - exit 0 + return 0 } fix_shared_folders_rights() @@ -58,12 +57,12 @@ service_postinst () { # Install busybox stuff - ${INSTALL_DIR}/bin/busybox --install ${INSTALL_DIR}/bin + ${SYNOPKG_PKGDEST}/bin/busybox --install ${SYNOPKG_PKGDEST}/bin syno_user_add_to_legacy_group "${EFF_USER}" "${LEGACY_USER}" "${LEGACY_GROUP}" # Install the web interface - cp -pR ${INSTALL_DIR}/share/${PACKAGE} ${WEB_DIR} >>"${INST_LOG}" 2>&1 + cp -pR ${SYNOPKG_PKGDEST}/share/${PACKAGE} ${WEB_DIR} >>"${INST_LOG}" 2>&1 # Configure open_basedir if [ "${APACHE_USER}" == "nobody" ]; then @@ -81,13 +80,13 @@ service_postinst () sed -i -e "s|scgi_port = 5000;|scgi_port = 8050;|g" \ -e "s|topDirectory = '/';|topDirectory = '/${TOP_DIR}/';|g" \ - -e "s|tempDirectory = null;|tempDirectory = '${INSTALL_DIR}/tmp/';|g" \ - -e "s|\"python\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"python\"\1=>\2'${INSTALL_DIR}/env/bin/python3'\3,\4|g" \ - -e "s|\"pgrep\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"pgrep\"\1=>\2'${INSTALL_DIR}/bin/pgrep'\3,\4|g" \ - -e "s|\"sox\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"sox\"\1=>\2'${INSTALL_DIR}/bin/sox'\3,\4|g" \ - -e "s|\"mediainfo\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"mediainfo\"\1=>\2'${INSTALL_DIR}/bin/mediainfo'\3,\4|g" \ + -e "s|tempDirectory = null;|tempDirectory = '${SYNOPKG_PKGDEST}/tmp/';|g" \ + -e "s|\"python\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"python\"\1=>\2'${SYNOPKG_PKGDEST}/env/bin/python3'\3,\4|g" \ + -e "s|\"pgrep\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"pgrep\"\1=>\2'${SYNOPKG_PKGDEST}/bin/pgrep'\3,\4|g" \ + -e "s|\"sox\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"sox\"\1=>\2'${SYNOPKG_PKGDEST}/bin/sox'\3,\4|g" \ + -e "s|\"mediainfo\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"mediainfo\"\1=>\2'${SYNOPKG_PKGDEST}/bin/mediainfo'\3,\4|g" \ -e "s|\"stat\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"stat\"\1=>\2'/bin/stat'\3,\4|g" \ - -e "s|\"curl\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"curl\"\1=>\2'${INSTALL_DIR}/bin/curl'\3,\4|g" \ + -e "s|\"curl\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"curl\"\1=>\2'${SYNOPKG_PKGDEST}/bin/curl'\3,\4|g" \ -e "s|\"id\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"id\"\1=>\2'/bin/id'\3,\4|g" \ -e "s|\"gzip\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"gzip\"\1=>\2'/bin/gzip'\3,\4|g" \ -e "s|\"php\"\(\\s*\)=>\(\\s*\)'.*'\(\\s*\),\(\\s*\)|\"php\"\1=>\2'/bin/php'\3,\4|g" \ @@ -96,12 +95,12 @@ service_postinst () sed -i -e "s|@download_dir@|${wizard_download_dir:=/volume1/downloads}|g" \ -e "s|@max_memory@|$MAX_MEMORY|g" \ -e "s|@port_range@|${wizard_port_range:=6881-6999}|g" \ - ${INSTALL_DIR}/var/.rtorrent.rc >>"${INST_LOG}" 2>&1 + ${SYNOPKG_PKGDEST}/var/.rtorrent.rc >>"${INST_LOG}" 2>&1 if [ -d "${wizard_watch_dir}" ]; then - sed -i -e "s|@watch_dir@|${wizard_watch_dir}|g" ${INSTALL_DIR}/var/.rtorrent.rc >>"${INST_LOG}" 2>&1 + sed -i -e "s|@watch_dir@|${wizard_watch_dir}|g" ${SYNOPKG_PKGDEST}/var/.rtorrent.rc >>"${INST_LOG}" 2>&1 else - sed -i -e "/@watch_dir@/d" ${INSTALL_DIR}/var/.rtorrent.rc >>"${INST_LOG}" 2>&1 + sed -i -e "/@watch_dir@/d" ${SYNOPKG_PKGDEST}/var/.rtorrent.rc >>"${INST_LOG}" 2>&1 fi if [ "${wizard_disable_openbasedir}" == "true" ] && [ "${APACHE_USER}" == "http" ]; then @@ -123,20 +122,15 @@ service_postinst () #If python3 is available setup a virtual environment with cloudscraper if [ -f "${PYTHON_DIR}/bin/python3" ]; then # Create a Python virtualenv - ${VIRTUALENV} --system-site-packages ${INSTALL_DIR}/env >> "${INST_LOG}" 2>&1 + ${VIRTUALENV} --system-site-packages ${SYNOPKG_PKGDEST}/env >> "${INST_LOG}" 2>&1 # Install the cloudscraper wheels - ${INSTALL_DIR}/env/bin/pip install -U cloudscraper==1.2.48 >> "${INST_LOG}" 2>&1 + ${SYNOPKG_PKGDEST}/env/bin/pip install -U cloudscraper==1.2.48 >> "${INST_LOG}" 2>&1 fi - fix_shared_folders_rights "${INSTALL_DIR}/tmp" + fix_shared_folders_rights "${SYNOPKG_PKGDEST}/tmp" fix_shared_folders_rights "${WEB_DIR}/${PACKAGE}/share" - exit 0 -} - -service_preuninst () -{ - exit 0 + return 0 } service_postuninst () @@ -145,14 +139,14 @@ service_postuninst () log_step "Removing web interface" rm -fr "${WEB_DIR}/${PACKAGE}" >>"${INST_LOG}" 2>&1 - exit 0 + return 0 } service_save () { # Revision 8 introduces backward incompatible changes if [ `echo ${SYNOPKG_OLD_PKGVER} | sed -r "s/^.*-([0-9]+)$/\1/"` -le 8 ]; then - sed -i -e "s|http_cacert = .*|http_cacert = /etc/ssl/certs/ca-certificates.crt|g" ${INSTALL_DIR}/var/.rtorrent.rc + sed -i -e "s|http_cacert = .*|http_cacert = /etc/ssl/certs/ca-certificates.crt|g" ${SYNOPKG_PKGDEST}/var/.rtorrent.rc fi # Save the configuration file @@ -161,10 +155,10 @@ service_save () mv "${WEB_DIR}/${PACKAGE}/.htaccess" "${TMP_DIR}/" >>"${INST_LOG}" 2>&1 fi cp -pr ${WEB_DIR}/${PACKAGE}/share/ ${TMP_DIR}/ >>"${INST_LOG}" 2>&1 - mv ${INSTALL_DIR}/var/.rtorrent.rc ${TMP_DIR}/ >>"${INST_LOG}" 2>&1 - mv ${INSTALL_DIR}/var/.session ${TMP_DIR}/ >>"${INST_LOG}" 2>&1 + mv ${SYNOPKG_PKGDEST}/var/.rtorrent.rc ${TMP_DIR}/ >>"${INST_LOG}" 2>&1 + mv ${SYNOPKG_PKGDEST}/var/.session ${TMP_DIR}/ >>"${INST_LOG}" 2>&1 - exit 0 + return 0 } is_not_defined_external_program() @@ -196,22 +190,22 @@ service_restore () # In previous versions the python entry had nothing defined, # here we define it if, and only if, python3 is actually installed if [ -f "${PYTHON_DIR}/bin/python3" ] && `is_not_defined_external_program 'python'`; then - define_external_program 'python' "${INSTALL_DIR}/env/bin/python3" '/usr/bin/python3' + define_external_program 'python' "${SYNOPKG_PKGDEST}/env/bin/python3" '/usr/bin/python3' fi # In previous versions the pgrep entry had nothing defined if `is_not_defined_external_program 'pgrep'`; then - define_external_program 'pgrep' "${INSTALL_DIR}/bin/pgrep" '/usr/bin/pgrep' + define_external_program 'pgrep' "${SYNOPKG_PKGDEST}/bin/pgrep" '/usr/bin/pgrep' fi # In previous versions the sox entry had nothing defined if `is_not_defined_external_program 'sox'`; then - define_external_program 'sox' "${INSTALL_DIR}/bin/sox" '/usr/bin/sox' + define_external_program 'sox' "${SYNOPKG_PKGDEST}/bin/sox" '/usr/bin/sox' fi # In previous versions the mediainfo entry had nothing defined if `is_not_defined_external_program 'mediainfo'`; then - define_external_program 'mediainfo' "${INSTALL_DIR}/bin/mediainfo" '/usr/bin/mediainfo' + define_external_program 'mediainfo' "${SYNOPKG_PKGDEST}/bin/mediainfo" '/usr/bin/mediainfo' fi # In previous versions the stat entry had nothing defined @@ -228,7 +222,7 @@ service_restore () fi if `is_not_defined_external_program 'curl'`; then - define_external_program 'curl' "${INSTALL_DIR}/bin/curl" '/usr/bin/curl' + define_external_program 'curl' "${SYNOPKG_PKGDEST}/bin/curl" '/usr/bin/curl' fi if `is_not_defined_external_program 'php'`; then @@ -240,17 +234,17 @@ service_restore () cp -pr ${TMP_DIR}/share/*/ ${WEB_DIR}/${PACKAGE}/share/ >>"${INST_LOG}" 2>&1 set_syno_permissions "${WEB_DIR}/${PACKAGE}/share/" "${APACHE_USER}" - mv ${TMP_DIR}/.rtorrent.rc ${INSTALL_DIR}/var/ >>"${INST_LOG}" 2>&1 + mv ${TMP_DIR}/.rtorrent.rc ${SYNOPKG_PKGDEST}/var/ >>"${INST_LOG}" 2>&1 - if [ ! `grep 'http_cacert = ' "${INSTALL_DIR}/var/.rtorrent.rc" | wc -l` -eq 0 ]; then + if [ ! `grep 'http_cacert = ' "${SYNOPKG_PKGDEST}/var/.rtorrent.rc" | wc -l` -eq 0 ]; then # http_cacert command has been moved to network.http.cacert - sed -i -e 's|http_cacert = \(.*\)|network.http.cacert = \1|g' ${INSTALL_DIR}/var/.rtorrent.rc >>"${INST_LOG}" 2>&1 + sed -i -e 's|http_cacert = \(.*\)|network.http.cacert = \1|g' ${SYNOPKG_PKGDEST}/var/.rtorrent.rc >>"${INST_LOG}" 2>&1 fi - mv ${TMP_DIR}/.session ${INSTALL_DIR}/var/ >>"${INST_LOG}" 2>&1 + mv ${TMP_DIR}/.session ${SYNOPKG_PKGDEST}/var/ >>"${INST_LOG}" 2>&1 # Restore appropriate rights on the var directory - set_unix_permissions "${INSTALL_DIR}/var/" + set_unix_permissions "${SYNOPKG_PKGDEST}/var/" - exit 0 + return 0 } From 633538212efdd761d4168a188333a7f5a3a2ea78 Mon Sep 17 00:00:00 2001 From: Smaarn Date: Thu, 26 Nov 2020 23:30:26 +0100 Subject: [PATCH 14/19] rutorrent: fixed invalid resolution of variable not using makefile valid syntax --- spk/rutorrent/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spk/rutorrent/Makefile b/spk/rutorrent/Makefile index 6ec84b54ba8..b6211c2fec0 100644 --- a/spk/rutorrent/Makefile +++ b/spk/rutorrent/Makefile @@ -28,8 +28,8 @@ SERVICE_USER = auto SERVICE_SETUP = src/service-setup.sh SERVICE_WIZARD_SHARE = wizard_download_dir -SERVICE_COMMAND = /var/packages/${SPK_NAME}/target/bin/$(SPK_NAME)-daemon -FWPORTS = src/${SPK_NAME}.sc +SERVICE_COMMAND = /var/packages/$(SPK_NAME)/target/bin/$(SPK_NAME)-daemon +FWPORTS = src/$(SPK_NAME).sc CONF_DIR = src/conf/ WIZARDS_DIR = src/wizard/ From 466c09594d770e02bf83e7486e6df1878818917c Mon Sep 17 00:00:00 2001 From: Smaarn Date: Thu, 26 Nov 2020 23:31:38 +0100 Subject: [PATCH 15/19] Fixed syntax --- spk/rutorrent/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spk/rutorrent/Makefile b/spk/rutorrent/Makefile index b6211c2fec0..546fd86dd33 100644 --- a/spk/rutorrent/Makefile +++ b/spk/rutorrent/Makefile @@ -18,7 +18,7 @@ ADMIN_URL = /rutorrent/ RELOAD_UI = yes STARTABLE = yes DISPLAY_NAME = ruTorrent -CHANGELOG = 9. Update rutorrent to 3.10
+CHANGELOG = "9. Update rutorrent to 3.10
" HOMEPAGE = https://github.com/Novik/ruTorrent LICENSE = GPLv3 From 196d012bd6c3089445888cbc5e8e2f296b17d9b4 Mon Sep 17 00:00:00 2001 From: Smaarn Date: Thu, 26 Nov 2020 23:33:41 +0100 Subject: [PATCH 16/19] rutorrent: fixed INSTALL_DIR syntax --- spk/rutorrent/src/bin/rutorrent-daemon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spk/rutorrent/src/bin/rutorrent-daemon b/spk/rutorrent/src/bin/rutorrent-daemon index ef355b2d94e..e6ab5e685ca 100644 --- a/spk/rutorrent/src/bin/rutorrent-daemon +++ b/spk/rutorrent/src/bin/rutorrent-daemon @@ -3,7 +3,7 @@ # Package PACKAGE="rutorrent" -INSTALL_DIR="/var/packages/${SPK_NAME}/target/" +INSTALL_DIR="/var/packages/${SPK_NAME}/target" export HOME=${INSTALL_DIR}/var export PATH="${INSTALL_DIR}/env/bin:${INSTALL_DIR}/bin:${INSTALL_DIR}/usr/bin:${PATH}" From f7c5c30f09e9881592d1907f63da764b6f5c6331 Mon Sep 17 00:00:00 2001 From: Vincent Fortier Date: Sat, 5 Dec 2020 15:42:33 +0000 Subject: [PATCH 17/19] rutorrent: Renumber changelog info and add minimal update details --- spk/rutorrent/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spk/rutorrent/Makefile b/spk/rutorrent/Makefile index 546fd86dd33..0dbd3a45a51 100644 --- a/spk/rutorrent/Makefile +++ b/spk/rutorrent/Makefile @@ -18,7 +18,7 @@ ADMIN_URL = /rutorrent/ RELOAD_UI = yes STARTABLE = yes DISPLAY_NAME = ruTorrent -CHANGELOG = "9. Update rutorrent to 3.10
" +CHANGELOG = "1. Update rutorrent to 3.10
2. Update rtorrent to 0.9.8
3. Update openssl to 1.1" HOMEPAGE = https://github.com/Novik/ruTorrent LICENSE = GPLv3 From f8f68f237e7fdcc1042b710853bf42b173a37dbb Mon Sep 17 00:00:00 2001 From: Vincent Fortier Date: Sat, 5 Dec 2020 16:08:29 +0000 Subject: [PATCH 18/19] rutorrent: pre-allocate download file Pre-allocating the download file reduces the overhead when validating the hash post-download resulting in a better behavior of the NAS (reduces halt of other processes du to IO wait on large files). Functionality is compatible with xfs, ext4, btrfs and ocfs2 as such compatible with Synology filesystems. --- spk/rutorrent/src/.rtorrent.rc | 1 + 1 file changed, 1 insertion(+) diff --git a/spk/rutorrent/src/.rtorrent.rc b/spk/rutorrent/src/.rtorrent.rc index 4c3c3a085a6..d89b607e778 100755 --- a/spk/rutorrent/src/.rtorrent.rc +++ b/spk/rutorrent/src/.rtorrent.rc @@ -7,6 +7,7 @@ log.open_file = "rtorrent.log", "/usr/local/rutorrent/var/rtorrent.log" log.add_output = "warn", "rtorrent.log" network.http.cacert = /etc/ssl/certs/ca-certificates.crt system.umask.set = 002 +system.file.allocate = 1 protocol.encryption.set = require,require_RC4,allow_incoming,try_outgoing dht.mode.set = auto dht.port.set = 6881 From eb9454e137ec306cfbd3caa716ca49413358cae8 Mon Sep 17 00:00:00 2001 From: Vincent Fortier Date: Sat, 5 Dec 2020 19:53:50 +0000 Subject: [PATCH 19/19] rutorrent: Fix daemon startup script --- spk/rutorrent/src/bin/rutorrent-daemon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spk/rutorrent/src/bin/rutorrent-daemon b/spk/rutorrent/src/bin/rutorrent-daemon index e6ab5e685ca..99eae98b8d6 100644 --- a/spk/rutorrent/src/bin/rutorrent-daemon +++ b/spk/rutorrent/src/bin/rutorrent-daemon @@ -3,7 +3,7 @@ # Package PACKAGE="rutorrent" -INSTALL_DIR="/var/packages/${SPK_NAME}/target" +INSTALL_DIR="/var/packages/${PACKAGE}/target" export HOME=${INSTALL_DIR}/var export PATH="${INSTALL_DIR}/env/bin:${INSTALL_DIR}/bin:${INSTALL_DIR}/usr/bin:${PATH}"