#!/bin/sh
# $Id: sc_createfreebusy 2908 2006-05-09 15:18:46Z joergs $
# Copyright (c) 2005 dass-IT Cologne, Germany.  All rights reserved.
#
# Author: Phil Sutter <Phil.Sutter@dass-IT.de>
#
# /etc/init.d/sc_createfreebusy
#
# System startup script for the Freebusy-List generator
#
### BEGIN INIT INFO
# Provides: sc_createfreebusy
# Required-Start: $network 
# Default-Start: 5
# Default-Stop: 0 1 2 4 6
# Description: Kontact-Freebusy-URLs generator using ldap
### END INIT INFO

FREEBUSY_BIN=/usr/bin/sc_freebusy.pl
test -x $FREEBUSY_BIN || { echo "$FREEBUSY_BIN not found"; exit 5; }
FREEBUSY_DIR="/var/lib/kde-profiles/lvermgeo_kontact/share/apps/korganizer"
mkdir -p "$FREEBUSY_DIR"

. /etc/rc.status
rc_reset

case "$1" in 
	start|restart|try-restart|condrestart|force-reload|reload)
		echo -n "Scanning FreeBusy-Lists "
		$FREEBUSY_BIN > "$FREEBUSY_DIR"/freebusyurls &
		rc_status -v
		rc_exit
	;;
	stop)
		#echo -n "This script doesnt need to be stopped "
		rc_status -v
		rc_exit
	;;
	reload|restart|try-restart|condrestart)
		rc_active $0 || { echo "Service is not active, wont restart" ; exit 7; } 
		$0 start
		rc_status -v
		rc_exit
	;;
	*)
		echo "Usage: $0 {start}"
		exit 2
	;;
esac

