2007-07-20 22:18:56 +02:00
|
|
|
#!/bin/bash
|
2008-09-05 18:05:59 +02:00
|
|
|
# chkconfig: 2345 85 15
|
2007-09-17 17:40:22 +02:00
|
|
|
# description: SOGo is a groupware server
|
2009-03-19 02:22:09 +01:00
|
|
|
# processname: sogod
|
2007-09-17 17:40:22 +02:00
|
|
|
# config: /etc/sysconfig/sogo
|
|
|
|
# config: /etc/httpd/conf.d/SOGo.conf
|
|
|
|
# pidfile: /var/run/sogo/sogod.pid
|
2007-07-24 20:40:20 +02:00
|
|
|
|
|
|
|
# SOGo init script for RedHat
|
2007-07-20 22:18:56 +02:00
|
|
|
#
|
2009-01-22 16:25:20 +01:00
|
|
|
# Copyright (C) 2007-2009 Inverse inc.
|
2007-07-24 20:40:20 +02:00
|
|
|
#
|
2008-11-07 17:00:31 +01:00
|
|
|
# Authors: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
|
|
|
# Francis Lachapelle <flachapelle@inverse.ca>
|
2007-07-24 20:40:20 +02:00
|
|
|
#
|
|
|
|
# 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.
|
2007-07-19 17:51:18 +02:00
|
|
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
|
|
|
|
2009-11-12 19:30:21 +01:00
|
|
|
NAME=sogo
|
2011-10-17 21:02:12 +02:00
|
|
|
DAEMON=/usr/sbin/sogod
|
2010-06-10 17:07:13 +02:00
|
|
|
DESC="SOGo"
|
2007-07-19 17:51:18 +02:00
|
|
|
|
2009-11-12 19:30:21 +01:00
|
|
|
USER=$NAME
|
|
|
|
PREFORK=1
|
2007-07-19 17:51:18 +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
|
2007-07-19 17:51:18 +02:00
|
|
|
fi
|
|
|
|
|
2007-10-26 22:29:06 +02:00
|
|
|
if [ ! -x $DAEMON ]; then
|
|
|
|
echo "$DAEMON is not executable."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2009-03-23 22:19:54 +01:00
|
|
|
checkDir() {
|
|
|
|
directory="$1"
|
|
|
|
if [ ! -d "$directory" ]
|
|
|
|
then
|
|
|
|
echo "$directory does not exist."
|
|
|
|
exit 1
|
|
|
|
fi
|
2007-10-26 22:29:06 +02:00
|
|
|
|
2009-03-23 22:19:54 +01:00
|
|
|
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-03-23 22:19:54 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
2007-10-26 22:29:06 +02:00
|
|
|
|
2009-11-12 19:30:21 +01:00
|
|
|
checkDir /var/run/$NAME
|
|
|
|
checkDir /var/spool/$NAME
|
|
|
|
checkDir /var/log/$NAME
|
|
|
|
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
if [ -z "$GNUSTEP_SYSTEM_ROOT" ]
|
|
|
|
then
|
2011-11-16 01:35:23 +01:00
|
|
|
. /usr/share/GNUstep/Makefiles/GNUstep.sh
|
2009-11-12 19:30:21 +01:00
|
|
|
fi
|
2007-07-19 17:51:18 +02:00
|
|
|
|
2009-11-12 19:30:21 +01:00
|
|
|
DAEMON_OPTS="-WOWorkersCount $PREFORK -WOPidFile $PIDFILE -WOLogFile $LOGFILE"
|
2007-07-19 17:51:18 +02:00
|
|
|
|
2010-08-30 21:38:56 +02:00
|
|
|
RETVAL=0
|
|
|
|
|
2008-11-07 17:00:31 +01: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-03-23 22:16:25 +01:00
|
|
|
then
|
2009-11-12 19:30:21 +01:00
|
|
|
echo " $NAME already running. Skipped."
|
2010-08-30 21:38:56 +02:00
|
|
|
RETVAL=0
|
2009-03-23 22:16:25 +01:00
|
|
|
else
|
2009-11-12 19:30:21 +01:00
|
|
|
rm -f $PIDFILE
|
|
|
|
daemon --user="$USER" --pidfile="$PIDFILE" "$DAEMON" $DAEMON_OPTS
|
2010-08-30 21:38:56 +02:00
|
|
|
RETVAL=$?
|
2009-11-12 19:30:21 +01:00
|
|
|
echo " $NAME (stale pid file removed)"
|
2009-03-23 22:16:25 +01:00
|
|
|
fi
|
2009-11-12 19:30:21 +01:00
|
|
|
else
|
|
|
|
daemon --user="$USER" --pidfile="$PIDFILE" "$DAEMON" $DAEMON_OPTS
|
2010-08-30 21:38:56 +02:00
|
|
|
RETVAL=$?
|
2009-11-12 19:30:21 +01:00
|
|
|
echo " $NAME"
|
|
|
|
fi
|
2010-08-30 21:38:56 +02:00
|
|
|
return $RETVAL
|
2008-11-07 17:00:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
echo $"Stopping $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-03-23 22:16:25 +01:00
|
|
|
then
|
2009-12-14 17:02:15 +01:00
|
|
|
kill $pid >& /dev/null
|
2010-08-30 21:38:56 +02:00
|
|
|
RETVAL=$?
|
2009-12-14 17:02:15 +01:00
|
|
|
echo " $NAME stopped"
|
2009-11-12 19:30:21 +01:00
|
|
|
else
|
|
|
|
echo " $NAME not running"
|
2010-08-30 21:38:56 +02:00
|
|
|
RETVAL=0
|
2009-03-23 22:16:25 +01:00
|
|
|
fi
|
2009-11-12 19:30:21 +01:00
|
|
|
else
|
|
|
|
echo " $NAME not running"
|
2010-08-30 21:38:56 +02:00
|
|
|
RETVAL=0
|
2009-11-12 19:30:21 +01:00
|
|
|
fi
|
2010-08-30 21:38:56 +02:00
|
|
|
return $RETVAL
|
2009-03-23 22:16:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
restart() {
|
|
|
|
echo $"Restarting $DESC: "
|
2009-11-12 19:30:21 +01:00
|
|
|
pid="`cat $PIDFILE 2> /dev/null`"
|
|
|
|
if [ -n "$pid" ]
|
|
|
|
then
|
2009-12-14 17:02:15 +01:00
|
|
|
kill $pid >& /dev/null
|
2009-11-12 19:30:21 +01:00
|
|
|
fi
|
2009-12-14 17:02:15 +01:00
|
|
|
sleep 1
|
2009-11-12 19:30:21 +01:00
|
|
|
daemon --user="$USER" --pidfile="$PIDFILE" "$DAEMON" $DAEMON_OPTS
|
|
|
|
echo " $NAME"
|
2008-11-07 17:00:31 +01:00
|
|
|
}
|
|
|
|
|
2007-07-19 17:51:18 +02:00
|
|
|
case "$1" in
|
|
|
|
start)
|
2008-11-07 17:00:31 +01:00
|
|
|
start
|
2007-07-19 17:51:18 +02:00
|
|
|
;;
|
|
|
|
stop)
|
2008-11-07 17:00:31 +01:00
|
|
|
stop
|
2007-07-19 17:51:18 +02:00
|
|
|
;;
|
2009-11-12 19:30:21 +01:00
|
|
|
restart)
|
2009-03-23 22:16:25 +01:00
|
|
|
restart
|
2007-07-19 17:51:18 +02:00
|
|
|
;;
|
2007-07-20 22:18:56 +02:00
|
|
|
status)
|
2009-11-12 19:30:21 +01:00
|
|
|
status -p "$PIDFILE" $DAEMON
|
2007-07-20 22:18:56 +02:00
|
|
|
;;
|
2007-07-19 17:51:18 +02:00
|
|
|
*)
|
|
|
|
N=/etc/init.d/$NAME
|
2009-11-12 19:30:21 +01:00
|
|
|
echo "Usage: $N {start|stop|restart|status}" >&2
|
2007-07-19 17:51:18 +02:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2010-08-30 21:38:56 +02:00
|
|
|
exit $?
|