gfjardim Posted June 18, 2015 Share Posted June 18, 2015 Hi guys, This is just a script I wrote to help the usage of unRAID notifications from inside a docker container (Transmission, in this example): #!/bin/bash UNRAID_ADDR="172.17.42.1" UNRAID_PASS="pass" # Available Channels # # 1 = notify using browser-popups only; # 2 = notify using e-mail only; # 3 = notify using browser-popups and e-mail; # 4 = notify using agents only; # 5 = notify using browser-popups and agents; # 6 = notify using e-mail and agents; # 7 = notify using browser popups, e-mail and agents; CHANNEL="2" curl -d "cmd=add" \ -d "e=Transmission: Torrent Done" \ -d "s=Download of Torrent ${TR_TORRENT_NAME} finished on $TR_TIME_LOCALTIME" \ -d "i=normal ${CHANNEL}" \ -u "root:${UNRAID_PASS}" "http://${UNRAID_ADDR}/webGui/include/Notify.php" Hope you enjoy it. Quote Link to comment
sparklyballs Posted June 18, 2015 Share Posted June 18, 2015 Hi guys, This is just a script I wrote to help the usage of unRAID notifications from inside a docker container (Transmission, in this example): #!/bin/bash UNRAID_ADDR="172.17.42.1" UNRAID_PASS="pass" # Available Channels # # 1 = notify using browser-popups only; # 2 = notify using e-mail only; # 3 = notify using browser-popups and e-mail; # 4 = notify using agents only; # 5 = notify using browser-popups and agents; # 6 = notify using e-mail and agents; # 7 = notify using browser popups, e-mail and agents; CHANNEL="2" curl -d "cmd=add" \ -d "e=Transmission: Torrent Done" \ -d "s=Download of Torrent ${TR_TORRENT_NAME} finished on $TR_TIME_LOCALTIME" \ -d "i=mormal ${CHANNEL}" \ -u "root:${UNRAID_PASS}" "http://${UNRAID_ADDR}/webGui/include/Notify.php" Hope you enjoy it. is this to go inside of a container ? Quote Link to comment
gfjardim Posted June 18, 2015 Author Share Posted June 18, 2015 is this to go inside of a container ? Yes, inside /config folder, for example. A user asked me why his ssmtp script was failing, and I wrote this for him. Quote Link to comment
sparklyballs Posted June 18, 2015 Share Posted June 18, 2015 is this to go inside of a container ? Yes, inside /config folder, for example. A user asked me why his ssmtp script was failing, and I wrote this for him. got it, so for transmission, you'd call this say torrent-done.sh , make it executable and then in the transmission webui call it as an action when torrent is completed. Quote Link to comment
gfjardim Posted June 18, 2015 Author Share Posted June 18, 2015 is this to go inside of a container ? Yes, inside /config folder, for example. A user asked me why his ssmtp script was failing, and I wrote this for him. got it, so for transmission, you'd call this say torrent-done.sh , make it executable and then in the transmission webui call it as an action when torrent is completed. Exactly that. Obviously, you can adapt it to Deluge, NZBGet etc... Quote Link to comment
sparklyballs Posted June 18, 2015 Share Posted June 18, 2015 is this to go inside of a container ? Yes, inside /config folder, for example. A user asked me why his ssmtp script was failing, and I wrote this for him. got it, so for transmission, you'd call this say torrent-done.sh , make it executable and then in the transmission webui call it as an action when torrent is completed. Exactly that. Obviously, you can adapt it to Deluge, NZBGet etc... cool, now to think of ways of using it in containers on the drawing board. would be handy if UNRAID_ADDR was an environment variable could pass directly to container bit like time info. Quote Link to comment
sparklyballs Posted June 18, 2015 Share Posted June 18, 2015 lol, just tried it from command line of a VM. -d "i=mormal ${CHANNEL}" \ everything mormal here. Quote Link to comment
gfjardim Posted June 18, 2015 Author Share Posted June 18, 2015 cool, now to think of ways of using it in containers on the drawing board. would be handy if UNRAID_ADDR was an environment variable could pass directly to container bit like time info. The problem always was those who doesn't use fixed IP address, relying only in the NETBIOS name. If the IP changes, you have to recreate all containers... Quote Link to comment
gfjardim Posted June 18, 2015 Author Share Posted June 18, 2015 lol, just tried it from command line of a VM. -d "i=mormal ${CHANNEL}" \ everything mormal here. ;D Fixed Quote Link to comment
Squid Posted June 18, 2015 Share Posted June 18, 2015 is this to go inside of a container ? Yes, inside /config folder, for example. A user asked me why his ssmtp script was failing, and I wrote this for him. got it, so for transmission, you'd call this say torrent-done.sh , make it executable and then in the transmission webui call it as an action when torrent is completed. Exactly that. Obviously, you can adapt it to Deluge, NZBGet etc... cool, now to think of ways of using it in containers on the drawing board. would be handy if UNRAID_ADDR was an environment variable could pass directly to container bit like time info. We figured that out before... Map /usr/local/emhttp/state through to the container and you can scrap var.ini for the IP address Quote Link to comment
sparklyballs Posted June 18, 2015 Share Posted June 18, 2015 is this to go inside of a container ? Yes, inside /config folder, for example. A user asked me why his ssmtp script was failing, and I wrote this for him. got it, so for transmission, you'd call this say torrent-done.sh , make it executable and then in the transmission webui call it as an action when torrent is completed. Exactly that. Obviously, you can adapt it to Deluge, NZBGet etc... cool, now to think of ways of using it in containers on the drawing board. would be handy if UNRAID_ADDR was an environment variable could pass directly to container bit like time info. We figured that out before... Map /usr/local/emhttp/state through to the container and you can scrap var.ini for the IP address blah blah blah, i can't be expected to remember stuff, i'm old. Quote Link to comment
Squid Posted June 18, 2015 Share Posted June 18, 2015 is this to go inside of a container ? Yes, inside /config folder, for example. A user asked me why his ssmtp script was failing, and I wrote this for him. got it, so for transmission, you'd call this say torrent-done.sh , make it executable and then in the transmission webui call it as an action when torrent is completed. Exactly that. Obviously, you can adapt it to Deluge, NZBGet etc... cool, now to think of ways of using it in containers on the drawing board. would be handy if UNRAID_ADDR was an environment variable could pass directly to container bit like time info. We figured that out before... Map /usr/local/emhttp/state through to the container and you can scrap var.ini for the IP address blah blah blah, i can't be expected to remember stuff, i'm old. You're like 2 minutes older than I am dude.... Quote Link to comment
dlandon Posted June 18, 2015 Share Posted June 18, 2015 Add: -d "d=Description of event" \ to give the notification a description of the event. Quote Link to comment
ikosa Posted June 18, 2015 Share Posted June 18, 2015 thanks very much for your response am i missing something, i cant get notified i replace my .sh script with the one you wrote above, write my UNRAID_ADDR and UNRAID_PASS. lines in syslog: Jun 18 15:27:14 Tower emhttp: /usr/bin/docker logs --tail=350 -f Transmission 2>&1 Jun 18 15:28:01 Tower emhttp: /usr/bin/tail -n 42 -f /var/log/syslog 2>&1 Jun 18 15:33:50 Tower emhttp: /usr/bin/tail -n 42 -f /var/log/syslog 2>&1 Jun 18 15:57:25 Tower emhttp: /usr/bin/tail -n 42 -f /var/log/syslog 2>&1 Quote Link to comment
gfjardim Posted June 18, 2015 Author Share Posted June 18, 2015 thanks very much for your response am i missing something, i cant get notified i replace my .sh script with the one you wrote above, write my UNRAID_ADDR and UNRAID_PASS. lines in syslog: Jun 18 15:27:14 Tower emhttp: /usr/bin/docker logs --tail=350 -f Transmission 2>&1 Jun 18 15:28:01 Tower emhttp: /usr/bin/tail -n 42 -f /var/log/syslog 2>&1 Jun 18 15:33:50 Tower emhttp: /usr/bin/tail -n 42 -f /var/log/syslog 2>&1 Jun 18 15:57:25 Tower emhttp: /usr/bin/tail -n 42 -f /var/log/syslog 2>&1 First thing to verify is if your script is executable. Then, verify if your Notification system is operational. Please see if this helps debugging: docker exec -ti Transmission /config/<your_script>.sh Quote Link to comment
ikosa Posted June 18, 2015 Share Posted June 18, 2015 First thing to verify is if your script is executable. Then, verify if your Notification system is operational. Please see if this helps debugging: docker exec -ti Transmission /config/<your_script>.sh Yeap, thats helps me to solve, file permissions was wrong. Thanks agaion, Thumbs up! By the way this is my way, tidier i think: CHANNEL="3" curl -d "cmd=add" \ -d "e=Transmission: Torrent Done" \ -d "s=Download finished" \ -d "d=Download of Torrent ${TR_TORRENT_NAME} finished on $TR_TIME_LOCALTIME" \ -d "i=normal ${CHANNEL}" \ -u "root:${UNRAID_PASS}" "http://${UNRAID_ADDR}/webGui/include/Notify.php" Quote Link to comment
gfjardim Posted June 18, 2015 Author Share Posted June 18, 2015 Yeap, thats helps me to solve, file permissions was wrong. Thanks agaion, Thumbs up! You're welcome. Glad it worked for you! Quote Link to comment
JoergHH Posted November 7, 2018 Share Posted November 7, 2018 I've got the following error after using the script and NO notification: Quote Nov 7 18:38:01 unraidserver root: error: /webGui/include/Notify.php: missing csrf_token Any ideas how to fix? Quote Link to comment
Squid Posted November 7, 2018 Share Posted November 7, 2018 You would have to also scrape var.ini to get the current csrf token and then append it to the url. Would probably ultimately be easier to instead add a path mapping to /usr/local/emhttp/plugins/dynamix/scripts and then execute notify.php directly as a script. Quote Link to comment
JoergHH Posted November 8, 2018 Share Posted November 8, 2018 20 hours ago, Squid said: You would have to also scrape var.ini to get the current csrf token and then append it to the url. Since I am not a programmer, I would be grateful if someone could adapt the original script accordingly. 20 hours ago, Squid said: Would probably ultimately be easier to instead add a path mapping to /usr/local/emhttp/plugins/dynamix/scripts and then execute notify.php directly as a script. Unfortunately this doesn't work because PHP doesn't exist in the docker container I use and I don't want to install it. Quote Link to comment
Squid Posted November 9, 2018 Share Posted November 9, 2018 Something like this. csrf=$(cat /var/local/emhttp/var.ini | grep csrf | sed 's/.*="\(.*\)"/\1/') curl -d "csrf_token=${csrf}" -d "cmd=add" -d "e=Transmission: Torrent Done" -d "s=Download finished" -d "d=Download of Torrent" -d "i=normal" -u "root:THEROOTPASSWORD" "http://192.168.1.61/webGui/include/Notify.php" You would need to map "/" to "/" on the container Quote Link to comment
JoergHH Posted November 9, 2018 Share Posted November 9, 2018 17 hours ago, Squid said: Something like this. csrf=$(cat /var/local/emhttp/var.ini | grep csrf | sed 's/.*="\(.*\)"/\1/') curl -d "csrf_token=${csrf}" -d "cmd=add" -d "e=Transmission: Torrent Done" -d "s=Download finished" -d "d=Download of Torrent" -d "i=normal" -u "root:THEROOTPASSWORD" "http://192.168.1.61/webGui/include/Notify.php" You would need to map "/" to "/" on the container Works! Thanks a lot! 👍 BTW: It is completely sufficient to link the host path /var/local/emhttp e.g. to the container path /var. Quote Link to comment
trurl Posted November 9, 2018 Share Posted November 9, 2018 48 minutes ago, JoergHH said: It is completely sufficient to link the host path /var/local/emhttp e.g. to the container path /var. You might want to make that mapping RO to prevent the container from possibly overwriting something in the HOST OS. Also, maybe use a subfolder of /var on the container side to prevent HOST from overwriting something in the container OS. 1 Quote Link to comment
PeteRock Posted June 10, 2020 Share Posted June 10, 2020 I would like to use this script with binhex-delugevpn. I assume I primarily need to modify the two variables ${TR_TORRENT_NAME} and ${TR_TIME_LOCALTIME}. Does anyone know what they are for binhex-delugevpn? Best, Peter Quote Link to comment
tuxbass Posted September 29, 2020 Share Posted September 29, 2020 Also interested if this still works in 2020? Tried curling different endpoints, but either receive stock nginx page, or 'file not found. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.