Ajout script mise a jour de tracker
[auf_roundup.git] / scripts / server-ctl
CommitLineData
c638d827
CR
1#!/bin/sh
2
3#
4# Configuration
5#
6CONFFILE="/var/roundup/server-config.ini"
7
8# this will end up with extra space, but it should be ignored in the script
9PIDFILE=`grep '^pidfile' ${CONFFILE} | awk -F = '{print $2}' `
10SERVER="/usr/local/bin/roundup-server -C ${CONFFILE}"
11ERROR=0
12ARGV="$@"
13if [ "x$ARGV" = "x" ] ; then
14 ARGS="help"
15fi
16
17if [ -z "${PIDFILE}" ] ; then
18 echo "pidfile option must be set in configuration file"
19 exit 1
20fi
21
22for ARG in $@ $ARGS
23do
24 # check for pidfile
25 if [ -f $PIDFILE ] ; then
26 PID=`cat $PIDFILE`
27 if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then
28 STATUS="roundup-server (pid $PID) running"
29 RUNNING=1
30 else
31 STATUS="roundup-server (pid $PID?) not running"
32 RUNNING=0
33 fi
34 else
35 STATUS="roundup-server (no pid file) not running"
36 RUNNING=0
37 fi
38
39 case $ARG in
40 start)
41 if [ $RUNNING -eq 1 ] ; then
42 echo "$0 $ARG: roundup-server (pid $PID) already running"
43 continue
44 fi
45 if $SERVER ; then
46 echo "$0 $ARG: roundup-server started"
47 else
48 echo "$0 $ARG: roundup-server could not be started"
49 ERROR=1
50 fi
51 ;;
52 condstart)
53 if [ $RUNNING -eq 1 ] ; then
54 continue
55 fi
56 if $SERVER ; then
57 echo "$0 $ARG: roundup-server started"
58 else
59 echo "$0 $ARG: roundup-server could not be started"
60 ERROR=1
61 fi
62 ;;
63 stop)
64 if [ $RUNNING -eq 0 ] ; then
65 echo "$0 $ARG: $STATUS"
66 continue
67 fi
68 if kill $PID ; then
69 echo "$0 $ARG: roundup-server stopped"
70 else
71 echo "$0 $ARG: roundup-server could not be stopped"
72 ERROR=2
73 fi
74 ;;
75 status)
76 echo $STATUS
77 ;;
78 *)
79 echo "usage: $0 (start|condstart|stop|status)"
80 cat <<EOF
81
82 start - start roundup-server
83 condstart - start roundup-server if it's not running
84 stop - stop roundup-server
85 status - display roundup-server status
86
87EOF
88 ERROR=3
89 ;;
90
91 esac
92
93done
94
95exit $ERROR
96