diff options
author | David Woodfall <dave@dawoodfall.net> | 2015-11-25 18:12:26 +0700 |
---|---|---|
committer | Willy Sudiarto Raharjo <willysr@slackbuilds.org> | 2015-11-28 07:25:59 +0700 |
commit | 930330f99242481c2b07ed7d549caca9efe47dee (patch) | |
tree | 330417f2223838527ceab4031f6db068a6b7f66e /network | |
parent | c70dba9b054066bab035025403a1ba97c9d2439f (diff) | |
download | slackbuilds-930330f99242481c2b07ed7d549caca9efe47dee.tar.gz |
network/qbittorrent: Added qbittorrent-nox + an rc init script.
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'network')
-rw-r--r-- | network/qbittorrent/README.nox | 17 | ||||
-rw-r--r-- | network/qbittorrent/doinst.sh | 15 | ||||
-rw-r--r-- | network/qbittorrent/qbittorrent.SlackBuild | 17 | ||||
-rw-r--r-- | network/qbittorrent/rc.qbittorrent-nox.new | 82 |
4 files changed, 130 insertions, 1 deletions
diff --git a/network/qbittorrent/README.nox b/network/qbittorrent/README.nox new file mode 100644 index 0000000000..15193a85ab --- /dev/null +++ b/network/qbittorrent/README.nox @@ -0,0 +1,17 @@ +An rc init script is provided and has the following features: + +Runs qbittorrent-nox webui under user who started the script. + +Usage: +/etc/rc.d/rc.qbittorrent-nox start [PORT]|stop|restart [PORT]|status +Port defaults to 8080 if not provided. + +To run this script from rc.local you must run it as a non-root user. + +Example: +/bin/su - david -c /etc/rc.d/rc.qbittorrent-nox start 9000 + +Program output is sent to /tmp/qbittorrent-nox-$USER + +The status command can be run as root, in which case you should see +all process of qbittorrent-nox, otherwise you will just see $USER's. diff --git a/network/qbittorrent/doinst.sh b/network/qbittorrent/doinst.sh index 3e5691a052..48fc6d14ef 100644 --- a/network/qbittorrent/doinst.sh +++ b/network/qbittorrent/doinst.sh @@ -1,3 +1,18 @@ +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + # If there's no config file by that name, mv it over: + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then + # toss the redundant copy + rm $NEW + fi + # Otherwise, we leave the .new copy for the admin to consider... +} + +config etc/rc.d/rc.qbittorrent-nox.new + if [ -x /usr/bin/update-desktop-database ]; then /usr/bin/update-desktop-database -q usr/share/applications >/dev/null 2>&1 fi diff --git a/network/qbittorrent/qbittorrent.SlackBuild b/network/qbittorrent/qbittorrent.SlackBuild index 72ed69b606..73a4f56275 100644 --- a/network/qbittorrent/qbittorrent.SlackBuild +++ b/network/qbittorrent/qbittorrent.SlackBuild @@ -24,7 +24,7 @@ PRGNAM=qbittorrent VERSION=${VERSION:-3.1.12} -BUILD=${BUILD:-1} +BUILD=${BUILD:-2} TAG=${TAG:-_SBo} if [ -z "$ARCH" ]; then @@ -77,16 +77,31 @@ CXXFLAGS="$SLKCFLAGS" \ make make install INSTALL_ROOT=$PKG +make clean + +CFLAGS="$SLKCFLAGS" \ +CXXFLAGS="$SLKCFLAGS" \ +./configure \ + --prefix=/usr \ + --disable-gui + +make +mv src/qbittorrent-nox $PKG/usr/bin find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true + mv $PKG/usr/share/man $PKG/usr find $PKG/usr/man -type f -exec gzip -9 {} \; for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done +mkdir -p $PKG/etc/rc.d +cp $CWD/rc.qbittorrent-nox.new $PKG/etc/rc.d/. + mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION cp -a AUTHORS Changelog NEWS TODO COPYING INSTALL README.md \ + $CWD/README.nox \ $PKG/usr/doc/$PRGNAM-$VERSION cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild diff --git a/network/qbittorrent/rc.qbittorrent-nox.new b/network/qbittorrent/rc.qbittorrent-nox.new new file mode 100644 index 0000000000..f2c3c6218b --- /dev/null +++ b/network/qbittorrent/rc.qbittorrent-nox.new @@ -0,0 +1,82 @@ +#!/bin/sh + +# /etc/rc.d/rc.qbittorrent-nox +# Runs qbittorrent webui under user who started the script. +# Usage: /etc/rc.d/rc.qbittorrent-nox start <PORT>|stop|restart <PORT>|status +# Port defaults to 8080 if not provided. +# +# To run this script from rc.local you must run it as a non-root user. +# +# Example: +# /bin/su - david -c /etc/rc.d/rc.qbittorrent-nox start 9000 +# Program output is sent to /tmp/qbittorrent-nox-$USER + +# First some checks to see what's what. + +if [ "$USER" = "root" ] && [ "$1" = "start" ]; then + echo "Do not start the daemon as root." >/dev/stderr + exit 1 +fi + + +if [ -n "$2" ]; then + UIPORT="$2" +else + UIPORT="8080" +fi + +LOG="/tmp/qbittorrent-nox-$USER" +APP="/usr/bin/qbittorrent-nox" + +do_start() +{ + if [ -n "$(/bin/netstat -nta | awk '{print $4}' \ + | cut -d: -f2 | grep $UIPORT | grep 0.0.0.0)" ]; then + + echo "Port $UIPORT is already in use." >/dev/stderr + exit 1 + fi + + $APP --webui-port=$UIPORT 1>$LOG 2>&1 & +} + +do_stop() +{ + PID="$(pgrep -u $USER qbittorrent-nox)" + + if [ -n "$PID" ]; then + echo "Killing PID $PID" + kill $PID + else + echo "No process found." >/dev/stderr + fi +} + +do_status() +{ + echo "Local Address Foreign Address State PID/Program name" + /bin/netstat -pntl 2>&1 | grep qbittorrent-n \ + | awk '{print $4 " " $5 " " $6 " " $7}' +} + +case "$1" in + 'start') + do_start + ;; + + 'stop') + do_stop + ;; + 'restart') + do_stop + sleep 1 + do_start + ;; + 'status') + do_status + ;; + *) + echo "Usage: $0 {start <PORT>|stop|restart <PORT>|status}" >/dev/stderr + exit 1 + ;; +esac |