summaryrefslogtreecommitdiff
path: root/packages/openpbx/files/init
blob: 0ce88c462654553a5199316ef87810f8c6509809 (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
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
#! /bin/sh 
#
# This is an init script for openembedded
# Copy it to /etc/init.d/openpbx and type
# > update-rc.d openpbx defaults 60
#
openpbx=/usr/sbin/openpbx
pidfile=/var/run/openpbx.org/openpbx.pid

test -x "$openpbx" || exit 0

case "$1" in
  start)
    echo -n "Starting OpenPBX"
    start-stop-daemon --start --quiet --exec $openpbx -- -npq
    echo "."
    ;;
  stop)
    echo -n "Stopping OpenPBX"
    $openpbx -rx "stop gracefully"
    sleep 4
    if [ -f $pidfile ]; then
      start-stop-daemon --stop --quiet --pidfile $pidfile
    fi
    echo "."
    ;;
  force-stop)
    echo -n "Stopping OpenPBX"
    $openpbx -rx "stop now"
    sleep 2
    if [ -f $pidfile ]; then
      start-stop-daemon --stop --quiet --pidfile $pidfile
    fi
    echo "."
    ;;
  restart)
    echo -n "Restarting OpenPBX"
    if [ -f $pidfile ]; then
      $openpbx -rx "restart gracefully"
      sleep 2
    else
      start-stop-daemon --start --quiet --exec $openpbx -- -npq
    fi
    ;;
  force-restart)
    echo -n "Forcibly Restarting OpenPBX"
    if [ -f $pidfile ]; then
      $openpbx -rx "restart now"
      sleep 2
    else
      start-stop-daemon --start --quiet --exec $openpbx -- -npq
    fi
    ;;
  reload)
    echo -n "Reloading OpenPBX Configuration"
    if [ -f $pidfile ]; then
      $openpbx -rx "reload"
    else
      start-stop-daemon --start --quiet --exec $openpbx -- -npq
    fi
    echo "."
    ;;
  logger-reload)
#    echo -n "Restating OpenPBX Logger"
    if [ -f $pidfile ]; then
      $openpbx -rx "logger reload"
    fi
#    echo "."
    ;;
  *)
    echo "Usage: /etc/init.d/openpbx {start|stop|force-stop|restart|force-restart|reload|logger-reload}"
    exit 1
esac

exit 0