-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint.sh
executable file
·79 lines (60 loc) · 1.07 KB
/
docker-entrypoint.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
terminate() {
trap - SIGINT SIGTERM
kill $$
}
ensure_process() {
pid_length=`pidof $1|awk '{print length($0)}'`
if [ "$pid_length" == "0" -a "$pid_length" != "" ]; then
echo "Process '$1' not found, aborting!"
terminate
fi
}
start_cron() {
crond -s
}
stop_cron() {
kill `pidof crond`
}
start_mysql() {
mysqld_safe > /dev/null 2>&1 &
sleep 5
ensure_process mysqld
}
stop_mysql() {
mysqladmin --socket=/var/lib/mysql/mysql.sock shutdown
}
start_freepbx() {
fwconsole start --no-interaction -vv
sleep 5
ensure_process asterisk
}
stop_freepbx() {
fwconsole stop --immediate --maxwait=60 --no-interaction -vv
}
start_httpd() {
httpd -k start
sleep 5
ensure_process httpd
}
stop_httpd() {
httpd -k graceful-stop
}
on_exit() {
echo "Stopping services..."
stop_httpd
stop_freepbx
stop_mysql
stop_cron
echo "Shutting down..."
terminate
}
trap on_exit SIGINT SIGTERM
echo "Starting services..."
start_cron
start_mysql
start_freepbx
start_httpd
echo "Services started"
fwconsole dbug &
sleep infinity