summaryrefslogtreecommitdiff
path: root/doc/tips/transmission_integration/transmission_integration.sh
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-01-05 16:12:07 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-01-05 16:12:07 -0400
commit68638f359a64b377d77677f60a8c49fe20bb8670 (patch)
treec958fa2deda03f001ce7700a307853260eada4e8 /doc/tips/transmission_integration/transmission_integration.sh
parent6f915ca947097bce44b2193d1dbaf4055ebd3169 (diff)
split docs and script
Diffstat (limited to 'doc/tips/transmission_integration/transmission_integration.sh')
-rw-r--r--doc/tips/transmission_integration/transmission_integration.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/doc/tips/transmission_integration/transmission_integration.sh b/doc/tips/transmission_integration/transmission_integration.sh
new file mode 100644
index 000000000..8b4dcd4d0
--- /dev/null
+++ b/doc/tips/transmission_integration/transmission_integration.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+
+set -e
+
+# environment from transmission:
+# TR_APP_VERSION
+# TR_TIME_LOCALTIME
+# TR_TORRENT_DIR
+# TR_TORRENT_HASH
+# TR_TORRENT_ID
+# TR_TORRENT_NAME
+# source: https://trac.transmissionbt.com/wiki/Scripts
+
+if [ -z "$TR_APP_VERSION" ]; then
+ echo "missing expected $TR_APP_VERSION from Transmission"
+ exit 1
+fi
+
+message="transmission adding torrent '$TR_TORRENT_NAME'
+
+TR_APP_VERSION: $TR_APP_VERSION
+TR_TIME_LOCALTIME: $TR_TIME_LOCALTIME
+TR_TORRENT_DIR: $TR_TORRENT_DIR
+TR_TORRENT_HASH: $TR_TORRENT_HASH
+TR_TORRENT_ID: $TR_TORRENT_ID
+TR_TORRENT_NAME: $TR_TORRENT_NAME
+"
+
+# heredocs preserve newlines
+cat <<EOF
+$message
+EOF
+# add the actual torrent and commit whatever's left to commit
+cd "$TR_TORRENT_DIR"
+git annex add "$TR_TORRENT_NAME" && \
+git commit -F- <<EOF
+$message
+EOF