44 lines
1.4 KiB
Bash
44 lines
1.4 KiB
Bash
|
#!/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
|