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