2009-04-01 15:38:46 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# chkconfig: 2345 85 15
|
|
|
|
# description: SOGo is a groupware server
|
|
|
|
# processname: sogod
|
|
|
|
# config: /etc/sysconfig/sogo
|
|
|
|
# config: /etc/httpd/conf.d/SOGo.conf
|
|
|
|
# pidfile: /var/run/sogo/sogod.pid
|
|
|
|
|
|
|
|
# SOGo init script for SUSE Linux Enterprise Server
|
|
|
|
#
|
|
|
|
# Copyright (C) 2007-2009 Inverse inc.
|
|
|
|
#
|
|
|
|
# Authors: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
|
|
|
# Francis Lachapelle <flachapelle@inverse.ca>
|
|
|
|
#
|
|
|
|
# This file is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
# any later version.
|
|
|
|
#
|
|
|
|
# This file is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; see the file COPYING. If not, write to
|
|
|
|
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
# Boston, MA 02111-1307, USA.
|
|
|
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
|
|
|
|
2009-11-12 19:30:21 +01:00
|
|
|
NAME=sogo
|
|
|
|
DAEMON=/usr/GNUstep/System/Tools/Admin/sogod
|
2009-04-01 15:38:46 +02:00
|
|
|
DESC="Scalable OpenGroupware.Org (Inverse edition)"
|
|
|
|
|
2009-11-12 19:30:21 +01:00
|
|
|
USER=$NAME
|
|
|
|
PREFORK=1
|
2009-04-01 15:38:46 +02:00
|
|
|
|
2009-11-12 19:30:21 +01:00
|
|
|
PIDFILE=/var/run/$NAME/$NAME.pid
|
|
|
|
LOGFILE=/var/log/$NAME/$NAME.log
|
|
|
|
|
|
|
|
if [ -f /etc/sysconfig/$NAME ]; then
|
|
|
|
. /etc/sysconfig/$NAME
|
2009-04-01 15:38:46 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -x $DAEMON ]; then
|
|
|
|
echo "$DAEMON is not executable."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
checkDir() {
|
|
|
|
directory="$1"
|
|
|
|
if [ ! -d "$directory" ]
|
|
|
|
then
|
|
|
|
echo "$directory does not exist."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ `/usr/bin/stat "$directory" -c %U` != "$USER" ]
|
|
|
|
then
|
2009-11-12 19:30:21 +01:00
|
|
|
echo "$directory is not owned by the '$USER' user."
|
2009-04-01 15:38:46 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2009-11-12 19:30:21 +01:00
|
|
|
checkDir /var/run/$NAME
|
|
|
|
checkDir /var/spool/$NAME
|
|
|
|
checkDir /var/log/$NAME
|
|
|
|
|
|
|
|
. /lib/lsb/init-functions
|
|
|
|
if [ -z "$GNUSTEP_SYSTEM_ROOT" ]
|
|
|
|
then
|
|
|
|
. /usr/GNUstep/System/Library/Makefiles/GNUstep.sh
|
|
|
|
fi
|
2009-04-01 15:38:46 +02:00
|
|
|
|
2009-11-12 19:30:21 +01:00
|
|
|
DAEMON_OPTS="-WOWorkersCount $PREFORK -WOPidFile $PIDFILE -WOLogFile $LOGFILE"
|
2009-04-01 15:38:46 +02:00
|
|
|
|
|
|
|
start() {
|
|
|
|
echo $"Starting $DESC: "
|
2009-11-12 19:30:21 +01:00
|
|
|
pid="`cat $PIDFILE 2> /dev/null`"
|
|
|
|
if [ -n "$pid" ]
|
|
|
|
then
|
|
|
|
pid="`ps --pid ${pid} -o pid=`"
|
|
|
|
if [ -n "$pid" ]
|
2009-04-01 15:38:46 +02:00
|
|
|
then
|
2009-11-12 19:30:21 +01:00
|
|
|
echo " $NAME already running. Skipped."
|
2009-04-01 15:38:46 +02:00
|
|
|
else
|
2009-11-12 19:30:21 +01:00
|
|
|
rm -f $PIDFILE
|
|
|
|
startproc -u "$USER" -p $PIDFILE "$DAEMON" $DAEMON_OPTS
|
|
|
|
echo " $NAME (stale pid file removed)"
|
2009-04-01 15:38:46 +02:00
|
|
|
fi
|
2009-11-12 19:30:21 +01:00
|
|
|
else
|
|
|
|
startproc -u "$USER" -p $PIDFILE "$DAEMON" $DAEMON_OPTS
|
|
|
|
echo " $NAME"
|
|
|
|
fi
|
2009-04-01 15:38:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
echo $"Stopping $DESC: "
|
|
|
|
# We kill the parent processes with SIGTERM so that they
|
|
|
|
# can exit gracefully.
|
2009-11-12 19:30:21 +01:00
|
|
|
pid="`cat $PIDFILE 2> /dev/null`"
|
|
|
|
if [ -n "$pid" ]
|
|
|
|
then
|
|
|
|
pid="`ps --pid ${pid} -o pid=`"
|
|
|
|
if [ -n "$pid" ]
|
2009-04-01 15:38:46 +02:00
|
|
|
then
|
2009-11-12 19:30:21 +01:00
|
|
|
if kill $pid >& /dev/null
|
2009-04-01 15:38:46 +02:00
|
|
|
then
|
2009-11-12 19:30:21 +01:00
|
|
|
sleep 1
|
|
|
|
pid="`ps --pid ${pid} -o pid=`"
|
|
|
|
if [ -n "$pid" ]
|
|
|
|
then
|
|
|
|
echo " $NAME stopped"
|
|
|
|
else
|
2009-04-01 15:38:46 +02:00
|
|
|
kill -9 $pid >& /dev/null
|
2009-11-12 19:30:21 +01:00
|
|
|
echo " $NAME killed"
|
|
|
|
fi
|
|
|
|
rm -f $PIDFILE
|
2009-04-01 15:38:46 +02:00
|
|
|
fi
|
2009-11-12 19:30:21 +01:00
|
|
|
else
|
|
|
|
echo " $NAME not running"
|
2009-04-01 15:38:46 +02:00
|
|
|
fi
|
2009-11-12 19:30:21 +01:00
|
|
|
else
|
|
|
|
echo " $NAME not running"
|
|
|
|
fi
|
2009-04-01 15:38:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
restart() {
|
|
|
|
echo $"Restarting $DESC: "
|
2009-11-12 19:30:21 +01:00
|
|
|
pid="`cat $PIDFILE 2> /dev/null`"
|
|
|
|
if [ -n "$pid" ]
|
|
|
|
then
|
|
|
|
pid="`ps --pid ${pid} -o pid=`"
|
|
|
|
if [ -n "$pid" ]
|
2009-04-01 15:38:46 +02:00
|
|
|
then
|
2009-11-12 19:30:21 +01:00
|
|
|
if kill $pid >& /dev/null
|
2009-04-01 15:38:46 +02:00
|
|
|
then
|
2009-11-12 19:30:21 +01:00
|
|
|
sleep 1
|
|
|
|
pid="`ps --pid ${pid} -o pid=`"
|
|
|
|
if [ -n "$pid" ]
|
|
|
|
then
|
|
|
|
kill -9 $pid >& /dev/null
|
|
|
|
fi
|
2009-04-01 15:38:46 +02:00
|
|
|
fi
|
|
|
|
fi
|
2009-11-12 19:30:21 +01:00
|
|
|
fi
|
|
|
|
startproc -u "$USER" -p $PIDFILE "$DAEMON" $DAEMON_OPTS
|
|
|
|
echo " $NAME"
|
2009-04-01 15:38:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
2009-11-12 19:30:21 +01:00
|
|
|
restart)
|
2009-04-01 15:38:46 +02:00
|
|
|
restart
|
|
|
|
;;
|
|
|
|
status)
|
2009-11-12 19:30:21 +01:00
|
|
|
checkproc -p $PIDFILE $DAEMON
|
2009-04-01 15:38:46 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
N=/etc/init.d/$NAME
|
2009-11-12 19:30:21 +01:00
|
|
|
echo "Usage: $N {start|stop|restart|status}" >&2
|
2009-04-01 15:38:46 +02:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|