diff --git a/staubsauger.sh b/staubsauger.sh index cec490f..2e24fcb 100644 --- a/staubsauger.sh +++ b/staubsauger.sh @@ -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 ' to_report='Admin email <@>' -from='Staubsauger-Erinnerung '; +from='Staubsauger-Erinnerung '; 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

Guten Morgen!

- Es ist wieder Zeit, den Staubsauger zu reinigen.
Es ist wieder Zeit, den Staubsauger zu reinigen.
@@ -51,11 +54,15 @@ if [[ $month == "1" || $month == "3" || $month == "5" || $month == "7" || $month

-

-- 
Automatisch generierte Email. Bitte nicht darauf antworten.

+

+ -- 
+ Automatisch generierte Email.
+ Bei Klick auf `Antworten` sollte bereits meine eigene Adresse eingefüllt werden. +

- + '; fi else @@ -65,12 +72,12 @@ else fi bodymg=' + -

Staubsaugerreinigung vom '`date +%d.%m.%Y`'

@@ -79,8 +86,15 @@ bodymg=' Die Erinnerung wurde heute '"$send_report_msg"'versendet.

+
+

+ -- 
+ Test-Signatur. FFS <°)))>< +

+
+ '; @@ -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}"