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

notifier: Added support for smtp.turris.cz server.

parent 2c25890f
No related branches found
No related tags found
No related merge requests found
......@@ -16,20 +16,55 @@ mail_stamp="sent_by_email"
smtp_enabled=`uci get user_notify.smtp.enable`
mail_to=`uci get user_notify.smtp.to`
mail_from=`uci get user_notify.smtp.from`
create_msmtp_config() {
local turris_smtp=`uci get user_notify.smtp.use_turris_smtp`
echo "account notifier" > "$msmtp_cfg_file"
if [ -n $turris_smtp ] && [ $turris_smtp = "1" ] && [ $turris_smtp = "1" ]; then
use_turris_smtp
else
parse_user_server_setting
fi
echo "timeout 5" >> "$msmtp_cfg_file"
echo "account default: notifier" >> "$msmtp_cfg_file"
}
use_turris_smtp() {
mail_from="$(uci get system.@system[0].hostname)@notify.turris.cz"
local username=`atsha204cmd serial-number`
local password=`echo "efefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefef" \
| atsha204cmd challenge-response \
| awk '{print tolower($0)}'`
local server="smtp.turris.cz"
local port="465"
echo "from $from" >> "$msmtp_cfg_file"
echo "host $server" >> "$msmtp_cfg_file"
echo "port $port" >> "$msmtp_cfg_file"
echo "tls on" >> "$msmtp_cfg_file"
echo "tls_certcheck off" >> "$msmtp_cfg_file"
echo "tls_starttls off" >> "$msmtp_cfg_file"
echo "auth on" >> "$msmtp_cfg_file"
echo "user $username" >> "$msmtp_cfg_file"
echo "password $password" >> "$msmtp_cfg_file"
}
parse_user_server_setting() {
mail_from=`uci get user_notify.smtp.from`
local username=`uci get user_notify.smtp.username 2>/dev/null`
local password=`uci get user_notify.smtp.password 2>/dev/null`
local server=`uci get user_notify.smtp.server`
local port=`uci get user_notify.smtp.port`
local security=`uci get user_notify.smtp.security`
local from=`uci get user_notify.smtp.from`
echo "account notifier" > "$msmtp_cfg_file"
echo "host $server" >> "$msmtp_cfg_file"
echo "from $from" >> "$msmtp_cfg_file"
echo "host $server" >> "$msmtp_cfg_file"
echo "port $port" >> "$msmtp_cfg_file"
echo "from $from" >> "$msmtp_cfg_file"
if [ "$security" = "ssl" ]; then
echo "tls on" >> "$msmtp_cfg_file"
......@@ -50,9 +85,6 @@ create_msmtp_config() {
else
echo "auth off" >> "$msmtp_cfg_file"
fi
echo "timeout 5" >> "$msmtp_cfg_file"
echo "account default: notifier" >> "$msmtp_cfg_file"
}
schedule_restart() {
......
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