-
Notifications
You must be signed in to change notification settings - Fork 1
/
alert
executable file
·61 lines (48 loc) · 1.42 KB
/
alert
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
55
56
57
58
59
60
61
#!/bin/sh
# This script will be called by different parts of the DOMjudge system
# and allows the administrator to flexibly configure a way to get
# notified of important messages. By default this script calls 'beep'
# if available.
# Calling syntax: $0 <msgtype> [<description>]
MSGTYPE=$1
if [ -z "$MSGTYPE" ]; then
echo "Error: missing required message type argument."
exit 1
fi
shift
DESCRIPTION="$*"
# shellcheck disable=SC2230
BEEPCMD=$(which beep 2>/dev/null)
beep()
{
[ -x "$BEEPCMD" ] && "$BEEPCMD" "$@"
}
case "$MSGTYPE" in
error) # internal system error
beep -l 1000 -d 500 -f 800 -n -l 1000 -d 500 -f 1000 -n \
-l 1000 -d 500 -f 800 -n -l 1000 -d 500 -f 1000 -n \
-l 1000 -d 500 -f 800 -n -l 1000 -d 500 -f 1000
;;
warning) # important system warning
beep -l 1000 -d 500 -f 300 -n -l 1000 -d 500 -f 200 -n \
-l 1000 -d 500 -f 300 -n -l 1000 -d 500 -f 200
;;
usererr) # user error
beep -l 1000 -d 500 -f 800 -n -l 1000 -d 500 -f 1000 -n \
-l 1000 -d 500 -f 800 -n -l 1000 -d 500 -f 1000 -n \
-l 1000 -d 500 -f 800 -n -l 1000 -d 500 -f 1000
;;
submit) # team submission received
# beep -f 400 -l 100 -n -f 400 -l 70
;;
accept) # submission judged and accepted
beep -f 400 -l 100 -n -f 500 -l 70
;;
reject) # submission judged and rejected
# beep -f 400 -l 100 -n -f 350 -l 70
;;
*)
echo "Error: unknown message type '$MSGTYPE' specified."
exit 1
;;
esac