I tried -e and also I made the script to write into a log file after every line. The log only showed that it failed at random lines, so I couldn't pin point the error. So I forgot the whole problem and continued with my life, maybe with a scar in my soul.
Today I started to wonder if there may be some problems with the rights in Qnaps OS, it was a auto script that was supposed to run at boot. So I finally also resolved this problem (not a good and nice solution, but it works).
1. In amule.conf I have this
[UserEvents/DownloadCompleted]
CoreEnabled=1
CoreCommand=/opt/sbin/aMuleMail.sh "%NAME" "%FILE" %HASH %SIZE "%DLACTIVETIME"
GUIEnabled=1
GUICommand=/opt/sbin/aMuleMail.sh "%NAME" "%FILE" %HASH %SIZE "%DLACTIVETIME"
2. In aMuleMail.sh I have this (I run the 'real' e-mail script aMuleMail
Send.sh from aMuleMail.sh with sudo (e.g. as root) and the echo part gives sudo the root password, so not very secure as someone may see root password i clear text in that file)
#!/bin/bash
echo "My-password-for-root" | sudo /opt/sbin/aMuleMailSend.sh "$1" "$2" $3 $4 "$5"
And now it works
. As aMule already runs as "admin" (the "root" in Qnap) it should work without this, but I guess they have done something wrong.
I guess I could do this much shorter with just change amule.conf to
[UserEvents/DownloadCompleted]
CoreEnabled=1
CoreCommand=echo "My-password-for-root" | sudo /opt/sbin/aMuleMailSend.sh "%NAME" "%FILE" %HASH %SIZE "%DLACTIVETIME"
GUIEnabled=1
GUICommand=echo "My-password-for-root" | sudo /opt/sbin/aMuleMailSend.sh "%NAME" "%FILE" %HASH %SIZE "%DLACTIVETIME"
But now it works, and I am like "If it works, don't fix it" right now
I wonder if I can run sudo without the echo part? On a normal system maybe something in /usr/etc/sudoers, but it has "admin ALL=(ALL) ALL" but it still didn't work.