1 #!/bin/sh 2 3 . "`dirname \"$0\"`/common_minimal.sh" 4 5 export N=$1 6 export START=20141126T090000 7 export END=20141126T100000 8 export SENDERADDRESS="person-$N@example.com" 9 export SENDER="mailto:person-$N@example.com" 10 11 # Exit if a previous result indicates acceptance of a request. 12 13 [ -e "outP${N}.tmp" ] \ 14 && `grep 'PARTSTAT' "outP${N}.tmp" | grep -q 'ACCEPTED'` \ 15 && exit 0 16 17 FBRESULT=$2 18 19 # Find the end of a busy period or use the initial start. 20 21 FBSTART=`grep 'FREEBUSY' "$FBRESULT" | grep -v 'VFREEBUSY' | tail -n 1 | cut -d: -f2 | cut -d/ -f2 | tr -d '\\r'` 22 FBEND=`python "$THIS_DIR/next_time.py" "$FBSTART" 09 16` 23 START=${FBSTART:-$START} 24 END=${FBEND:-$END} 25 26 echo "Try for $N with $START and $END..." 27 28 # Request a resource on behalf of a numbered person identity. 29 30 envsubst < "$TEMPLATES/event-request-group.txt" \ 31 | tee "inP${N}.tmp" \ 32 | "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \ 33 | "$SHOWMAIL" 2>> $ERROR \ 34 > "outP${N}.tmp"