Neuer Versuch mit CalDav-Integration

master
gandalf 2022-05-19 17:03:00 +02:00
parent b6591799a9
commit 78cf0f032e
2 changed files with 78 additions and 0 deletions

43
add_date.sh Normal file
View File

@ -0,0 +1,43 @@
#!/bin/bash
### This shell script is used to create new events in caldav on our owncloud server after a machine booking on our grr server
usage="$0 machineNumber user starttime endtime"
if [ "$#" -ne 4 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ];then
echo $usage
exit 1
else
random1=`</dev/urandom tr -dc '1-9a-z' | head -c8; echo ""`
random2=`</dev/urandom tr -dc '1-9a-z' | head -c4; echo ""`
random3=`</dev/urandom tr -dc '1-9a-z' | head -c4; echo ""`
random4=`</dev/urandom tr -dc '1-9a-z' | head -c4; echo ""`
random5=`</dev/urandom tr -dc '1-9a-z' | head -c12; echo ""`
#UID=`</dev/urandom tr -dc '1-9a-z' | head -c10; echo ""`
# ics example 8cbf7d9e-6g68-43b9-zb3c-073a8e6b8f46.ics
UID=$random1-$random2-$random3-$random4-$random5
ics=$UID.ics
NOW=`date +%Y%m%dT%H%M%S`
template=template.ics
cp template.ics $ics
sed -i "s|reservation machine|reservation machine $1 par $2|g" $ics
sed -i "s|20160225T083000|$3|g" $ics
sed -i "s|20160225T090000|$4|g" $ics
sed -i "s|99g999gggg|$UID|g" $ics
sed -i "s|20160224T172807|$NOW|g" $ics
sed -i "s|20160224T172807|$NOW|g" $ics
user=username:secret
url=http://owncloud.domain.tld/owncloud/remote.php/caldav/calendars/foo
curl -k --user $user -X PUT -H "Content-Type: text/calendar; charset=utf-8" --data-binary @./$ics --url $url/$ics
fi

35
template.ics Normal file
View File

@ -0,0 +1,35 @@
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
BEGIN:VTIMEZONE
TZID:Europe/Paris
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
CREATED:20160224T172807Z
LAST-MODIFIED:20160224T172807Z
DTSTAMP:20160224T172807Z
UID:99g999gggg
SUMMARY:reservation machine
DESCRIPTION:to_replace
DTSTART;TZID=Europe/Paris:20160225T083000
DTEND;TZID=Europe/Paris:20160225T090000
X-LIC-ERROR;X-LIC-ERRORTYPE=VALUE-PARSE-ERROR:No value for CATEGORIES prope
rty. Removing entire property:
CLASS:PUBLIC
X-MOZ-GENERATION:1
END:VEVENT
END:VCALENDAR