File: server-ctl

package info (click to toggle)
roundup 1.2.1-10%2Betch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 4,764 kB
  • ctags: 3,756
  • sloc: python: 30,296; sh: 1,497; perl: 23; makefile: 22
file content (96 lines) | stat: -rwxr-xr-x 1,874 bytes parent folder | download | duplicates (8)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh

#
# Configuration
#
CONFFILE="/var/roundup/server-config.ini"

# this will end up with extra space, but it should be ignored in the script
PIDFILE=`grep '^pidfile' ${CONFFILE} | awk -F = '{print $2}' `
SERVER="/usr/local/bin/roundup-server -C ${CONFFILE}"
ERROR=0
ARGV="$@"
if [ "x$ARGV" = "x" ] ; then
    ARGS="help"
fi

if [ -z "${PIDFILE}" ] ; then
    echo "pidfile option must be set in configuration file"
    exit 1
fi

for ARG in $@ $ARGS
do
    # check for pidfile
    if [ -f $PIDFILE ] ; then
	PID=`cat $PIDFILE`
	if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then
	    STATUS="roundup-server (pid $PID) running"
	    RUNNING=1
	else
	    STATUS="roundup-server (pid $PID?) not running"
	    RUNNING=0
	fi
    else
	STATUS="roundup-server (no pid file) not running"
	RUNNING=0
    fi

    case $ARG in
    start)
	if [ $RUNNING -eq 1 ] ; then
	    echo "$0 $ARG: roundup-server (pid $PID) already running"
	    continue
	fi
	if $SERVER ; then
	    echo "$0 $ARG: roundup-server started"
	else
	    echo "$0 $ARG: roundup-server could not be started"
	    ERROR=1
	fi
	;;
    condstart)
	if [ $RUNNING -eq 1 ] ; then
	    continue
	fi
	if $SERVER ; then
	    echo "$0 $ARG: roundup-server started"
	else
	    echo "$0 $ARG: roundup-server could not be started"
	    ERROR=1
	fi
	;;
    stop)
	if [ $RUNNING -eq 0 ] ; then
	    echo "$0 $ARG: $STATUS"
	    continue
	fi
	if kill $PID ; then
	    echo "$0 $ARG: roundup-server stopped"
	else
	    echo "$0 $ARG: roundup-server could not be stopped"
	    ERROR=2
	fi
	;;
    status)
	echo $STATUS
	;;
    *)
	echo "usage: $0 (start|condstart|stop|status)"
	cat <<EOF

    start      - start roundup-server
    condstart  - start roundup-server if it's not running
    stop       - stop roundup-server
    status     - display roundup-server status

EOF
	ERROR=3
    ;;

    esac

done

exit $ERROR