Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help wanted] ruTorrent - Generic Service approach #3175

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions spk/rutorrent/Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
SPK_NAME = rutorrent
SPK_VERS = 3.8
SPK_REV = 1
SPK_REV = 9
SPK_ICON = src/rutorrent.png
DSM_UI_DIR = app

DEPENDS = cross/busybox cross/curl cross/procps-ng cross/mediainfo cross/rtorrent cross/rutorrent cross/screen cross/unzip
DEPENDS = cross/busybox cross/curl cross/procps-ng cross/mediainfo
DEPENDS += cross/rtorrent cross/rutorrent cross/screen cross/unzip

MAINTAINER = moneytoo
# Changes to Web Station user were applied in 5.0
REQUIRED_DSM = 5.1

MAINTAINER = Safihre
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.8"
BETA = 1
CHANGELOG = "Use DSM 5+6 generic service approach for correct permissions management."

HOMEPAGE = https://github.com/Novik/ruTorrent
LICENSE = GPLv3

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

SERVICE_USER = auto
SERVICE_SETUP = src/service-setup.sh

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
Expand Down
3 changes: 2 additions & 1 deletion spk/rutorrent/src/app/config
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"port": "80",
"url": "/rutorrent",
"allUsers": true,
"grantPrivilege": "local"
"grantPrivilege": "all",
"advanceGrantPrivilege": true
}
}
}
31 changes: 0 additions & 31 deletions spk/rutorrent/src/conf/privilege

This file was deleted.

53 changes: 29 additions & 24 deletions spk/rutorrent/src/dsm-control.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
#!/bin/sh

# Package
PACKAGE="rutorrent"
DNAME="ruTorrent"
# Source package specific variable and functions
SVC_SETUP=`dirname $0`"/service-setup"
if [ -r "${SVC_SETUP}" ]; then
. "${SVC_SETUP}"
fi

# 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"
# Default display name
DNAME="${SYNOPKG_PKGNAME}"

SC_USER="sc-rutorrent"
LEGACY_USER="rutorrent"
USER="$([ "${BUILDNUMBER}" -ge "7321" ] && echo -n ${SC_USER} || echo -n ${LEGACY_USER})"
# Others
RTORRENT="${SYNOPKG_PKGDEST}/bin/rtorrent"
PID_FILE="${SYNOPKG_PKGDEST}/var/rtorrent.pid"
LOG_FILE="${SYNOPKG_PKGDEST}/var/rtorrent.log"


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}
export HOME=${SYNOPKG_PKGDEST}/var
start-stop-daemon -S -q -m -b -N 10 -x screen -p ${PID_FILE} -- -D -m ${RTORRENT}
}

stop_daemon ()
{
start-stop-daemon -K -q -u ${USER} -p ${PID_FILE}
start-stop-daemon -K -q -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}
start-stop-daemon -K -q -t -p ${PID_FILE}
}

wait_for_status ()
Expand All @@ -50,31 +48,38 @@ wait_for_status ()
case $1 in
start)
if daemon_status; then
echo ${DNAME} is already running
echo "${DNAME} is already running"
exit 0
else
echo Starting ${DNAME} ...
echo "Starting ${DNAME} ..."
start_daemon
exit $?
fi
;;
stop)
if daemon_status; then
echo Stopping ${DNAME} ...
echo "Stopping ${DNAME} ..."
stop_daemon
exit $?
else
echo ${DNAME} is not running
echo "${DNAME} is not running"
exit 0
fi
;;
status)
if daemon_status; then
echo ${DNAME} is running
echo "${DNAME} is running"
exit 0
else
echo ${DNAME} is not running
echo "${DNAME} is not running"
exit 1
fi
;;
log)
echo ${LOG_FILE}
if [ -n "${LOG_FILE}" -a -r "${LOG_FILE}" ]; then
echo "${LOG_FILE}"
fi
exit 0
;;
*)
exit 1
Expand Down
Loading