-
Notifications
You must be signed in to change notification settings - Fork 0
/
fifteen
40 lines (33 loc) · 924 Bytes
/
fifteen
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
#!/bin/sh
#
# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/apccontrol when the UPS
# goes on batteries.
#
HOSTNAME=`hostname`
MGMT_BOT_ID=""
CLUBWIDE_BOT_ID=""
GROUPME_API_URL="https://api.groupme.com/v3/bots/post"
# Sleep for 15 minutes (900 seconds)
sleep 900
timeleft=$(sudo apcaccess -p TIMELEFT)
(
echo "To: $SYSADMIN"
echo "From: wbor-smtp@bowdoin.edu"
echo "Subject: $timeleft remaining"
echo ""
echo "Estimated time remaining: $timeleft."
) | sudo $APCUPSD_MAIL $SYSADMIN
curl -s -X POST $GROUPME_API_URL \
-H "Content-Type: application/json" \
-d '{
"text": "Estimated time remaining: '"$timeleft"'",
"bot_id": "'"$MGMT_BOT_ID"'"
}'
curl -s -X POST $GROUPME_API_URL \
-H "Content-Type: application/json" \
-d '{
"text": "Estimated time remaining: '"$timeleft"'",
"bot_id": "'"$CLUBWIDE_BOT_ID"'"
}'
exit 0