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/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/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..c06b5ccbd7a
--- /dev/null
+++ b/cross/sox/PLIST
@@ -0,0 +1,7 @@
+bin:bin/play
+bin:bin/rec
+bin:bin/sox
+bin:bin/soxi
+lnk:lib/libsox.so
+lnk:lib/libsox.so.3
+lib:lib/libsox.so.3.0.0
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
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 6cf84a45c89..0dbd3a45a51 100644
--- a/spk/rutorrent/Makefile
+++ b/spk/rutorrent/Makefile
@@ -1,28 +1,35 @@
SPK_NAME = rutorrent
SPK_VERS = 3.10
-SPK_REV = 3
+SPK_REV = 9
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
-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
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"
-BETA = 1
+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
-INSTALLER_SCRIPT = src/installer.sh
-SSS_SCRIPT = src/dsm-control.sh
-FWPORTS = src/${SPK_NAME}.sc
+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
CONF_DIR = src/conf/
WIZARDS_DIR = src/wizard/
@@ -30,20 +37,22 @@ 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 daemon nice
+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
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..d89b607e778 100755
--- a/spk/rutorrent/src/.rtorrent.rc
+++ b/spk/rutorrent/src/.rtorrent.rc
@@ -1,10 +1,15 @@
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"
-http_cacert = /etc/ssl/certs/ca-certificates.crt
+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
+protocol.pex.set= yes
port_range = @port_range@
diff --git a/spk/rutorrent/src/bin/rutorrent-daemon b/spk/rutorrent/src/bin/rutorrent-daemon
new file mode 100644
index 00000000000..99eae98b8d6
--- /dev/null
+++ b/spk/rutorrent/src/bin/rutorrent-daemon
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# Package
+PACKAGE="rutorrent"
+
+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}"
+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/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
deleted file mode 100644
index adb91e83069..00000000000
--- a/spk/rutorrent/src/dsm-control.sh
+++ /dev/null
@@ -1,82 +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 ()
-{
- 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}
-}
-
-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/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..307f790a7aa
--- /dev/null
+++ b/spk/rutorrent/src/service-setup.sh
@@ -0,0 +1,250 @@
+#!/bin/sh
+
+# Package
+PACKAGE="rutorrent"
+DNAME="ruTorrent"
+PACKAGE_NAME="com.synocommunity.packages.${PACKAGE}"
+
+# Others
+WEB_DIR="/var/services/web"
+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)"
+
+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"
+
+SVC_BACKGROUND=y
+PID_FILE="${SYNOPKG_PKGDEST}/var/rtorrent.pid"
+LOG_FILE="${SYNOPKG_PKGDEST}/var/rtorrent.log"
+SVC_WRITE_PID=y
+
+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
+
+ return 0
+}
+
+fix_shared_folders_rights()
+{
+ local folder=$1
+ echo "Fixing shared folder rights for ${folder}" >> "${INST_LOG}"
+ 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
+}
+
+service_postinst ()
+{
+
+ # Install busybox stuff
+ ${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 ${SYNOPKG_PKGDEST}/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 = '${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'${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" \
+ ${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" \
+ ${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" ${SYNOPKG_PKGDEST}/var/.rtorrent.rc >>"${INST_LOG}" 2>&1
+ else
+ 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
+ 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 ${SYNOPKG_PKGDEST}/env >> "${INST_LOG}" 2>&1
+ # Install the cloudscraper wheels
+ ${SYNOPKG_PKGDEST}/env/bin/pip install -U cloudscraper==1.2.48 >> "${INST_LOG}" 2>&1
+ fi
+
+ fix_shared_folders_rights "${SYNOPKG_PKGDEST}/tmp"
+ fix_shared_folders_rights "${WEB_DIR}/${PACKAGE}/share"
+
+ return 0
+}
+
+service_postuninst ()
+{
+ # Remove the web interface
+ log_step "Removing web interface"
+ rm -fr "${WEB_DIR}/${PACKAGE}" >>"${INST_LOG}" 2>&1
+
+ 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" ${SYNOPKG_PKGDEST}/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 ${SYNOPKG_PKGDEST}/var/.rtorrent.rc ${TMP_DIR}/ >>"${INST_LOG}" 2>&1
+ mv ${SYNOPKG_PKGDEST}/var/.session ${TMP_DIR}/ >>"${INST_LOG}" 2>&1
+
+ return 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' "${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' "${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' "${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' "${SYNOPKG_PKGDEST}/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' "${SYNOPKG_PKGDEST}/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 ${SYNOPKG_PKGDEST}/var/ >>"${INST_LOG}" 2>&1
+
+ 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' ${SYNOPKG_PKGDEST}/var/.rtorrent.rc >>"${INST_LOG}" 2>&1
+ fi
+
+ mv ${TMP_DIR}/.session ${SYNOPKG_PKGDEST}/var/ >>"${INST_LOG}" 2>&1
+
+ # Restore appropriate rights on the var directory
+ set_unix_permissions "${SYNOPKG_PKGDEST}/var/"
+
+ return 0
+}