[Csync2] csync2 init.d script

Marcus Bointon marcus at synchromedia.co.uk
Fri Nov 30 19:01:10 CET 2007


I know someone asked on here about an init.d script for csync2. I was  
looking for one too after inetd was not working for me. I found one  
from pld-linux here:

http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/csync2.init?rev=1.2;content-type=text%2Fplain

However, it uses some rc.d scripts that are apparently only present in  
RedHat, Mandrake and a few other distros, and doesn't work in Debian/ 
Ubuntu. I found a shell init.d script and built one that seems to work:

#!/bin/sh
#
# csync2:        Init script for csync2 synchronisation daemon
#
# chkconfig: 345 90 10
# description: csync2 is a mechanism for keeping multiple servers in  
sync.
# pidfile: /var/run/csync2.pid
#
# by Marcus Bointon <marcus at synchromedia.co.uk>
# adapted from http://osdir.com/ml/mail.postfix.sqlgrey/2006-07/msg00000.html 
  by Karl O. Pinc
# GPL license

CSYNC2=/usr/sbin/csync2

# See how we were called.
case "$1" in
   start)
         echo -n " csync2"
         ERRMSG=$(/sbin/start-stop-daemon --pidfile /var/run/ 
csync2.pid --make-pidfile --background --exec $CSYNC2 --start -- -ii  
2>&1)

         if [ $? != 0 ]; then
             echo "(FAILED)"
             [ "$ERRMSG" ] && echo "ERROR: $ERRMSG" >&2 || true
             exit 1
         fi

         [ "$ERRMSG" ] && echo -n " ($ERRMSG)" >&2 || true
         ;;

   stop)
         echo -n " csync2"
         start-stop-daemon --stop --pidfile /var/run/csync2.pid
         rm -f /var/run/csync2.pid
         ;;

   restart)
         $0 stop
         sleep 1
         $0 start
         ;;

   *)
         echo "Usage: csync2 {start|stop|restart}"
         exit 1
esac

exit 0

In particular it seems that you do need to explicitly tell csync2 to  
detach and to create a pid file.

Hope it's of use to others, the archives, or anyone who cares to  
improve it (the PLD Linux one is quite a lot better).

Marcus
-- 
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
UK resellers of info at hand CRM solutions
marcus at synchromedia.co.uk | http://www.synchromedia.co.uk/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3945 bytes
Desc: not available
Url : http://lists.linbit.com/pipermail/csync2/attachments/20071130/fa587f29/smime.bin


More information about the Csync2 mailing list