paul@1050 | 1 | #!/bin/sh |
paul@1050 | 2 | |
paul@1050 | 3 | . "`dirname \"$0\"`/common.sh" |
paul@1050 | 4 | |
paul@1050 | 5 | USER="mailto:resource-car-porsche911@example.com" |
paul@1050 | 6 | SENDER="mailto:paul.boddie@example.com" |
paul@1050 | 7 | FBFILE="$STORE/$USER/freebusy" |
paul@1050 | 8 | FBSENDERFILE="$STORE/$SENDER/freebusy" |
paul@1050 | 9 | QUOTA="$USER" |
paul@1050 | 10 | JOURNALFILE="$JOURNAL/$QUOTA/journal/$SENDER" |
paul@1050 | 11 | |
paul@1050 | 12 | mkdir -p "$PREFS/$USER" |
paul@1050 | 13 | echo 'Europe/Oslo' > "$PREFS/$USER/TZID" |
paul@1050 | 14 | echo 'share' > "$PREFS/$USER/freebusy_sharing" |
paul@1050 | 15 | cat > "$PREFS/$USER/scheduling_function" <<EOF |
paul@1050 | 16 | schedule_in_freebusy |
paul@1050 | 17 | check_quota |
paul@1050 | 18 | EOF |
paul@1050 | 19 | |
paul@1050 | 20 | # Employ a user-specific quota (no argument with the functions above). |
paul@1050 | 21 | |
paul@1050 | 22 | mkdir -p "$JOURNAL/$QUOTA" |
paul@1050 | 23 | echo '* PT10H' > "$JOURNAL/$QUOTA/limits" |
paul@1050 | 24 | |
paul@1050 | 25 | "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-car-all.txt" 2>> $ERROR \ |
paul@1050 | 26 | | "$SHOWMAIL" \ |
paul@1050 | 27 | > out0.tmp |
paul@1050 | 28 | |
paul@1050 | 29 | grep -q 'METHOD:REPLY' out0.tmp \ |
paul@1050 | 30 | && ! grep -q '^FREEBUSY' out0.tmp \ |
paul@1050 | 31 | && echo "Success" \ |
paul@1050 | 32 | || echo "Failed" |
paul@1050 | 33 | |
paul@1050 | 34 | # Attempt to schedule an event. |
paul@1050 | 35 | |
paul@1050 | 36 | "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-recurring.txt" 2>> $ERROR |
paul@1050 | 37 | |
paul@1050 | 38 | grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE" \ |
paul@1050 | 39 | && grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBSENDERFILE" \ |
paul@1050 | 40 | && echo "Success" \ |
paul@1050 | 41 | || echo "Failed" |
paul@1050 | 42 | |
paul@1050 | 43 | # Present the request to the resource. |
paul@1050 | 44 | |
paul@1050 | 45 | "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-recurring.txt" 2>> $ERROR \ |
paul@1050 | 46 | | tee out1r.tmp \ |
paul@1050 | 47 | | "$SHOWMAIL" \ |
paul@1050 | 48 | > out1.tmp |
paul@1050 | 49 | |
paul@1050 | 50 | grep -q 'METHOD:REPLY' out1.tmp \ |
paul@1050 | 51 | && grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out1.tmp \ |
paul@1050 | 52 | && echo "Success" \ |
paul@1050 | 53 | || echo "Failed" |
paul@1050 | 54 | |
paul@1050 | 55 | ! [ -e "$FBFILE" ] \ |
paul@1050 | 56 | || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ |
paul@1050 | 57 | && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBFILE" ) \ |
paul@1050 | 58 | && echo "Success" \ |
paul@1050 | 59 | || echo "Failed" |
paul@1050 | 60 | |
paul@1050 | 61 | # Check the quota (event is not confirmed). |
paul@1050 | 62 | |
paul@1050 | 63 | ! [ -e "$JOURNALFILE" ] \ |
paul@1050 | 64 | || ! grep -q "event24@example.com" "$JOURNALFILE" \ |
paul@1050 | 65 | && echo "Success" \ |
paul@1050 | 66 | || echo "Failed" |
paul@1050 | 67 | |
paul@1050 | 68 | # Modify the event and attempt to schedule it again. |
paul@1050 | 69 | |
paul@1050 | 70 | sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=11/;' "$TEMPLATES/event-request-car-recurring.txt" \ |
paul@1050 | 71 | | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR |
paul@1050 | 72 | |
paul@1050 | 73 | grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE" \ |
paul@1054 | 74 | && grep -q "^20141205T150000Z${TAB}20141205T160000Z" "$FBSENDERFILE" \ |
paul@1050 | 75 | && grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBSENDERFILE" \ |
paul@1050 | 76 | && echo "Success" \ |
paul@1050 | 77 | || echo "Failed" |
paul@1050 | 78 | |
paul@1050 | 79 | # Present the request to the resource. |
paul@1050 | 80 | |
paul@1050 | 81 | sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=11/;' "$TEMPLATES/event-request-car-recurring.txt" \ |
paul@1050 | 82 | | "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \ |
paul@1050 | 83 | | tee out2r.tmp \ |
paul@1050 | 84 | | "$SHOWMAIL" \ |
paul@1050 | 85 | > out2.tmp |
paul@1050 | 86 | |
paul@1050 | 87 | grep -q 'METHOD:REPLY' out2.tmp \ |
paul@1050 | 88 | && grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out2.tmp \ |
paul@1050 | 89 | && echo "Success" \ |
paul@1050 | 90 | || echo "Failed" |
paul@1050 | 91 | |
paul@1050 | 92 | ! [ -e "$FBFILE" ] \ |
paul@1050 | 93 | || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ |
paul@1050 | 94 | && ! grep -q "^20141205T150000Z${TAB}20141205T160000Z" "$FBFILE" \ |
paul@1050 | 95 | && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBFILE" ) \ |
paul@1050 | 96 | && echo "Success" \ |
paul@1050 | 97 | || echo "Failed" |
paul@1050 | 98 | |
paul@1050 | 99 | # Check the quota (event is confirmed). |
paul@1050 | 100 | |
paul@1050 | 101 | ! [ -e "$JOURNALFILE" ] \ |
paul@1050 | 102 | || ! grep -q "event24@example.com" "$JOURNALFILE" \ |
paul@1050 | 103 | && echo "Success" \ |
paul@1050 | 104 | || echo "Failed" |
paul@1050 | 105 | |
paul@1050 | 106 | # Modify the event and attempt to schedule it again. |
paul@1050 | 107 | |
paul@1050 | 108 | sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=10/;' "$TEMPLATES/event-request-car-recurring.txt" \ |
paul@1050 | 109 | | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR |
paul@1050 | 110 | |
paul@1050 | 111 | grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE" \ |
paul@1054 | 112 | && grep -q "^20141205T150000Z${TAB}20141205T160000Z" "$FBSENDERFILE" \ |
paul@1050 | 113 | && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBSENDERFILE" \ |
paul@1050 | 114 | && echo "Success" \ |
paul@1050 | 115 | || echo "Failed" |
paul@1050 | 116 | |
paul@1050 | 117 | # Present the request to the resource. |
paul@1050 | 118 | |
paul@1050 | 119 | sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=10/;' "$TEMPLATES/event-request-car-recurring.txt" \ |
paul@1050 | 120 | | "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \ |
paul@1050 | 121 | | tee out2r.tmp \ |
paul@1050 | 122 | | "$SHOWMAIL" \ |
paul@1050 | 123 | > out2.tmp |
paul@1050 | 124 | |
paul@1050 | 125 | grep -q 'METHOD:REPLY' out2.tmp \ |
paul@1050 | 126 | && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out2.tmp \ |
paul@1050 | 127 | && echo "Success" \ |
paul@1050 | 128 | || echo "Failed" |
paul@1050 | 129 | |
paul@1050 | 130 | [ -e "$FBFILE" ] \ |
paul@1050 | 131 | && grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ |
paul@1050 | 132 | && grep -q "^20141205T150000Z${TAB}20141205T160000Z" "$FBFILE" \ |
paul@1050 | 133 | && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBFILE" \ |
paul@1050 | 134 | && echo "Success" \ |
paul@1050 | 135 | || echo "Failed" |
paul@1050 | 136 | |
paul@1050 | 137 | # Check the quota (event is confirmed). |
paul@1050 | 138 | |
paul@1050 | 139 | [ -e "$JOURNALFILE" ] \ |
paul@1050 | 140 | && grep -q "event24@example.com" "$JOURNALFILE" \ |
paul@1050 | 141 | && echo "Success" \ |
paul@1050 | 142 | || echo "Failed" |