summaryrefslogtreecommitdiffstats
path: root/www/caudium10/files/caudium.sh
blob: e337a8ccb4582167e39a0a2af964494902e5a454 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/sh
# init.d script for Caudium. Set the variables below to something fitting..
# This is only an example script.
#############

# The server directory where the 'start' script is located.
#
caudiumhome=@@PREFIX@@/caudium/server/

# Set this to something unique to be able to stop, reload and restart
# with this init script. It will override the setting in the config
# interface. '0' is typically replaced with the uid.
#
pidfile=/tmp/caudium_pid

# Set these to kill all processes owned by wwwuser on stop. Useful to
# reap CGI scripts.
#
# killallwww=yes
# wwwuser=www

umask 022

# If you want to start with another configuration directory:
#
# configdir=dirname

# Here you can add extra flags to the start script, like enabling or
# disabling threads.
# 
# flags="--without-threads"
flags="--with-threads"

### Check if that caudium is configured...
if [ ! -f @@PREFIX@@/caudium/configurations/Global_Variables ]
then
  echo "This server need some configuration...."
  echo "Please login as caudium user and go to @@PREFIX@@/caudium/server"
  echo "and type ./install to configure your server...."
  exit 0
fi

### You should not _have_ to change anything below here...

test -n "$pidfile" && flags="$flags --pid-file=$pidfile"
test -n "$configdir" && flags="$flags --config-dir=$configdir"

case $1 in
	'start')
          echo "Starting Caudium from $caudiumhome..."
	  if [ -z "$pidfile" ]; then
	    echo "Warning: No pid file set - cannot stop or reload."
	  elif [ -f "$pidfile" ]; then
	    read pid < $pidfile
	    if kill -0 $pid ; then
	      echo "Caudium is already running."
	      exit 0
	    fi
	    rm -f $pidfile
	    if [ -f "$pidfile" ]; then
	      echo Cannot remove pid file $pidfile
	      exit 1
	    fi
	  fi
	  if [ -x "$caudiumhome/start" ]; then
 	    cd $caudiumhome
	    ./start $flags 2>/dev/null
            echo "Done."
          else
            echo "I cannot find the Caudium dir '('$caudiumhome')'"
	  fi
	;;

	'reload')
	  if [ -z "$pidfile" ] ; then
	    echo "No pid file set."
	    exit 1
	  fi
	  echo "Reloading configurations..."
	  if [ -f $pidfile ] ; then
	    read pid < $pidfile
	    kill -HUP $pid || kill 1 $pid
	    exit 0
	  fi
	  echo "Caudium doesn't seem to be running."
	  ;;

	'restart')
	  if [ -z "$pidfile" ] ; then
	    echo "No pid file set."
	    exit 1
	  fi
	  echo Restarting Caudium...
	  if [ -f "$pidfile" ] ; then
	    read pid < $pidfile
	    kill -INT $pid || kill 2 $pid
	    rm "$pidfile"
	    echo Done.
	    exit 0
	  fi
	  echo "Caudium doesn't seem to be running."
	  echo Starting a new Caudium in $caudiumhome...
	  if [ -x "$caudiumhome/start" ]; then
 	    cd $caudiumhome
	    ./start $flags 2>/dev/null
          else
            echo "I cannot find the Caudium dir '('$caudiumhome')'"
	  fi
          echo "Done."
	;;

	'stop')
	   if [ -z "$pidfile" ] ; then
	     echo "No pid file set."
	     exit 1
	   fi
           echo "Stopping Caudium..."
	   if [ -f $pidfile ] ; then
	     if kill `cat $pidfile` ; then
               echo Caudium stopped.
	     fi
	     rm $pidfile
	   else
	     echo "Caudium doesn't seem to be running."
           fi
           # Get all the CGI scripts... :-)
           if [ x$killallwww = xyes ] ; then
	     echo Killing all programs running as the $wwwuser user.
             su $wwwuser -c "kill -9 -1"
           fi
	;;

	*)
          echo "Syntax: $0 [start|stop|restart|reload]"
          ;;
esac

exit 0
OpenPOWER on IntegriCloud