building-foam: foam-init.d-centos

File foam-init.d-centos, 1.4 kB (added by ibaldin, 7 years ago)

FOAM init.d script for CentOS

Line 
1#!/bin/bash
2#
3# foam          This shell script takes care of starting and stopping
4#
5# chkconfig: - 58 74
6
7### BEGIN INIT INFO
8# Provides: ntpd
9# Required-Start: $network $local_fs $remote_fs
10# Required-Stop: $network $local_fs $remote_fs
11# Should-Start: $syslog $named ntpdate
12# Should-Stop: $syslog $named
13# Short-Description: start and stop foam
14### END INIT INFO
15
16# Source function library.
17. /etc/init.d/functions
18
19# Source networking configuration.
20. /etc/sysconfig/network
21
22#prog=/opt/foam/sbin/foam.fcgi
23prog=/opt/foam/sbin/start-foam.sh
24lockfile=/var/lock/subsys/foam
25
26start() {
27        [ "$EUID" != "0" ] && exit 4
28        [ "$NETWORKING" = "no" ] && exit 1
29        [ -x $prog ] || exit 5
30
31        # Start daemons.
32        echo -n $"Starting $prog: "
33        export PYTHONPATH=/opt/foam/lib
34        daemon --user nginx $prog $OPTIONS &
35        RETVAL=$?
36        echo
37        [ $RETVAL -eq 0 ] && touch $lockfile
38        return $RETVAL
39}
40
41stop() {
42        [ "$EUID" != "0" ] && exit 4
43        echo -n $"Shutting down $prog: "
44        killproc foam.fcgi
45        RETVAL=$?
46        echo
47        [ $RETVAL -eq 0 ] && rm -f $lockfile
48        return $RETVAL
49}
50
51# See how we were called.
52case "$1" in
53  start)
54        start
55        ;;
56  stop)
57        stop
58        ;;
59  status)
60        status $prog
61        ;;
62  restart|force-reload)
63        stop
64        start
65        ;;
66  try-restart|condrestart)
67        if status $prog > /dev/null; then
68            stop
69            start
70        fi
71        ;;
72  reload)
73        exit 3
74        ;;
75  *)
76        echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
77        exit 2
78esac