make staubsauger.sh work on OpenBSD

main
Dominic Reich 2 months ago
parent 0472b65847
commit 66b74d1619
Signed by: dominic
GPG Key ID: BC9D6AE1A3BE169A

@ -1,10 +1,11 @@
#!/bin/bash #!/usr/bin/env bash
date=$(date +%d.%m.%Y); date=$(date +%d.%m.%Y);
day=$(date +%-d); day=$(date +%d);
month=$(date +%-m); month=$(date +%m);
to_notification='User email <@>' to_notification='User email <@>'
#to_notification='Test User <test@tmsn.at>'
to_report='Admin email <@>' to_report='Admin email <@>'
from='Staubsauger-Erinnerung <staubsauger-erinnerung@oe7drt.cc>'; from='Staubsauger-Erinnerung <staubsauger-erinnerung@oe7drt.com>';
subject=`printf "Staubsauger-Erinnerung vom %s" "$date"`; subject=`printf "Staubsauger-Erinnerung vom %s" "$date"`;
subject_report=`printf "[Cron Report] $subject"`; subject_report=`printf "[Cron Report] $subject"`;
host=$(/bin/hostname); host=$(/bin/hostname);
@ -14,13 +15,15 @@ headers=`printf "From: %s\r\nReply-To: %s\r\nContent-Type: text/html; charset=ut
send='no' send='no'
sendcc='no' sendcc='no'
send_report_msg='nicht ' send_report_msg='nicht '
body='Ein Fehler ist aufgetreten. (Scope vermutlich)'
bodymg='an error occured. invalid scope probably.'
# Change settings here # Change settings here
#sendcc='yes' sendcc='no'
if [[ $month == "1" || $month == "3" || $month == "5" || $month == "7" || $month == "9" || $month == "11" ]]; then if [[ $month -eq 2 || $month -eq 4 || $month -eq 6 || $month -eq 8 || $month -eq 10 || $month -eq 12 ]]; then
# in diesem Monat senden # in diesem Monat senden
if [ $day -gt "7" ]; then if [ $day -gt 7 ]; then
# nicht senden, falls wir schon nach der ersten woche sind # nicht senden, falls wir schon nach der ersten woche sind
# -> kein 1. Samstag nach 7 Tagen im Monat möglich # -> kein 1. Samstag nach 7 Tagen im Monat möglich
send='no'; send='no';
@ -41,7 +44,7 @@ if [[ $month == "1" || $month == "3" || $month == "5" || $month == "7" || $month
<div class="main"> <div class="main">
<p> <p>
Guten Morgen!<br /><br /> Guten Morgen!<br /><br />
Es ist wieder Zeit, den Staubsauger zu reinigen.<br / <strong>Es ist wieder Zeit, den Staubsauger zu reinigen.</strong><br /
Falls das schon geschehen ist, kann diese E-Mail ignoriert Falls das schon geschehen ist, kann diese E-Mail ignoriert
werden. werden.
</p> </p>
@ -51,11 +54,15 @@ if [[ $month == "1" || $month == "3" || $month == "5" || $month == "7" || $month
</p> </p>
</div> </div>
<div class="sig"> <div class="sig">
<p style="margin-top:1.5em;color:#777;">--&nbsp;<br>Automatisch generierte Email. Bitte nicht darauf antworten.</p> <p style="margin-top:1.5em;color:#777;">
--&nbsp;<br />
Automatisch generierte Email.<br />
Bei Klick auf `Antworten` sollte bereits meine eigene Adresse eingefüllt werden.
</p>
</div> </div>
</body> </body>
</html> </html>
<!-- lichtlein ;) --> <!-- lichtlein ;) running on OpenBSD -->
'; ';
fi fi
else else
@ -65,12 +72,12 @@ else
fi fi
bodymg='<html> bodymg='<html>
<!-- report -->
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="HandheldFriendly" content="True"> <meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320"> <meta name="MobileOptimized" content="320">
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head> </head>
<body> <body>
<h3>Staubsaugerreinigung vom '`date +%d.%m.%Y`'</h3> <h3>Staubsaugerreinigung vom '`date +%d.%m.%Y`'</h3>
@ -79,8 +86,15 @@ bodymg='<html>
Die Erinnerung wurde heute <strong>'"$send_report_msg"'versendet</strong>. Die Erinnerung wurde heute <strong>'"$send_report_msg"'versendet</strong>.
</p> </p>
</div> </div>
<div class="sig">
<p style="margin-top:1.5em;color:#777;">
--&nbsp;<br />
Test-Signatur. FFS <°)))><
</p>
</div>
</body> </body>
</html> </html>
<!-- report end -->
<!-- lichtlein ;) --> <!-- lichtlein ;) -->
'; ';
@ -88,13 +102,13 @@ if [ $send == "yes" ]; then
# es wird eine benachrichtigung versendet # es wird eine benachrichtigung versendet
if [ $sendcc == "yes" ]; then if [ $sendcc == "yes" ]; then
# auch an den admin/report # auch an den admin/report
/usr/bin/php -r "mail('$to_notification, $to_report', '$subject', '$body', '$headers');"; echo -e "${headers}\n\n${body}" | /usr/local/bin/mutt -H - -s "${subject}" -- "${to_notification}" "${to_report}"
else else
# nur an die notification mail adresse # nur an die notification mail adresse
/usr/bin/php -r "mail('$to_notification', '$subject', '$body', '$headers');"; echo -e "${headers}\n\n${body}" | /usr/local/bin/mutt -H - -s "${subject}" -- "${to_notification}"
fi fi
fi fi
# A report is always sent out. Keeping track if the script works is a good idea. # a report is always sent
/usr/bin/php -r "mail('$to_report', '$subject_report', '$bodymg', '$headers');"; echo -e "${headers}\n\n${bodymg}" | /usr/local/bin/mutt -H - -s "${subject_report}" -- "${to_report}"

Loading…
Cancel
Save