1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/resource_request.sh Thu Sep 10 22:09:38 2015 +0200
1.3 @@ -0,0 +1,44 @@
1.4 +#!/bin/sh
1.5 +
1.6 +THIS_DIR=`dirname $0`
1.7 +
1.8 +TEMPLATES="$THIS_DIR/templates"
1.9 +RESOURCE_SCRIPT="$THIS_DIR/../imip_resource.py"
1.10 +SHOWMAIL="$THIS_DIR/../tools/showmail.py"
1.11 +STORE=/tmp/store
1.12 +STATIC=/tmp/static
1.13 +PREFS=/tmp/prefs
1.14 +ARGS="-S $STORE -P $STATIC -p $PREFS -d"
1.15 +
1.16 +ERROR=err.tmp
1.17 +
1.18 +export N=$1
1.19 +export START=20141126T090000
1.20 +export END=20141126T100000
1.21 +export SENDERADDRESS="person-$N@example.com"
1.22 +export SENDER="mailto:person-$N@example.com"
1.23 +
1.24 +# Exit if a previous result indicates acceptance of a request.
1.25 +
1.26 + [ -e "outP${N}.tmp" ] \
1.27 +&& `grep 'PARTSTAT' "outP${N}.tmp" | grep -q 'ACCEPTED'` \
1.28 +&& exit 0
1.29 +
1.30 +FBRESULT=$2
1.31 +
1.32 +# Find the end of a busy period or use the initial start.
1.33 +
1.34 +FBSTART=`grep 'FREEBUSY' "$FBRESULT" | grep -v 'VFREEBUSY' | tail -n 1 | cut -d: -f2 | cut -d/ -f2 | tr -d '\\r'`
1.35 +FBEND=`python "$THIS_DIR/next_time.py" "$FBSTART" 09 16`
1.36 +START=${FBSTART:-$START}
1.37 +END=${FBEND:-$END}
1.38 +
1.39 +echo "Try for $N with $START and $END..."
1.40 +
1.41 +# Request a resource on behalf of a numbered person identity.
1.42 +
1.43 + envsubst < "$TEMPLATES/event-request-group.txt" \
1.44 +| tee "inP${N}.tmp" \
1.45 +| "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \
1.46 +| "$SHOWMAIL" 2>> $ERROR \
1.47 +> "outP${N}.tmp"