#!/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 # 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. # sogod Scalable OpenGroupware.org (Inverse edition) PREFORK=1 SOGO_ARGS="" USER=sogo PATH=/sbin:/bin:/usr/sbin:/usr/bin . /lib/lsb/init-functions if [ -z "$GNUSTEP_SYSTEM_ROOT" ] then . /usr/GNUstep/System/Library/Makefiles/GNUstep.sh fi REAL_DAEMON=sogod DAEMON=/usr/sbin/sogod NAME=sogod DESC="Scalable OpenGroupware.Org (Inverse edition)" PIDFILE=/var/run/sogo/sogod. if [ -f /etc/sysconfig/sogo ]; then . /etc/sysconfig/sogo 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 sogo user." exit 1 fi } checkDir /var/run/sogo checkDir /var/spool/sogo #set -e start() { echo $"Starting $DESC: " for ((a=1; a <= PREFORK ; a++)) do ppid="`cat ${PIDFILE}${a} 2> /dev/null`" if [ -n "$ppid" ] then ppid="`ps --pid ${ppid} -o pid=`" if [ -n "$ppid" ] then echo " $DAEMON $a already running. Skipped." else rm -f ${PIDFILE}${a} startproc -u "$USER" "$DAEMON" $a echo " $DAEMON $a (stale pid file removed)" fi else startproc -u "$USER" "$DAEMON" $a echo " $DAEMON $a" fi sleep 1 done } stop() { echo $"Stopping $DESC: " su "$USER" -c '/usr/bin/killall gdnc >& /dev/null' # We kill the parent processes with SIGTERM so that they # can exit gracefully. for ((a=1; a <= PREFORK ; a++)) do ppid="`cat ${PIDFILE}${a} 2> /dev/null`" if [ -n "$ppid" ] then ppid="`ps --pid ${ppid} -o pid=`" if [ -n "$ppid" ] then if kill $ppid >& /dev/null then echo " $DAEMON $a stopped" fi else echo " $DAEMON $a not running" fi else echo " $DAEMON $a not running" fi done sleep 1 # We kill the parent and child processes with SIGKILL to make sure they # really are shutdown, and then we remove their pidfile. for ((a=1; a <= PREFORK ; a++)) do ppid="`cat ${PIDFILE}${a} 2> /dev/null`" if [ -n "$ppid" ] then ppid="`ps --pid ${ppid} -o pid= 2> /dev/null`" if [ -n "$ppid" ] then kill -9 $ppid >& /dev/null pid="`ps --ppid ${ppid} -o pid= 2> /dev/null`" if [ -n "$pid" ] then kill -9 $pid >& /dev/null fi echo " $DAEMON $a killed" fi fi rm -f ${PIDFILE}${a} done } restart() { echo $"Restarting $DESC: " su "$USER" -c '/usr/bin/killall gdnc >& /dev/null' for ((a=1; a <= PREFORK ; a++)) do ppid="`cat ${PIDFILE}${a} 2> /dev/null`" if [ -n "$ppid" ] then ppid="`ps --pid ${ppid} -o pid=`" if [ -n "$ppid" ] then kill $ppid >& /dev/null sleep 1 fi ppid="`ps --pid ${ppid} -o pid=`" if [ -n "$ppid" ] then pid="`ps --ppid ${ppid} -o pid=`" kill -9 $ppid >& /dev/null kill -9 $pid >& /dev/null fi rm -f ${PIDFILE}${a} fi startproc -u "$USER" "$DAEMON" $a echo " $DAEMON $a" done } case "$1" in start) start ;; stop) stop ;; restart|force-reload) restart ;; status) status $REAL_DAEMON ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 exit 1 ;; esac exit 0