mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-03 12:28:51 +00:00
Monotone-Parent: 1a782399b604ae97568989d22d23777b11896071
Monotone-Revision: 03c8c1c0221284dc94112f17b3904d59c31d5c94 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-08-12T18:29:34 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,173 +0,0 @@
|
||||
#! /bin/bash
|
||||
|
||||
# SOGo init script for Debian GNU/Linux
|
||||
#
|
||||
# Copyright (C) 2007-2009 Inverse inc.
|
||||
#
|
||||
# Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
# Ludovic Marcotte <ludovic@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.
|
||||
|
||||
# specify more if you are using a load-balancer
|
||||
PREFORK=3
|
||||
SOGO_ARGS=""
|
||||
USER=sogo
|
||||
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
DAEMON=/usr/sbin/sogod
|
||||
NAME=sogod
|
||||
DESC="Scalable OpenGroupware.Org"
|
||||
|
||||
PIDFILE=/var/run/sogo/sogod.
|
||||
|
||||
if [ -f /etc/default/sogo ]; then
|
||||
. /etc/default/sogo
|
||||
fi
|
||||
|
||||
if [ ! -x $DAEMON ]; then
|
||||
echo "$DAEMON is not executable."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ `/usr/bin/stat /var/run/sogo -c %U` != $USER ]; then
|
||||
echo "/var/run/sogo is not owned by the ${USER}."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ `/usr/bin/stat /var/spool/sogo -c %U` != $USER ]; then
|
||||
echo "/var/spool/sogo is not owned by the ${USER}."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ `/usr/bin/stat /var/log/sogo -c %U` != $USER ]; then
|
||||
echo "/var/log/sogo is not owned by the ${USER}."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
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}
|
||||
start-stop-daemon -c $USER \
|
||||
-b --start --quiet --exec $DAEMON $a
|
||||
echo " $DAEMON $a (stale pid file removed)"
|
||||
fi
|
||||
else
|
||||
start-stop-daemon -c $USER \
|
||||
-b --start --quiet --exec $DAEMON $a
|
||||
echo " $DAEMON $a"
|
||||
fi
|
||||
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|force-reload)
|
||||
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
|
||||
start-stop-daemon -c $USER \
|
||||
-b --start --quiet --exec $DAEMON $a
|
||||
echo " $DAEMON $a"
|
||||
done
|
||||
;;
|
||||
|
||||
*)
|
||||
N=/etc/init.d/$NAME
|
||||
echo "Usage: $N {start|stop|restart|force-reload}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user