This repository has been archived by the owner on Aug 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun
executable file
·68 lines (56 loc) · 1.5 KB
/
run
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
#!/bin/bash
set -e
readonly HOSTNAME=$(hostname -f)
readonly MONGOOSEIMCTL="${MONGOOSE_ROOT}/bin/mongooseimctl"
readonly CONFIGFILE="${MONGOOSE_ROOT}/etc/ejabberd.cfg"
readonly CONFIGTEMPLATE="${MONGOOSE_ROOT}/etc/ejabberd.cfg.tpl"
readonly LOGDIR="${MONGOOSE_ROOT}/var/log"
readonly PYTHON_JINJA2="import os;
import sys;
import jinja2;
sys.stdout.write(
jinja2.Template
(sys.stdin.read()
).render(env=os.environ))"
_trap() {
echo "Stopping mongooseim..."
if ctl stop ; then
local cnt=0
sleep 1
while ctl status || test $? = 1 ; do
cnt=`expr $cnt + 1`
if [ $cnt -ge 60 ] ; then
break
fi
sleep 1
done
fi
}
## setup
echo "Generating mongooseim config file..."
cat ${CONFIGTEMPLATE} \
| python -c "${PYTHON_JINJA2}" \
> ${CONFIGFILE}
# Catch signals and shutdown mongooseim
# trap _trap SIGTERM SIGINT
## run mongooseim
case "$@" in
start)
echo "Starting mongooseim..."
exec ${MONGOOSEIMCTL} "live"
# child=$!
# # echo "post process"
# # exec ${MONGOOSEIMCTL} "started"
# # echo "post sleep"
# # PID=`ps ax -o pid= -o command=|\
# # grep "$MONGOOSE_ROOT/.*/[b]eam"|awk '{print $1}'`
# echo "wait $child"
# wait $child
echo "ending"
tail -F ${LOGDIR}/ejabberd.log
;;
live)
echo "Starting mongooseim in 'live' mode..."
exec ${MONGOOSEIMCTL} "live"
;;
esac