summaryrefslogtreecommitdiffstats
path: root/bind-cal.sh
blob: 555560f98aa84ae9c74f2913b097c35f5cccf35f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

BASE="$1"
USER="$2"
RESOURCE="$3"
NAME="${4:-${3##*/}}"

URL="$BASE/caldav.php/$USER/"

RESSOURCE=$(echo "$RESSOURCE" | php -e '<?php echo file_get_contents("php://stdin")')


REQUEST=`cat <<EOF
<?xml version="1.0" encoding="utf-8"?>
<bind xmlns="DAV:">
    <segment>$NAME</segment>
    <href>$RESOURCE</href>
</bind>
EOF`

echo $REQUEST

echo $REQUEST | curl -k -d @- -X BIND -u $USER -H "content-type: text/xml;charset=\"UTF-8\"" -H "user-agent: bind-script" $URL