Created
January 4, 2022 16:04
-
-
Save dmcallejo/57f104d9241013930e08432b5c9206a4 to your computer and use it in GitHub Desktop.
Add magnet files from watch dir to transmission (with authentication, for linuxserver.io docker image)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Filename: grab-magnets-from-watchdir.custom-cont-init-script | |
# Save this file in /config/custom-cont-init.d/ | |
# This way it will run everytime the container is created and will add the crontab entry and transmission authentication | |
# Save env files to get authentication | |
printenv | sed 's/^\(.*\)$/export \1/g' > /root/container.env | |
# Add entry to crontab, runs every minute | |
echo '* * * * * . /root/container.env; /config/grab-magnets-from-watchdir.sh' >> /etc/crontabs/root |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Filename: grab-magnets-from-watchdir.sh | |
# Save this file into your /config directory | |
tr=$(which transmission-remote) # set path for transmission-remote binary | |
if [ -f /watch/*.magnet ] | |
then | |
for t in /watch/*.magnet; do | |
echo "Adding "$t"" | |
m=$(cat "$t") # get contents of magnet file | |
$tr -n "$USER:$PASS" --add $m && \ | |
/bin/mv "$t" "$t".added # add to transmission and rename the magnet file | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment