aboutsummaryrefslogtreecommitdiff
path: root/business/tinyerp-server/rc.tinyerp-server
blob: a5314c0f9071a91e11af60f3c3f3b42d4717d288 (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
#!/bin/sh
# Start/stop/restart tinyerp-server.
# $Id: rc.tinyerp-server,v 1.0 2008/06/02
# Author: Heinz Wiesinger <hmwiesinger@gmx.at>
# ---------------------------------------------------------------------------

PIDFILE=/var/spool/tinyerp/tinyerp-server.pid
LOCKFILE=/var/lock/subsys/tinyerp-server
LOGFILE=/var/log/tinyerp/tinyerp-server.log

# Start tinyerp:
tinyerp_start() {
  if [ -x /usr/bin/tinyerp-server ]; then
    echo "Starting tinyerp server:  /usr/bin/tinyerp-server "
    if [ -e "$LOCKFILE" ]; then
        echo "tinyerp server already running!"
        echo "Please remove $LOCKFILE"
    else
        /usr/bin/tinyerp-server --pidfile=$PIDFILE --logfile=$LOGFILE \
          -c /etc/tinyerp/tinyerp-server.conf &
        touch $LOCKFILE
    fi
  fi
}

# Stop tinyerp:
tinyerp_stop() {
  echo "Stopping tinyerp-server"
  kill -TERM $(cat $PIDFILE) > /dev/null 2>&1
  rm -f $LOCKFILE
}

# Restart tinyerp:
tinyerp_restart() {
  tinyerp_stop
  sleep 1
  tinyerp_start
}

case "$1" in
'start')
  tinyerp_start
  ;;
'stop')
  tinyerp_stop
  ;;
'restart')
  tinyerp_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac