aboutsummaryrefslogtreecommitdiff
path: root/network/ejabberd/rc.ejabberd
blob: dfd7a3504316fa47294d83ee3be3d8d78017ca20 (plain)
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
#!/bin/bash
# Start/stop/restart the ejabberd xmpp server

bin=/usr/sbin/ejabberdctl

start_ejabberd() {
  echo "Starting ejabberd... "
  $bin start
  $bin started
}

stop_ejabberd() {
  echo "Stoppping ejabberd... "
  $bin stop
  $bin stopped
}

restart_ejabberd() {
  stop_ejabberd
  start_ejabberd
}

status_ejabberd() {
  $bin status
}

force-stop_ejabberd() {
  echo "Killing ejabberd... "
  port=$(/usr/bin/epmd -names | awk -v name=ejabberd '$2==name {print $5}')
  if [ -z "$port" ]; then
    echo "ejabberd not found"
  else
    kill $(lsof -i TCP:$port -s TCP:LISTEN | tail -n +2 | awk '{print $2}')
  fi
}

case "$1" in
start)
  start_ejabberd ;;
stop)
  stop_ejabberd ;;
restart|reload)
  restart_ejabberd ;;
status)
  status_ejabberd ;;
force-stop)
  force-stop_ejabberd ;;
*)
  echo "usage $0 start|stop|restart|status|force-stop"
esac