-#! /bin/sh
+#! /bin/bash
# SOGo init script for Debian GNU/Linux
#
# Copyright (C) 2007 Inverse groupe conseil
#
# 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, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
+PREFORK=3
+SOGO_ARGS=""
+
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/sogod-0.9
NAME=sogo
DESC="Scalable OpenGroupware.Org"
-PIDFILE=/var/run/sogo/sogod.pid
-
-SOGO_ARGS=""
+PIDFILE=/var/run/sogo/sogod.
if [ -f /etc/default/sogo ]; then
. /etc/default/sogo
fi
-test -x $DAEMON || exit 0
+if [ ! -x $DAEMON ]; then
+ echo "$DAEMON is not executable."
+ exit 1
+fi
-#set -e
+if [ `/usr/bin/stat /var/run/sogo -c %U` != "sogo" ]; then
+ echo "/var/run/sogo is not owned by the sogo user."
+ exit 1
+fi
+
+if [ `/usr/bin/stat /var/spool/sogo -c %U` != "sogo" ]; then
+ echo "/var/spool/sogo is not owned by the sogo user."
+ exit 1
+fi
+
+if [ `/usr/bin/stat /var/log/sogo -c %U` != "sogo" ]; then
+ echo "/var/log/sogo is not owned by the sogo user."
+ exit 1
+fi
case "$1" in
start)
echo -n "Starting $DESC: "
- start-stop-daemon -c sogo --pidfile $PIDFILE \
- -b --start --quiet --exec $DAEMON
+ for ((a=1; a <= PREFORK ; a++))
+ do
+ start-stop-daemon -c sogo --pidfile $PIDFILE$a \
+ -b --start --quiet --exec $DAEMON $a
+ done
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
- sogopid=$(cat $PIDFILE)
- kill ${sogopid} 2> /dev/null
- rm -f $PIDFILE
+ for ((a=1; a <= PREFORK ; a++))
+ do
+ sogopid=$(cat $PIDFILE$a)
+ kill ${sogopid} 2> /dev/null
+ rm -f $PIDFILE$a
+ done
echo "$NAME."
;;
restart|force-reload)
- echo -n "Restarting $DESC: "
- sogopid=$(cat $PIDFILE)
- kill ${sogopid} 2> /dev/null
- rm -f $PIDFILE
- sleep 1
- start-stop-daemon -c sogo --pidfile $PIDFILE \
- -b --start --quiet --exec $DAEMON
- echo "$NAME."
+ $0 stop && sleep 2 && $0 start
;;
*)
N=/etc/init.d/$NAME
# sogod Scalable OpenGroupware.org (Inverse edition)
+PREFORK=3
+SOGO_ARGS=""
+
PATH=/sbin:/bin:/usr/sbin:/usr/bin
. /etc/rc.d/init.d/functions
NAME=sogo
DESC="Scalable OpenGroupware.Org (Inverse edition)"
-PIDFILE=/var/run/sogo/sogod.pid
-
-SOGO_ARGS=""
+PIDFILE=/var/run/sogo/sogod.
if [ -f /etc/sysconfig/sogo ]; then
. /etc/sysconfig/sogo
fi
-test -x $DAEMON || exit 0
+if [ ! -x $DAEMON ]; then
+ echo "$DAEMON is not executable."
+ exit 1
+fi
+
+if [ `/usr/bin/stat /var/run/sogo -c %U` != "sogo" ]; then
+ echo "/var/run/sogo is not owned by the sogo user."
+ exit 1
+fi
+
+if [ `/usr/bin/stat /var/spool/sogo -c %U` != "sogo" ]; then
+ echo "/var/spool/sogo is not owned by the sogo user."
+ exit 1
+fi
+
+if [ `/usr/bin/stat /var/log/sogo -c %U` != "sogo" ]; then
+ echo "/var/log/sogo is not owned by the sogo user."
+ exit 1
+fi
#set -e
case "$1" in
start)
echo -n $"Starting $DESC: "
- daemon --user sogo --pidfile $PIDFILE $DAEMON
+ daemon su - sogo -c $DAEMON
+# daemon --user sogo --pidfile $PIDFILE $DAEMON
echo "$NAME."
;;
stop)
echo -n $"Stopping $DESC: "
- killproc -p $PIDFILE $REAL_DAEMON && rm -f $PIDFILE
+ killproc `basename $REAL_DAEMON` && rm -f $PIDFILE
+# killproc -p $PIDFILE $REAL_DAEMON && rm -f $PIDFILE
echo "$NAME."
;;
restart|force-reload)
echo -n $"Restarting $DESC: "
- killproc -p $PIDFILE $REAL_DAEMON && rm -f $PIDFILE
- sleep 1
- daemon --user sogo --pidfile $PIDFILE $DAEMON
+ $0 stop && sleep 2 && $0 start
echo "$NAME."
;;
status)
esac
exit 0
-
+++ /dev/null
-#!/bin/bash
-# chkconfig: - 85 15
-# description: SOGo is a groupware server
-# processname: sogod-0.9
-# 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 Inverse groupe conseil
-#
-# Author: Wolfgang Sourdeau <wsourdeau@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.
-
-# sogod Scalable OpenGroupware.org (Inverse edition)
-
-PATH=/sbin:/bin:/usr/sbin:/usr/bin
-
-. /etc/rc.d/init.d/functions
-
-if [ -z "$GNUSTEP_SYSTEM_ROOT" ]
-then
- . /usr/GNUstep/System/Library/Makefiles/GNUstep.sh
-fi
-
-REAL_DAEMON=$GNUSTEP_SYSTEM_ROOT/Tools/sogod-0.9
-DAEMON=/usr/sbin/sogod
-NAME=sogo
-DESC="Scalable OpenGroupware.Org (Inverse edition)"
-
-PIDFILE=/var/run/sogo/sogod.pid
-
-SOGO_ARGS=""
-
-if [ -f /etc/sysconfig/sogo ]; then
- . /etc/sysconfig/sogo
-fi
-
-test -x $DAEMON || exit 0
-
-#set -e
-
-case "$1" in
- start)
- echo -n $"Starting $DESC: "
- daemon su - sogo -c $DAEMON
- echo "$NAME."
- ;;
- stop)
- echo -n $"Stopping $DESC: "
- killproc `basename $REAL_DAEMON` && rm -f $PIDFILE
- echo "$NAME."
- ;;
- restart|force-reload)
- echo -n $"Restarting $DESC: "
- killproc `basename $REAL_DAEMON` && rm -f $PIDFILE
- sleep 1
- daemon su - sogo -c $DAEMON
- echo "$NAME."
- ;;
- status)
- status $REAL_DAEMON
- ;;
- *)
- N=/etc/init.d/$NAME
- echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
- exit 1
- ;;
-esac
-
-exit 0
-
+++ /dev/null
-#!/bin/sh
-
-export PATH=/usr/local/sbin:$PATH
-
-cd /root/SOGo
-# echo "Pulling monotone repository"
-
-oldversion=$(mtn status)
-mtn pull >& /dev/null
-mtn update >& /dev/null
-newversion=$(mtn status)
-
-if [ "$oldversion" == "$newversion" ]
-then
- exit 0
-fi
-
-echo "SOGo mainsite updated at $(date)..."
-
-. /root/GNUstep/Library/Makefiles/GNUstep.sh >& /dev/null
-make distclean > /dev/null
-./configure --disable-strip --without-gnustep >& /dev/null
-make -s > /dev/null
-rm -rf /usr/local/lib/sogod-0.9
-make -s install > /dev/null
-# echo "Copying templates to /usr/local/share/sogo-0.9/templates"
-# rm -rf /usr/local/share/sogo-0.9/templates
-# cp -a UI/Templates /usr/local/share/sogo-0.9/templates
-# echo "Copying web resources to /usr/local/share/sogo-0.9/www"
-# cp -a UI/WebServerResources /usr/local/share/sogo-0.9/www
-# echo "Killing server"
-pkill sogod-0.9 >& /dev/null
-# echo "Starting sogod-0.9 (log in /var/log/sogod)"
-echo "Launching on $(date)" > /var/log/sogod
-sogod-0.9 >> /var/log/sogod 2>&1 &
-
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
-PIDFILE=/var/run/sogo/sogod.pid
+PIDFILE=/var/run/sogo/sogod.$1
. /usr/lib/GNUstep/System/Library/Makefiles/GNUstep.sh
echo $$ > $PIDFILE
-exec $GNUSTEP_LOCAL_ROOT/Tools/sogod-0.9 >& /var/log/sogo/sogod.log
+
+startport=`defaults read sogod-0.9 WOPort`
+if [ "$?" == "0" ]
+then
+ startport=`echo $startport | awk '{print $3}'`
+else
+ startport=20000
+fi
+
+let "port=$startport + $1 - 1"
+exec $GNUSTEP_LOCAL_ROOT/Tools/sogod-0.9 -WOPort $PORT >& /var/log/sogo/sogod-$PORT.log
--- /dev/null
+#!/bin/sh
+
+# SOGo daemon wrapper
+#
+# Copyright (C) 2007 Inverse groupe conseil
+#
+# Author: Wolfgang Sourdeau <wsourdeau@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.
+
+PIDFILE=/var/run/sogo/sogod.$1
+
+. /usr/GNUstep/System/Library/Makefiles/GNUstep.sh
+
+echo $$ > $PIDFILE
+
+startport=`defaults read sogod-0.9 WOPort`
+if [ "$?" == "0" ]
+then
+ startport=`echo $startport | awk '{print $3}'`
+else
+ startport=20000
+fi
+
+let "port=$startport + $1 - 1"
+exec $GNUSTEP_LOCAL_ROOT/Tools/sogod-0.9 -WOPort $PORT >& /var/log/sogo/sogod-$PORT.log
+++ /dev/null
-#!/bin/sh
-
-PIDFILE=/var/run/sogo/sogod.pid
-PROGRAM=sogod-0.9
-oldpid=`pgrep -u $USER sogod-0.9`
-
-if [ -n "$oldpid" ]
-then
- echo SOGo already launched.
- exit 1
-fi
-
-. /usr/GNUstep/System/Library/Makefiles/GNUstep.sh
-
-$GNUSTEP_SYSTEM_ROOT/Tools/$PROGRAM >& /var/log/sogo/sogod.log &
-
-newpid=`pgrep -u $USER $PROGRAM | awk '{ print $1 }'`
-echo $newpid > $PIDFILE
-