From 5ad9de1c6dbd98441ec00c33732e422638ef7b38 Mon Sep 17 00:00:00 2001 From: Ludwig Behm Date: Wed, 16 Dec 2020 02:39:37 +0100 Subject: [PATCH] Add invite.ics attachment (fix #2) ```mail```-Aufruf und Zeitplanung ist nicht getestet --- invite.ics | 30 ++++++++++++++++++++++++++++++ invite.sh | 30 ++++++++++++++++++++++-------- plenums_invite.service | 2 ++ 3 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 invite.ics diff --git a/invite.ics b/invite.ics new file mode 100644 index 0000000..e08f55a --- /dev/null +++ b/invite.ics @@ -0,0 +1,30 @@ +BEGIN:VCALENDAR +PRODID:-//KrautSpace Jena//KrautSpace Einladescript//DE +VERSION:2.0 +CALSCALE:GREGORIAN +METHOD:REQUEST +BEGIN:VEVENT +DTSTART:#DTSTART# +DTEND:#DTEND# +DTSTAMP:#DTSTAMP# +UID:#DTSTAMP#@kraut.space +SUMMARY:#SUMMARY# +DESCRIPTION:Wir treffen uns um 20 Uhr im virtuellen Raum unter: + \n\nhttps://blue.kabi.tk/b/hac-nuf-fp4 + \n\nFür Vorbereitung und Protokoll gibt es wieder ein Pad, + bitte tragt schon mal Themen ein, die Ihr gern besprechen würdet: + \n\nhttps://vereinte.verwirrung.institute/p/ksplenum-#URLDATE# + \n\n\nGgf. muss das Pad erst noch vorbereitet werden, + die Vorlage mit Anleitung findet Ihr hier: + \n\nhttps://vereinte.verwirrung.institute/p/ksplenum-template +LOCATION:#LOCATION# +ORGANIZER;CN=KrautSpace Jena; + SENT-BY="MAILTO:#FROM#" + :mailto:#REPLY_TO# +SEQUENCE:0 +STATUS:CONFIRMED +CLASS:PUBLIC +CATEGORIES:MEETING +TRANSP:OPAQUE +END:VEVENT +END:VCALENDAR diff --git a/invite.sh b/invite.sh index 6bead13..5033767 100755 --- a/invite.sh +++ b/invite.sh @@ -4,18 +4,17 @@ from="office@krautspace.de" to=("hackspace-jena@lstsrv.org" "krautspace-announce@lstsrv.org") +replyto="hackspace-jena@lstsrv.org" subject="Einladung zum Plenum" +location_url="https://blue.kabi.tk/b/hac-nuf-fp4" body_file=email_text # Use PROSEDATE for dd.mm.YYYY and URLDATE for YYYmmdd ## Find next Thursday - -day_of_week=$(date +%u) - -next_thursday_offset=$(( ( ( 7 - $day_of_week ) + 4 ) % 7 )) +date_fmt () { date -u -d "$2 next Thu" $1; } ## Check if next Thursday is the first of a month -if (( $(date -d "+$next_thursday_offset days" +%_d) > 7 )); then +if (( $(date_fmt +%_d) > 7 )); then echo "Invitation should be sent at most a week in advance." echo "Exiting without sending an inviation..." exit @@ -23,10 +22,25 @@ fi ## Send invitation -prose_date=$(date -d "+$next_thursday_offset days" +%d.%m.%Y) -url_date=$(date -d "+$next_thursday_offset days" +%Y%m%d) +prose_date=$(date_fmt +%d.%m.%Y) +url_date=$(date_fmt +%Y%m%d) script_path=$(readlink -f "$0") source_directory=$(dirname "$script_path") -cat "$source_directory/$body_file" | sed -e "s/PROSEDATE/$prose_date/g" | sed -e "s/URLDATE/$url_date/g" | mail -s "$subject" -r "$from" "${to[@]}" +sed -e "s/#DTSTART#/$(date_fmt +%Y%m%dT%H%M%SZ "TZ=\"Europe/Berlin\" 20:00")/" \ + -e "s/#DTEND#/$(date_fmt +%Y%m%dT%H%M%SZ "TZ=\"Europe/Berlin\" 21:00")/" \ + -e "s/#DTSTAMP#/$(date -u +%Y%m%dT%H%M%SZ)/" \ + -e "s/#SUMMARY#/KrautSpace Plenum/" \ + -e "s/#LOCATION#/${location}/" \ + -e "s/#FROM#/${from}/g" \ + -e "s/#REPLY_TO#/${replyto}/g" \ + -e "s/#URLDATE#/${url_date}/g" \ + invite.ics > /tmp/invite.ics + +sed -e "s/PROSEDATE/$prose_date/g" \ + -e "s/URLDATE/$url_date/g" \ + "$source_directory/$body_file" | mail -s "$subject" -r "$from" -a /tmp/invite.ics "${to[@]}" +ret=$? +rm -f /tmp/invite.ics +exit $ret diff --git a/plenums_invite.service b/plenums_invite.service index 9d2d5d4..9815de1 100644 --- a/plenums_invite.service +++ b/plenums_invite.service @@ -4,3 +4,5 @@ Description=Send invitation to Hackspace's Plenum [Service] Type=oneshot ExecStart=/opt/plenums_invite/invite.sh + +PrivateTmp=yes