summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/serverscripts/dladd41
-rwxr-xr-xbin/serverscripts/dlinfo3
-rwxr-xr-xstowcmds.sh2
3 files changed, 45 insertions, 1 deletions
diff --git a/bin/serverscripts/dladd b/bin/serverscripts/dladd
new file mode 100755
index 0000000..457e44e
--- /dev/null
+++ b/bin/serverscripts/dladd
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# Adds a torrent to deluge container
+# Assumes there is a config folder where auth and torrents/ are located
+
+DLPATH="/srv/deluge/config"
+
+mkdir -p /tmp/dladd
+LOG="/tmp/dladd/$(date +"%Y-%m-%d_%H-%M-%S").log"
+
+# Check for errors and input type
+if [ $# -eq 0 ]
+then
+ echo "No file name provided. Usage: $0 <file>" >&2
+ exit 1
+elif [ -f "$1" ]
+then
+ magnet=0
+elif echo "$1 " | grep -q "magnet:?xt=urn:btih:[a-zA-Z0-9]*"
+then
+ magnet=1
+else
+ echo "File '$1' not found." >&2
+ exit 1
+fi
+
+password="$(cut -f2 -d: "$DLPATH/auth")"
+if [ "$magnet" -eq 0 ]
+then
+ echo "Adding file."
+ file="$(date +"%Y-%m-%d_%H-%M-%S").torrent"
+ cp "$1" "$DLPATH/torrents/$file"
+ docker exec -i deluge deluge-console "connect 127.0.0.1 localclient $password; add /config/torrents/$file" 2>/dev/null |
+ tail -n 2
+else
+ echo "Adding magnet."
+ link=$(echo -n "$1" | tr -d "'\"")
+ docker exec -i deluge deluge-console "connect 127.0.0.1 localclient $password; add $link" 2>/dev/null |
+ tail -n 2
+fi
+rm -d /tmp/dladd 2>/dev/null
diff --git a/bin/serverscripts/dlinfo b/bin/serverscripts/dlinfo
new file mode 100755
index 0000000..83471ec
--- /dev/null
+++ b/bin/serverscripts/dlinfo
@@ -0,0 +1,3 @@
+#!/bin/sh
+password="$(cut -f 2 -d ':' /srv/deluge/config/auth)"
+docker exec -i deluge deluge-console "connect 127.0.0.1 localclient $password; info"
diff --git a/stowcmds.sh b/stowcmds.sh
index 974e84f..4b6eb13 100755
--- a/stowcmds.sh
+++ b/stowcmds.sh
@@ -28,7 +28,7 @@ case "$MACH" in
;;
"server" | "s")
mkdir -p "$HOME/bin"
- stow -d bin/ -t "$HOME/bin" -R common
+ stow -d bin/ -t "$HOME/bin" -R common serverscripts
mkdir -p "$HOME/.config"
stow -d config/ -t "$HOME/.config" -R essentials common
stow -d config/ -t "$HOME/" -R home