From 2df332e6184522c04f09fe45ae7be3bd90fb59c1 Mon Sep 17 00:00:00 2001 From: wolfgang Date: Fri, 26 Oct 2007 20:31:05 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1202 d1b88da0-ebda-0310-925b-ed51d893ca5b --- Scripts/sogo-init.d-debian | 55 ++++++++++------ Scripts/sogo-init.d-redhat | 38 ++++++++--- Scripts/sogo-init.d-rhel4 | 87 ------------------------- Scripts/sogocron.sh | 36 ---------- Scripts/{sogod-0.9 => sogod-0.9-debian} | 14 +++- Scripts/sogod-0.9-redhat | 39 +++++++++++ Scripts/sogod-redhat | 19 ------ 7 files changed, 115 insertions(+), 173 deletions(-) delete mode 100755 Scripts/sogo-init.d-rhel4 delete mode 100755 Scripts/sogocron.sh rename Scripts/{sogod-0.9 => sogod-0.9-debian} (75%) create mode 100755 Scripts/sogod-0.9-redhat delete mode 100755 Scripts/sogod-redhat diff --git a/Scripts/sogo-init.d-debian b/Scripts/sogo-init.d-debian index db2a939b..07e989aa 100755 --- a/Scripts/sogo-init.d-debian +++ b/Scripts/sogo-init.d-debian @@ -1,10 +1,11 @@ -#! /bin/sh +#! /bin/bash # SOGo init script for Debian GNU/Linux # # Copyright (C) 2007 Inverse groupe conseil # # Author: Wolfgang Sourdeau +# Ludovic Marcotte # # 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 @@ -21,47 +22,63 @@ # 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 diff --git a/Scripts/sogo-init.d-redhat b/Scripts/sogo-init.d-redhat index a63ca447..e2182e65 100755 --- a/Scripts/sogo-init.d-redhat +++ b/Scripts/sogo-init.d-redhat @@ -29,6 +29,9 @@ # sogod Scalable OpenGroupware.org (Inverse edition) +PREFORK=3 +SOGO_ARGS="" + PATH=/sbin:/bin:/usr/sbin:/usr/bin . /etc/rc.d/init.d/functions @@ -43,34 +46,50 @@ DAEMON=/usr/sbin/sogod 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) @@ -84,4 +103,3 @@ case "$1" in esac exit 0 - diff --git a/Scripts/sogo-init.d-rhel4 b/Scripts/sogo-init.d-rhel4 deleted file mode 100755 index 35d20f9c..00000000 --- a/Scripts/sogo-init.d-rhel4 +++ /dev/null @@ -1,87 +0,0 @@ -#!/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 -# -# 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 - diff --git a/Scripts/sogocron.sh b/Scripts/sogocron.sh deleted file mode 100755 index 1b1f87d4..00000000 --- a/Scripts/sogocron.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/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 & - diff --git a/Scripts/sogod-0.9 b/Scripts/sogod-0.9-debian similarity index 75% rename from Scripts/sogod-0.9 rename to Scripts/sogod-0.9-debian index d2a326b2..7f9568f1 100755 --- a/Scripts/sogod-0.9 +++ b/Scripts/sogod-0.9-debian @@ -21,9 +21,19 @@ # 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 diff --git a/Scripts/sogod-0.9-redhat b/Scripts/sogod-0.9-redhat new file mode 100755 index 00000000..eea7179b --- /dev/null +++ b/Scripts/sogod-0.9-redhat @@ -0,0 +1,39 @@ +#!/bin/sh + +# SOGo daemon wrapper +# +# Copyright (C) 2007 Inverse groupe conseil +# +# Author: Wolfgang Sourdeau +# +# 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 diff --git a/Scripts/sogod-redhat b/Scripts/sogod-redhat deleted file mode 100755 index dfab9a75..00000000 --- a/Scripts/sogod-redhat +++ /dev/null @@ -1,19 +0,0 @@ -#!/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 - -- 2.39.5