-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsipxhomer.in
113 lines (98 loc) · 2.49 KB
/
sipxhomer.in
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
# sipxhomer - Startup script for sipxhomer
# chkconfig: 35 85 15
# description: sipxhomer is a SIP proxy for telecommunications
# processname: sipxhomer
# Copyright (C) 2007 Pingtel Corp., certain elements licensed under a Contributor Agreement.
# Contributors retain copyright to elements licensed under a Contributor Agreement.
# Licensed to the User under the LGPL license.
. /etc/rc.d/init.d/functions || exit 1
. @SIPX_LIBEXECDIR@/sipx-utils.sh || exit 1
prog=sipxhomer
exec="@SIPX_LIBEXECDIR@/${prog}"
pidfile="@SIPX_RUNDIR@/sipxhomer.pid"
SIPXHOMER_CONFIG="@SIPX_CONFDIR@/sipxhomer.ini"
SIPXHOMER_OPTS="--log-file @SIPX_LOGDIR@/sipxhomer.log --config-file $SIPXHOMER_CONFIG --pid-file $pidfile"
[ -e @SIPX_CONFDIR@/sysconfig/$prog ] && . @SIPX_CONFDIR@/sysconfig/$prog
start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
if [ -n "${NoFork}" ] ; then
runuser - @SIPXPBXUSER@ -c "$exec $SIPXHOMER_OPTS"
else
echo -n $"Starting $prog: "
daemon --user @SIPXPBXUSER@ --pidfile $pidfile $exec $SIPXHOMER_OPTS --daemonize
Status=$?
echo_success
fi
}
stop() {
echo -n $"Stopping sipxhomer: "
# can take a while to shutdown because of relay
# dont wait too long as service availability is in jeopardy
killproc -p "${pidfile}" -d 10 "${exec}"
Status=$?
echo
[ $Status -eq 0 ] && rm -f "${pidfile}"
}
restart() {
stop
start
}
backup() {
for db in homer_db homer_users; do
mysqldump -u root ${db} > @SIPX_TMPDIR@/${db}.sql
done
tar -C @SIPX_TMPDIR@ -cvzf $1 homer_db.sql homer_users.sql
rm @SIPX_TMPDIR@/homer_db.sql @SIPX_TMPDIR@/homer_users.sql
}
restore() {
test -f ${pidfile} && running=yes
if [ "$running" = "yes" ] ; then
stop
fi
for db in homer_db homer_users; do
mysql -u root -e "drop database if exists ${db}; create database ${db};"
tar -xzf $1 -O ${db}.sql | mysql -u root ${db}
done
if [ "$running" = "yes" ] ; then
start
fi
}
case "$1" in
nofork)
NoFork=1
start
;;
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
restart
;;
condrestart)
[ -f ${pidfile} ] && restart || :
;;
status)
status -p "${pidfile}" "${prog}"
Status=$?
;;
configtest)
configtest
;;
backup)
shift
backup $1
;;
restore)
shift
restore $1
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|nofork|backup filename|restore filename}"
Status=1
esac
exit $Status