Jump to content

[HOWTO] Use unRAID's notification system inside containers


Recommended Posts

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.

Link to comment

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 ?

Link to comment

 

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.

Link to comment

 

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...

Link to comment

 

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.

Link to comment

 

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...

Link to comment

 

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
Link to comment

 

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.

Link to comment

 

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....  ;)
Link to comment

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

Link to comment

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

Link to comment

 

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"

Link to comment
  • 3 years later...
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.

Link to comment

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

Link to comment
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.

Link to comment
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.

  • Like 1
Link to comment
  • 1 year later...
  • 3 months later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...