<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Thank you, Jordan.</p>
<p>It now works. For the next icecast user who needs to get an
<on-connect> script to run, I am leaving this here. <br>
</p>
<p>Okay, icecast2 is not human user, so no /home directory for it. <br>
</p>
<p>/etc/passwd tells me:</p>
<pre>icecast2:x:112:119::/usr/share/icecast2:/bin/false</pre>
<p>So I copy the working (for my user kpovdjs)
/home/kpovdjs/.msmtprc file to /usr/share/icecast2 , and change
owner to user icecast2<br>
</p>
<pre>kpovdjs@Icecast-Pi:~ $ ls -la /usr/share/icecast2
total 20
drwxr-xr-x 4 root root 4096 Sep 20 11:31 .
drwxr-xr-x 205 root root 4096 Jul 13 2022 ..
drwxr-xr-x 2 root root 4096 Apr 22 2017 admin
-rw-rw-rw- 1 icecast2 root 332 Sep 20 11:31 .msmtprc
drwxr-xr-x 3 kpovdjs root 4096 May 12 2017 web
</pre>
<p>So, <br>
</p>
<pre>icecast2@Icecast-Pi:/home/kpovdjs$ echo "hello there username." | msmtp -a gmail <a class="moz-txt-link-abbreviated" href="mailto:thatjackelliott@kpov.org">thatjackelliott@kpov.org</a>
msmtp: /usr/share/icecast2/.msmtprc: must have no more than user read/write permissions</pre>
<p>But now msmtp finds the rc file! So chmod 600 to .msmtprc to get
<br>
</p>
<pre>-rw------- 1 icecast2 root 332 Sep 20 11:31 .msmtprc</pre>
<p>and try again . . . and . . . it works! email received. One minor
permissions issue, <br>
</p>
<pre>msmtp: cannot log to /home/kpovdjs/bin/msmtp_logfile.log: cannot open: Permission denied</pre>
<p>So as owner of the logfile.log:</p>
<pre>chmod 666 /home/kpovdjs/bin/msmtp_logfile.log</pre>
<p>And all is good. <br>
</p>
<p>Many thanks to you and the others who helped me debug this
routine. Have a good day!<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/20/23 11:18 AM, Jordan Erickson
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:29b3f775-60c6-7178-f159-353448546f3b@subj.am">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
You need to put that msmtp config file in Icecast user's
configured home directory. Look in /etc/passwd for that or just
'cd ~' as Icecast user. It's likely not /home/icecast2 if you had
to create it yourself manually.<br>
<br>
<br>
Cheers,<br>
Jordan Erickson<br>
<br>
<pre class="moz-signature" cols="72"><a class="moz-txt-link-freetext" href="https://subj.am/" moz-do-not-send="true">https://subj.am/</a></pre>
<div class="moz-cite-prefix">On 9/20/23 11:11, Jack Elliott wrote:<br>
</div>
<blockquote type="cite"
cite="mid:07e86cdd-66f1-308c-eea8-eb133c744205@kpov.org">
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<p>Hi Jordan, thank you for the suggestion to try msmtp directly
as user icecast2</p>
<p>First I try as user kpovdjs (me):<br>
</p>
<pre>kpovdjs@Icecast-Pi:~/bin $ echo "hello there username." | msmtp -a gmail <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:thatjackelliott@kpov.org" moz-do-not-send="true">thatjackelliott@kpov.org</a></pre>
<p>This does send the email. <br>
</p>
<p>Now su to user icecast2</p>
<pre>icecast2@Icecast-Pi:/home/kpovdjs/bin$ echo "hello there username." | msmtp -a gmail <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:thatjackelliott@kpov.org" moz-do-not-send="true">thatjackelliott@kpov.org</a>
msmtp: account gmail not found: no configuration file available</pre>
<p>Interesting. For user kpovdjs, msmtp finds account
information in /home/kpovdjs/.msmtprc<br>
</p>
<p>But as user icecast2, there is no .msmtprc file in
/home/icecast2 <br>
</p>
<p>In fact, there is no icecast2 folder in /home</p>
<p>So I create /home/icecast2</p>
<p>I copy my user .msmtprc to /home/icecast2</p>
<pre>icecast2@Icecast-Pi:/home/kpovdjs$ ls -la /home/icecast2
total 12
drwxr-xr-x 2 icecast2 root 4096 Sep 20 10:57 .
drwxr-xr-x 5 root root 4096 Sep 20 10:51 ..
-rw-r--r-- 1 icecast2 root 332 Sep 20 10:57 .msmtprc
</pre>
<p>Now I try again:</p>
<pre>icecast2@Icecast-Pi:/home/kpovdjs$ echo "hello there username." | msmtp -a gmail <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:thatjackelliott@kpov.org" moz-do-not-send="true">thatjackelliott@kpov.org</a>
msmtp: account gmail not found: no configuration file available</pre>
<p>If msmtp cannot find its rc file in /home/icecast2, then
maybe there is a way to specify the location. <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/20/23 10:35 AM, Jordan
Erickson wrote:<br>
</div>
<blockquote type="cite"
cite="mid:05b27e6e-c2bf-8867-330d-b12a8880d3ad@subj.am">
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
Hi Jack,<br>
<br>
Have you tried, as the icecast2 user, interactively using the
msmtp command instead of with your script? Try this, it will
narrow down the variables. Also, check to see if your iceast2
user has the required group membership(s), if any, to send
mail from that machine.<br>
<br>
<br>
Cheers,<br>
Jordan Erickson<br>
<br>
<pre class="moz-signature" cols="72"><a class="moz-txt-link-freetext" href="https://subj.am/" moz-do-not-send="true">https://subj.am/</a></pre>
<div class="moz-cite-prefix">On 9/20/23 10:32, Jack Elliott
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:6bba1eff-a503-7e04-444e-97143efdbee8@kpov.org">
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<p>Thank you, Philipp Schafft,</p>
<p>Okay my amateur bash script is badly written and I will
clean it up. <br>
</p>
<p>But I don't think my clumsy scripting explains why I can
run the script as user kpovdjs, but not as user icecast2?</p>
<p>It uses /usr/bin/msptp and <br>
</p>
<pre>kpovdjs@Icecast-Pi:~/bin $ ls -l /usr/bin/msmtp
-rwxr-xr-x 1 root root 83848 Jun 19 2014 /usr/bin/msmtp</pre>
<p>So that isn't a problem. <br>
</p>
<p>And the script:</p>
<pre>kpovdjs@Icecast-Pi:~/bin $ ls -l email_onconnect.sh
-rwxrwxrwx 1 kpovdjs kpovdjs 422 Sep 20 10:08 email_onconnect.sh
</pre>
<p>Yes, I have tried running the script as user kpovdjs and
it works. And the same command as user icecast2 does not
work and does not make an error message. <br>
</p>
<p>Thomas Zumbrunnen wonders about my mount point
definition, this is it:</p>
<pre> <mount type="normal">
<mount-name>/stream</mount-name>
<fallback-mount>/fallbacks/Generic_Silence_192kbps_48kHz.mp3</fallback-mount>
<fallback-override>1</fallback-override>
<fallback-when-full>1</fallback-when-full>
<burst-size>65535</burst-size>
<on-connect>/home/kpovdjs/bin/email_onconnect.sh</on-connect>
<on-disconnect>/home/kpovdjs/bin/email_ondisconnect.sh</on-disconnect>
<no-yp>1</no-yp>
</mount>
</pre>
<p>Thank you, everyone!<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/20/23 8:44 AM, Philipp
Schafft wrote:<br>
</div>
<blockquote type="cite"
cite="mid:80ffb48ae7ffb2a4922c3e923513a4927d13ca21.camel@de.loewenfelsen.net">
<pre class="moz-quote-pre" wrap="">Good morning,
On Wed, 2023-09-20 at 08:24 -0700, Jack Elliott wrote:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">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
# <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:thatjackelliott@kpov.org" moz-do-not-send="true">thatjackelliott@kpov.org</a>
printf "To: <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:thatjackelliott@kpov.org\nFrom" moz-do-not-send="true">thatjackelliott@kpov.org\nFrom</a>: <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:kpovcomputer@gmail.com\nS" moz-do-not-send="true">kpovcomputer@gmail.com\nS</a>
ubject: 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 <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:thatjackelliott@kpov.org" moz-do-not-send="true">thatjackelliott@kpov.org</a> <
/home/kpovdjs/bin/on_connect.txt >/home/kpovdjs/bin/msmtp.log 2>&1
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">Your printf is wrong here.
NEVER do something like: printf "bla $blubb bla\n";
ALWAYS do: printf "bla %s bla\n" "$blubb";
That is exactly why we use printf in the first place. This is the
reason it exists.
Also you can just pipe your output between the commands. No need for a
tempfile (which also adds many problems, from permissions to race
conditions).
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">If I run it as user kpovdjs (me), it sends the email, and this is the
debug output:
kpovdjs@Icecast-Pi:~/bin $ ./email_onconnect.sh
+ printf 'To: <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:thatjackelliott@kpov.org\nFrom" moz-do-not-send="true">thatjackelliott@kpov.org\nFrom</a>: <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:kpovcomputer@gmail.com\" moz-do-not-send="true">kpovcomputer@gmail.com\</a>
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 <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:thatjackelliott@kpov.org" moz-do-not-send="true">thatjackelliott@kpov.org</a>
But as user icecast2, the debug output is the same, but no email
sent:
icecast2@Icecast-Pi:/home/kpovdjs/bin$ ./email_onconnect.sh
+ printf 'To: <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:thatjackelliott@kpov.org\nFrom" moz-do-not-send="true">thatjackelliott@kpov.org\nFrom</a>: <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:kpovcomputer@gmail.com\" moz-do-not-send="true">kpovcomputer@gmail.com\</a>
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 <a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:thatjackelliott@kpov.org" moz-do-not-send="true">thatjackelliott@kpov.org</a>
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">Are you sure /usr/bin/msmtp works as the Icecast user?
Have you tried to run that script as the same user as Icecast?
e.g.: sudo -u icecast /path/to/script
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">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
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">I hope that is a really really bad joke.
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">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.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">Not the wording I would use.
You could check Icecast's error.log to see if it reports a problem.
Other than that you really first need to establish that the script
actually works running as that user.
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">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@Icecast-Pi:/home/kpovdjs/bin$ ./email_onconnect.sh
+ printf '<a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:To:thatjackelliott@kpov.org\nFrom:kpovcomputer@gmail.com\nS" moz-do-not-send="true">To:thatjackelliott@kpov.org\nFrom:kpovcomputer@gmail.com\nS</a>
ubject: 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@kpov.org
icecast2@Icecast-Pi:/home/kpovdjs/bin$
Thank you!
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">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 <
<a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:that.jack.elliott@gmail.com" moz-do-not-send="true">that.jack.elliott@gmail.com</a>>:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">Hi Jordan,
Here is my script:
#!/bin/bash
#thatjackelliott@kpov.org
printf <a class="moz-txt-link-rfc2396E" href="mailto:To:thatjackelliott@kpov.org\nFrom:kpovcomputer@gmail.com\nSubject:Remotehosthasconnectedtomountpoint$1ontheBackstream\n\nKPOVIcecastserveronIcecastPihasdetectedaconnectiononthebackstream." moz-do-not-send="true">"To:thatjackelliott@kpov.org\nFrom:kpovcomputer@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."</a> >
/home/my_username/bin/on_connect.txt
/usr/bin/msmtpthatjackelliott@kpov.org <
/home/my_username/bin/on_connect.txt
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">/home/my_username/bin/msmtp.log 2>&1
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">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:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">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@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
<a class="moz-txt-link-freetext" href="https://subj.am/" moz-do-not-send="true">https://subj.am/</a>
</pre>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
<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@xiph.org" moz-do-not-send="true">Icecast@xiph.org</a>
<a class="moz-txt-link-freetext" href="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@xiph.org" moz-do-not-send="true">Icecast@xiph.org</a>
<a class="moz-txt-link-freetext" href="http://lists.xiph.org/mailman/listinfo/icecast" moz-do-not-send="true">http://lists.xiph.org/mailman/listinfo/icecast</a>
</pre>
</blockquote>
<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@xiph.org" moz-do-not-send="true">Icecast@xiph.org</a>
<a class="moz-txt-link-freetext" href="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" href="mailto:Icecast@xiph.org">Icecast@xiph.org</a>
<a class="moz-txt-link-freetext" href="http://lists.xiph.org/mailman/listinfo/icecast">http://lists.xiph.org/mailman/listinfo/icecast</a>
</pre>
</blockquote>
</body>
</html>