Skip to content
Snippets Groups Projects
Commit eb69aaa0 authored by Martin Strbacka's avatar Martin Strbacka
Browse files

Fixed few friday bugs.

parent 14c0cbfb
No related branches found
No related tags found
No related merge requests found
#!/bin/sh
base_folder=/tmp/user_notify
msgs_folder=$base_folder/messages
locker_stamp=$base_folder/locked
locker_stamp=$base_folder/.locked
msg_file=$locker_stamp/msg.mail
msmtp_cfg_file=/tmp/msmtp.cfg
mail_stamp=".sent_by_email"
......@@ -36,28 +35,28 @@ create_msmtp_config() {
}
compose_message() {
mkdir $locker_stamp >/dev/null 2>&1
err_lvl=$?
if [ $err_lvl -ne 0 ]; then
echo "Another instance of notifier is running."
exit 1
fi
echo -e "Subject: Upozorneni od Vaseho routeru Turris\n" > $msg_file
msg_list=`ls $msgs_folder`
msg_list=`ls $base_folder`
for msg in $msg_list; do
echo "Working on message: $msg"
touch $msgs_folder/$msg/$mail_stamp
cat $msgs_folder/$msg/message >> $msg_file
touch $base_folder/$msg/$mail_stamp
cat $base_folder/$msg/message >> $msg_file
done
rm -rf $locker_stamp
}
send_mail() {
mkdir $locker_stamp >/dev/null 2>&1
err_lvl=$?
if [ $err_lvl -ne 0 ]; then
echo "Another instance of notifier is running."
exit 1
fi
compose_message
to=`uci get user_notify.smtp.to`
cat $msg_file | msmtp -C $msmtp_cfg_file $to
......@@ -66,6 +65,8 @@ send_mail() {
if [ $err_lvl -eq 0 ]; then
msg_cleanup
fi
rm -rf $locker_stamp
}
if [ $smtp_enabled -eq 0 ]; then
......@@ -74,5 +75,4 @@ if [ $smtp_enabled -eq 0 ]; then
fi
create_msmtp_config
compose_message
send_mail
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment