make staubsauger.sh work on OpenBSD
This commit is contained in:
parent
0472b65847
commit
66b74d1619
1 changed files with 29 additions and 15 deletions
|
@ -1,10 +1,11 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
date=$(date +%d.%m.%Y);
|
||||
day=$(date +%-d);
|
||||
month=$(date +%-m);
|
||||
day=$(date +%d);
|
||||
month=$(date +%m);
|
||||
to_notification='User email <@>'
|
||||
#to_notification='Test User <test@tmsn.at>'
|
||||
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_report=`printf "[Cron Report] $subject"`;
|
||||
host=$(/bin/hostname);
|
||||
|
@ -14,13 +15,15 @@ headers=`printf "From: %s\r\nReply-To: %s\r\nContent-Type: text/html; charset=ut
|
|||
send='no'
|
||||
sendcc='no'
|
||||
send_report_msg='nicht '
|
||||
body='Ein Fehler ist aufgetreten. (Scope vermutlich)'
|
||||
bodymg='an error occured. invalid scope probably.'
|
||||
|
||||
# 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
|
||||
if [ $day -gt "7" ]; then
|
||||
if [ $day -gt 7 ]; then
|
||||
# nicht senden, falls wir schon nach der ersten woche sind
|
||||
# -> kein 1. Samstag nach 7 Tagen im Monat möglich
|
||||
send='no';
|
||||
|
@ -41,7 +44,7 @@ if [[ $month == "1" || $month == "3" || $month == "5" || $month == "7" || $month
|
|||
<div class="main">
|
||||
<p>
|
||||
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
|
||||
werden.
|
||||
</p>
|
||||
|
@ -51,11 +54,15 @@ if [[ $month == "1" || $month == "3" || $month == "5" || $month == "7" || $month
|
|||
</p>
|
||||
</div>
|
||||
<div class="sig">
|
||||
<p style="margin-top:1.5em;color:#777;">-- <br>Automatisch generierte Email. Bitte nicht darauf antworten.</p>
|
||||
<p style="margin-top:1.5em;color:#777;">
|
||||
-- <br />
|
||||
Automatisch generierte Email.<br />
|
||||
Bei Klick auf `Antworten` sollte bereits meine eigene Adresse eingefüllt werden.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<!-- lichtlein ;) -->
|
||||
<!-- lichtlein ;) running on OpenBSD -->
|
||||
';
|
||||
fi
|
||||
else
|
||||
|
@ -65,12 +72,12 @@ else
|
|||
fi
|
||||
|
||||
bodymg='<html>
|
||||
<!-- report -->
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="HandheldFriendly" content="True">
|
||||
<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">
|
||||
</head>
|
||||
<body>
|
||||
<h3>Staubsaugerreinigung vom '`date +%d.%m.%Y`'</h3>
|
||||
|
@ -79,8 +86,15 @@ bodymg='<html>
|
|||
Die Erinnerung wurde heute <strong>'"$send_report_msg"'versendet</strong>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="sig">
|
||||
<p style="margin-top:1.5em;color:#777;">
|
||||
-- <br />
|
||||
Test-Signatur. FFS <°)))><
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<!-- report end -->
|
||||
<!-- lichtlein ;) -->
|
||||
';
|
||||
|
||||
|
@ -88,13 +102,13 @@ if [ $send == "yes" ]; then
|
|||
# es wird eine benachrichtigung versendet
|
||||
if [ $sendcc == "yes" ]; then
|
||||
# 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
|
||||
# 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
|
||||
|
||||
# A report is always sent out. Keeping track if the script works is a good idea.
|
||||
/usr/bin/php -r "mail('$to_report', '$subject_report', '$bodymg', '$headers');";
|
||||
# a report is always sent
|
||||
echo -e "${headers}\n\n${bodymg}" | /usr/local/bin/mutt -H - -s "${subject_report}" -- "${to_report}"
|
||||
|
||||
|
|
Loading…
Reference in a new issue