[Icecast] Edited: <on-connect> / <on-disconnect> not working
thomas.zumbrunnen at gmail.com
thomas.zumbrunnen at gmail.com
Wed Sep 20 15:48:55 UTC 2023
Hi
I’m using this function successful since years. I dont know how your mount point configuraiton looks like (or I cant see it)
Here’s how it works on my side.
The Mount Point definition in the XML looks like this:
<mount>
<mount-name>/mount_hi</mount-name>
<fallback-mount>/mount_hi_backup</fallback-mount>
<fallback-override>1</fallback-override>
<fallback-when-full>1</fallback-when-full>
<on-connect>/usr/local/bin/icecast/share/web/onconnect.sh</on-connect>
<on-disconnect>/usr/local/bin/icecast/share/web/disconnect.sh</on-disconnect>
</mount>
The script permission looks like this :
-rwxrwxrwx 1 icecast icecast 539 13. Sep 11:42 onconnect.sh
And finaly the script. It’s a bit different from yours, since I send alerts over two vectors (Mailing and Telegram Bot notification).
#!/bin/bash
/bin/echo "$(date '+%y-%m-%d %H:%M:%S') | CONNECTED" $1 >> /var/log/icecast/connectivity.log
/usr/local/sbin/telegram-notify --success --text "*M1 | Source CONNECTED* on *$1* check [stream](http:// <http://%3cURL%3e:8010$1.m3u> <URL>:8010$1.m3u)"
mailx -s "M1 | Source CONNECTED on $1" -r <frommailaddress> <tomailaddress> <<EOF
The Source Encoder for Mount Point $1 has connected at $(date +%H:%M:%S)
Please Check http:// <http://%3cURL%3e:8010$1.m3u> <URL>:8010$1.m3u
This check will be repeated every time the behavior of the source stream is changing
EOF
exit
This is it 😊 maybe it helps a bit.
Cheers
Tom
Von: Icecast <icecast-bounces at xiph.org> Im Auftrag von Jack Elliott
Gesendet: Mittwoch, 20. September 2023 17:24
An: Icecast streaming server user discussions <icecast at xiph.org>
Betreff: Re: [Icecast] Edited: <on-connect> / <on-disconnect> not working
Hi all,
I am still trying to debug this. Summary, I am using <on-connect> in my icecast.xml to launch an email when a source-client connects.
Here is the line in icecast.xml:
<on-connect>/home/kpovdjs/bin/email_onconnect.sh</on-connect>
The problem is that this script doesn't do anything when icecast runs it.
The script works if I run it as user kpovdjs (me). But if I su to user icecast2, it does nothing.
"email_onconnect.sh" is:
#!/bin/bash
set -x
# thatjackelliott at kpov.org <mailto:thatjackelliott at kpov.org>
printf "To: thatjackelliott at kpov.org\nFrom: kpovcomputer at gmail.com\nSubject: Remote host has connected to mountpoint $1 on the Backstream\n\n KPOV Icecast server on IcecastPi has detected a connection on the backstream." > /home/kpovdjs/bin/on_connect.txt
/usr/bin/msmtp thatjackelliott at kpov.org <mailto:thatjackelliott at kpov.org> < /home/kpovdjs/bin/on_connect.txt >/home/kpovdjs/bin/msmtp.log 2>&1
If I run it as user kpovdjs (me), it sends the email, and this is the debug output:
kpovdjs at Icecast-Pi:~/bin $ ./email_onconnect.sh
+ printf 'To: thatjackelliott at kpov.org\nFrom: kpovcomputer at gmail.com\nSubject: Remote host has connected to mountpoint on the Backstream\n\n KPOV Icecast server on IcecastPi has detected a connection on the backstream.'
+ /usr/bin/msmtp thatjackelliott at kpov.org <mailto:thatjackelliott at kpov.org>
But as user icecast2, the debug output is the same, but no email sent:
icecast2 at Icecast-Pi:/home/kpovdjs/bin$ ./email_onconnect.sh
+ printf 'To: thatjackelliott at kpov.org\nFrom: kpovcomputer at gmail.com\nSubject: Remote host has connected to mountpoint on the Backstream\n\n KPOV Icecast server on IcecastPi has detected a connection on the backstream.'
+ /usr/bin/msmtp thatjackelliott at kpov.org <mailto:thatjackelliott at kpov.org>
For debug purposes, I have rwxrwxrwx permission set from / and down to and including the script.
-rwxrwxrwx 1 kpovdjs kpovdjs 414 Sep 17 10:59 email_onconnect.sh
For further debug purposes, I made a copy of the .sh script and chowned it to user icecast2.
-rwxr-xr-x 1 icecast2 icecast 414 Sep 20 08:08 email_onconnect_usericecast2.sh
It also does not send the email when I invoke it as user icecast2. The "set -x" debug output is the same.
At this point it seems that this is not a icecast issue, per se, but some sneaky subtle weird annoying little Linux thing. However, if anyone here has an idea on how I might solve it, it would be very much appreciated.
Thank you!
===========================
Very cool, I haven't encountered the "set -x" debug flag before. However, the output isn't as interesting as I hoped:
icecast2 at Icecast-Pi:/home/kpovdjs/bin$ ./email_onconnect.sh
+ printf 'To:thatjackelliott at kpov.org\nFrom:kpovcomputer at gmail.com\nSubject: Remote host has connected to mountpoint on the Backstream\n\n KPOV Icecast server on IcecastPi has detected a connection on the backstream.'
+ /usr/bin/msmtpthatjackelliott at kpov.org <mailto:/usr/bin/msmtpthatjackelliott at kpov.org>
icecast2 at Icecast-Pi:/home/kpovdjs/bin$
Thank you!
--
Jack Elliott
Director of Classical Music Programming
High Desert Community Radio
KPOV Bend, Oregon
On 9/17/23 10:49 AM, Thomas Zumbrunnen wrote:
Hi
For debuging purpose put
set -x in the row after #!/bin/bash
and execute the script. Post the whole output here.
Cheers
Tom
Am 17. Sept. 2023, 19:42 +0200 schrieb Jack Elliott <mailto:that.jack.elliott at gmail.com> <that.jack.elliott at gmail.com>:
Hi Jordan,
Here is my script:
#!/bin/bash
#thatjackelliott at kpov.org <mailto:#thatjackelliott at kpov.org>
printf <mailto:To:thatjackelliott at kpov.org\nFrom:kpovcomputer at gmail.com\nSubject:Remotehosthasconnectedtomountpoint$1ontheBackstream\n\nKPOVIcecastserveronIcecastPihasdetectedaconnectiononthebackstream.> "To:thatjackelliott at kpov.org\nFrom:kpovcomputer at gmail.com\nSubject: Remote host has connected to mountpoint $1 on the Backstream\n\n KPOV Icecast server on IcecastPi has detected a connection on the backstream." > /home/my_username/bin/on_connect.txt
/usr/bin/msmtpthatjackelliott at kpov.org <mailto:/usr/bin/msmtpthatjackelliott at kpov.org> < /home/my_username/bin/on_connect.txt >/home/my_username/bin/msmtp.log 2>&1
This script has rwx set for everyone (for debugging).
Thank you!
--
Jack Elliott
Director of Classical Music Programming
High Desert Community Radio
KPOV Bend, Oregon
On 9/17/23 8:25 AM, Jordan Erickson wrote:
Hi Jack,
You said:
---
Okay now that I am user icecast2, let me see if the script I want the Icecast server to run <on-connect> runs, so . . .
icecast2 at icecast-Pi: $ ./email_onconnect.sh
and the prompt returns immediately, no error message, but no email received. But if I su back to my_username and try the script, it runs and an email is received.
---
This tells me that your script is not doing what it needs to do as the Icecast user. Since you're doing it outside of Icecast, it's not the <on-connect> or <on-disconnect> triggers that are failing. It would be helpful if you could paste your script (sensitive info like passwords removed) here.
Cheers,
Jordan
https://subj.am/
On 9/17/23 07:08, Jack Elliott wrote:
Hi, I posted yesterday that I was following this thread, and a nice listmember offered some suggestions to debug it. I replied directly to him, taking the thread off the list. This was not my intention, I'm bringing it back to the list to seek additional help because this issue has not been resolved.
So, summary:
The OS is Linux.
Issue: <on-connect> / <on-disconnect> does not launch a bash script that sends notification emails.
The script is located in /home/my_username/bin
The script runs from command line and sends the email with me as user. So the script is coded right. But icecast does not launch the script.
I have given rwx permission to everyone from / down to and including the script itself for debugging.
Here is the code I have in the mount definition in icecast.xml:
<on-connect>/home/my_username/bin/email_onconnect.sh</on-connect>
<on-disconnect>/home/my_username/bin/email_ondisconnect.sh</on-disconnect>
It is intended to run when a remote source client connects. The mountpoint works fine, our remote hosts routinely use it to stream their radio shows to the station to be put on the air.
So. Is it possible that by having a fallback-mount (a local mp3) in the mountpoint "blocks" <on-connect>? IOW, because there is always a source client connected—either the fallback or a remote source client—that there is no connecting event to trigger the command?
Thank you!
--
Jack Elliott
Director of Classical Music Programming
High Desert Community Radio
KPOV Bend, Oregon
_______________________________________________
Icecast mailing list
Icecast at xiph.org <mailto:Icecast at xiph.org>
http://lists.xiph.org/mailman/listinfo/icecast
_______________________________________________
Icecast mailing list
Icecast at xiph.org <mailto:Icecast at xiph.org>
http://lists.xiph.org/mailman/listinfo/icecast
_______________________________________________
Icecast mailing list
Icecast at xiph.org <mailto:Icecast at xiph.org>
http://lists.xiph.org/mailman/listinfo/icecast
--------------7bquXKfP2f2X3yn1FweF08yV
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Very cool, I haven't encountered the "set -x" debug flag before.
However, the output isn't as interesting as I hoped:<br>
</p>
<pre>icecast2 at Icecast-Pi:/home/kpovdjs/bin$ ./email_onconnect.sh
+ printf 'To: <a class="moz-txt-link-abbreviated" href= <mailto:thatjackelliott at kpov.org\nFrom> "mailto:thatjackelliott at kpov.org\nFrom">thatjackelliott at kpov.org\nFrom</a>: <a class="moz-txt-link-abbreviated" href= <mailto:kpovcomputer at gmail.com\nSubject> "mailto:kpovcomputer at gmail.com\nSubject">kpovcomputer at gmail.com\nSubject</a>: Remote host has connected to mountpoint on the Backstream\n\n KPOV Icecast server on IcecastPi has detected a connection on the backstream.'
+ /usr/bin/msmtp <a class="moz-txt-link-abbreviated" href= <mailto:thatjackelliott at kpov.org> "mailto:thatjackelliott at kpov.org">thatjackelliott at kpov.org <mailto:thatjackelliott at kpov.org> </a>
icecast2 at Icecast-Pi:/home/kpovdjs/bin$
</pre>
<p>Thank you!<br>
</p>
<pre class="moz-signature" cols="72">-- Jack Elliott
Director of Classical Music Programming
High Desert Community Radio
KPOV Bend, Oregon</pre>
<div class="moz-cite-prefix">On 9/17/23 10:49 AM, Thomas Zumbrunnen
wrote:<br>
</div>
<blockquote type="cite"
cite= <mid:192abebe-ee3a-45f8-af67-257177c9a6b3 at Spark> "mid:192abebe-ee3a-45f8-af67-257177c9a6b3 at Spark">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title></title>
<div name="messageBodySection">
<div dir="auto">Hi <br>
<br>
For debuging purpose put <br>
<span style="color:#5c2699;font-family:source-code-pro, Menlo,
Monaco, Courier New, Courier, monospace;font-size: 14px">set</span><span
style="color:#242424;background-color:#f9f9f9;font-family:source-code-pro,
Menlo, Monaco, Courier New, Courier, monospace;font-size:
14px"> -x in the row </span>after <span
style="color:#643820;font-family:source-code-pro, Menlo,
Monaco, Courier New, Courier, monospace;font-size: 14px">#!/bin/bash</span><span
style="font-size: 14px"><br>
</span><span style="color:#643820;font-family:source-code-pro,
Menlo, Monaco, Courier New, Courier, monospace;font-size:
14px">and execute the script. Post the whole output here.</span><span
style="font-size: 14px"><br>
</span><span style="font-size: 14px"><br>
</span><span style="color:#643820;font-family:source-code-pro,
Menlo, Monaco, Courier New, Courier, monospace;font-size:
14px">Cheers</span><span style="font-size: 14px"><br>
</span><span style="color:#643820;font-family:source-code-pro,
Menlo, Monaco, Courier New, Courier, monospace;font-size:
14px">Tom</span></div>
</div>
<div name="messageReplySection">Am 17. Sept. 2023, 19:42 +0200
schrieb Jack Elliott <a class="moz-txt-link-rfc2396E" href= <mailto:that.jack.elliott at gmail.com> "mailto:that.jack.elliott at gmail.com"><that.jack.elliott at gmail.com></a>:<br>
<blockquote type="cite" style="border-left-color: grey;
border-left-width: thin; border-left-style: solid; margin: 5px
5px;padding-left: 10px;">
<p>Hi Jordan,<br>
</p>
<p>Here is my script:</p>
<pre>#!/bin/bash
# <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href= <mailto:thatjackelliott at kpov.org> "mailto:thatjackelliott at kpov.org" moz-do-not-send="true">thatjackelliott at kpov.org <mailto:thatjackelliott at kpov.org> </a>
printf "To: <a class="moz-txt-link-abbreviated" href= <mailto:thatjackelliott at kpov.org/nFrom> "mailto:thatjackelliott at kpov.org/nFrom" moz-do-not-send="true">thatjackelliott at kpov.org\nFrom</a>: <a class="moz-txt-link-abbreviated" href= <mailto:kpovcomputer at gmail.com/nSubject> "mailto:kpovcomputer at gmail.com/nSubject" moz-do-not-send="true">kpovcomputer at gmail.com\nSubject</a>: Remote host has connected to mountpoint $1 on the Backstream\n\n KPOV Icecast server on IcecastPi has detected a connection on the backstream." > /home/my_username/bin/on_connect.txt
/usr/bin/msmtp <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href= <mailto:thatjackelliott at kpov.org> "mailto:thatjackelliott at kpov.org" moz-do-not-send="true">thatjackelliott at kpov.org <mailto:thatjackelliott at kpov.org> </a> < /home/my_username/bin/on_connect.txt >/home/my_username/bin/msmtp.log 2>&1
</pre>
<p>This script has rwx set for everyone (for debugging).<br>
</p>
<p>Thank you!<br>
</p>
<pre class="moz-signature" cols="72">-- Jack Elliott
Director of Classical Music Programming
High Desert Community Radio
KPOV Bend, Oregon</pre>
<div class="moz-cite-prefix">On 9/17/23 8:25 AM, Jordan
Erickson wrote:<br>
</div>
<blockquote type="cite"
cite= <mid:60932c58-d542-ed99-a719-8870da6dda65 at subj.am> "mid:60932c58-d542-ed99-a719-8870da6dda65 at subj.am">
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
Hi Jack,<br>
<br>
You said:<br>
<br>
---<br>
Okay now that I am user icecast2, let me see if the script I
want the Icecast server to run <on-connect> runs, so .
. .<br>
<pre>icecast2 at icecast-Pi: $ ./email_onconnect.sh</pre>
<p>and the prompt returns immediately, no error message, but
no email received. But if I su back to my_username and try
the script, it runs and an email is received.<br>
</p>
---<br>
<br>
This tells me that your script is not doing what it needs to
do as the Icecast user. Since you're doing it outside of
Icecast, it's not the <on-connect> or
<on-disconnect> triggers that are failing. It would be
helpful if you could paste your script (sensitive info like
passwords removed) here.<br>
<br>
<br>
Cheers,<br>
Jordan<br>
<pre class="moz-signature" cols="72"><a class="moz-txt-link-freetext" href= <https://subj.am/> "https://subj.am/" moz-do-not-send="true">https://subj.am/</a>
</pre>
<div class="moz-cite-prefix">On 9/17/23 07:08, Jack Elliott
wrote:<br>
</div>
<blockquote type="cite"
cite= <mid:68d4dadd-108f-933a-fad2-8b14e30772d7 at kpov.org> "mid:68d4dadd-108f-933a-fad2-8b14e30772d7 at kpov.org">
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<p>Hi, I posted yesterday that I was following this
thread, and a nice listmember offered some suggestions
to debug it. I replied directly to him, taking the
thread off the list. This was not my intention, I'm
bringing it back to the list to seek additional help
because this issue has not been resolved.<br>
</p>
<p>So, summary:</p>
<p>The OS is Linux.<br>
</p>
<p>Issue: <on-connect> / <on-disconnect> does
not launch a bash script that sends notification emails.<br>
</p>
<p>The script is located in /home/my_username/bin</p>
<p>The script runs from command line and sends the email
with me as user. So the script is coded right. But
icecast does not launch the script.</p>
<p>I have given rwx permission to everyone from / down to
and including the script itself for debugging.<br>
</p>
<p>Here is the code I have in the mount definition in
icecast.xml:<br>
</p>
<pre> <on-connect>/home/my_username/bin/email_onconnect.sh</on-connect>
<on-disconnect>/home/my_username/bin/email_ondisconnect.sh</on-disconnect>
</pre>
<p>It is intended to run when a remote source client
connects. The mountpoint works fine, our remote hosts
routinely use it to stream their radio shows to the
station to be put on the air.<br>
</p>
<p>So. Is it possible that by having a fallback-mount (a
local mp3) in the mountpoint "blocks"
<on-connect>? IOW, because there is always a
source client connected—either the fallback or a remote
source client—that there is no connecting event to
trigger the command?</p>
<p>Thank you!<br>
</p>
<pre class="moz-signature" cols="72">-- Jack Elliott
Director of Classical Music Programming
High Desert Community Radio
KPOV Bend, Oregon</pre>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Icecast mailing list
<a class="moz-txt-link-abbreviated moz-txt-link-freetext" href= <mailto:Icecast at xiph.org> "mailto:Icecast at xiph.org" moz-do-not-send="true">Icecast at xiph.org <mailto:Icecast at xiph.org> </a>
<a class="moz-txt-link-freetext" href= <http://lists.xiph.org/mailman/listinfo/icecast> "http://lists.xiph.org/mailman/listinfo/icecast" moz-do-not-send="true">http://lists.xiph.org/mailman/listinfo/icecast</a>
</pre>
</blockquote>
<br>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Icecast mailing list
<a class="moz-txt-link-abbreviated moz-txt-link-freetext" href= <mailto:Icecast at xiph.org> "mailto:Icecast at xiph.org" moz-do-not-send="true">Icecast at xiph.org <mailto:Icecast at xiph.org> </a>
<a class="moz-txt-link-freetext" href= <http://lists.xiph.org/mailman/listinfo/icecast> "http://lists.xiph.org/mailman/listinfo/icecast" moz-do-not-send="true">http://lists.xiph.org/mailman/listinfo/icecast</a>
</pre>
</blockquote>
_______________________________________________<br>
Icecast mailing list<br>
<a class="moz-txt-link-abbreviated" href= <mailto:Icecast at xiph.org> "mailto:Icecast at xiph.org">Icecast at xiph.org <mailto:Icecast at xiph.org> </a><br>
<a class="moz-txt-link-freetext" href= <http://lists.xiph.org/mailman/listinfo/icecast> "http://lists.xiph.org/mailman/listinfo/icecast">http://lists.xiph.org/mailman/listinfo/icecast</a><br>
</blockquote>
</div>
</blockquote>
</body>
</html>
--------------7bquXKfP2f2X3yn1FweF08yV--
>From Content-Type: multipart/alternative;
boundary="------------cwXTpa91
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xiph.org/pipermail/icecast/attachments/20230920/5ccd750f/attachment.htm>
More information about the Icecast
mailing list