-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtwilio-alert-escalate.sh
54 lines (41 loc) · 1.16 KB
/
twilio-alert-escalate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
#get the current weeknumber
weeknumber=`date +%V`
# get the person on next weeks call list
weeknumber=$((weeknumber+1))
function usage
{
if [ -n "$1" ]; then echo $1; fi
echo "Usage: twilio-alert-escalate.sh [-v] [-c configfile]"
exit 1
}
# set to verbose by default
VERBOSE=0
# get the current script directory
DIRECTORY=$(cd `dirname $0` && pwd)
# create a path to the default config file
CONFIGFILE="$DIRECTORY/twilio-alert.conf"
# create a schedule path
PHONEFILE="$DIRECTORY/Schedule/${weeknumber}"
# check the command line options
while getopts ":c:v" opt; do
case "$opt" in
c) CONFIGFILE=$OPTARG ;;
v) VERBOSE=1 ;;
*) echo "Unknown param: $opt"; usage ;;
esac
done
# test configfile
if [ -n "$CONFIGFILE" -a ! -f "$CONFIGFILE" ]; then echo "Configfile not found: $CONFIGFILE"; usage; fi
# source configfile
if [ "$VERBOSE" -eq 1 ]; then echo "Reading twilio-alert.conf..."; fi
if [ -n "$CONFIGFILE" ]; then . "$CONFIGFILE"; fi
# get the phone number
if [ "$UseWeeklySchedule" -eq 1 ];
then
PHONENUMBER=$(cat $PHONEFILE)
else
PHONENUMBER="$OnCallNumber"
fi
echo "$1" | $DIRECTORY/twilio-sms.sh -c $DIRECTORY/twilio-sms.conf $PHONENUMBER
echo ok