Add invite.ics attachment (fix #2)
```mail```-Aufruf und Zeitplanung ist nicht getestet
This commit is contained in:
parent
2fd20b18f6
commit
5f26566df3
3 changed files with 54 additions and 8 deletions
30
invite.sh
30
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue