#!/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 RedHat # # Copyright (C) 2007-2009 Inverse inc. # # Authors: Wolfgang Sourdeau # Francis Lachapelle # # 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 NAME=sogo DAEMON=/usr/GNUstep/System/Tools/Admin/sogod DESC="Scalable OpenGroupware.Org (Inverse edition)" USER=$NAME PREFORK=1 PIDFILE=/var/run/$NAME/$NAME.pid LOGFILE=/var/log/$NAME/$NAME.log if [ -f /etc/sysconfig/$NAME ]; then . /etc/sysconfig/$NAME 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 echo "$directory is not owned by the '$USER' user." exit 1 fi } checkDir /var/run/$NAME checkDir /var/spool/$NAME checkDir /var/log/$NAME . /etc/rc.d/init.d/functions if [ -z "$GNUSTEP_SYSTEM_ROOT" ] then . /usr/GNUstep/System/Library/Makefiles/GNUstep.sh fi DAEMON_OPTS="-WOWorkersCount $PREFORK -WOPidFile $PIDFILE -WOLogFile $LOGFILE" start() { echo $"Starting $DESC: " pid="`cat $PIDFILE 2> /dev/null`" if [ -n "$pid" ] then pid="`ps --pid ${pid} -o pid=`" if [ -n "$pid" ] then echo " $NAME already running. Skipped." else rm -f $PIDFILE daemon --user="$USER" --pidfile="$PIDFILE" "$DAEMON" $DAEMON_OPTS echo " $NAME (stale pid file removed)" fi else daemon --user="$USER" --pidfile="$PIDFILE" "$DAEMON" $DAEMON_OPTS echo " $NAME" fi } stop() { echo $"Stopping $DESC: " pid="`cat $PIDFILE 2> /dev/null`" if [ -n "$pid" ] then pid="`ps --pid ${pid} -o pid=`" if [ -n "$pid" ] then kill $pid >& /dev/null echo " $NAME stopped" else echo " $NAME not running" fi else echo " $NAME not running" fi } restart() { echo $"Restarting $DESC: " pid="`cat $PIDFILE 2> /dev/null`" if [ -n "$pid" ] then kill $pid >& /dev/null fi sleep 1 daemon --user="$USER" --pidfile="$PIDFILE" "$DAEMON" $DAEMON_OPTS echo " $NAME" } case "$1" in start) start ;; stop) stop ;; restart) restart ;; status) status -p "$PIDFILE" $DAEMON ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|status}" >&2 exit 1 ;; esac exit 0