#!/bin/sh
#
# la-sync-manager startup script
#
# chkconfig: 345 97 3
# description: Manage synchronisation between latmos-account bases

. /etc/rc.d/init.d/functions
[ -r /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
export LC_ALL
export LANG

USER=nobody
[ -f /etc/sysconfig/latmos-accounts ] && \
    . /etc/sysconfig/latmos-accounts

RETVAL=0
prog=la-sync-manager

function start () {
    gprintf "Starting %s: " "$prog"
    daemon --user $USER /usr/bin/la-sync-manager
    [ $? -eq 0 ] && success || failure
    touch /var/lock/subsys/$prog
    echo
}

function stop () {
    gprintf "Stopping %s: " "$prog"
    killproc la-sync-manager
    rm -f /var/lock/subsys/$prog
    echo
}

case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    status)
	status la-sync-manager
	;;
    restart)
	stop
	start
	;;
    reload)
        la-sync -b
	;;
    *)
	gprintf "Usage: $0 {start|stop|status|restart|reload}\n"
	exit 1
esac

exit $RETVAL
