#!/bin/sh DAEMON=aiccu . /etc/init.d/modlibrc AICCU_SH=/tmp/flash/$DAEMON/aiccu.sh config() { modlib_config } start() { #aiccu needs correct date, wait for it local counter=$AICCU_WAITTIME while [ `date +%Y` -lt 2010 -a $counter -gt 0 ]; do let counter-- sleep 1 done if [ `date +%Y` -lt 2010 -a "$AICCU_WAITTIME" -gt 0 ]; then echo "Starting of ${DAEMON} aborted. Time is not synchronized, failed." exit 1 fi # try to load kernel module [ -d /proc/sys/net/ipv6 ] || modprobe ipv6 2>/dev/null modlib_startdaemon $DAEMON start /mod/etc/$DAEMON.conf retval=$? local _timer=30 while [ $_timer -gt 0 ]; do let _timer-- if ifconfig ${AICCU_INTERFACE} >/dev/null 2>&1; then echo 0 2>/dev/null >/proc/sys/net/ipv6/conf/${AICCU_INTERFACE}/disable_ipv6 break fi sleep 1 done if [ "$AICCU_RUNSCRIPT" == "yes" ]; then $AICCU_SH $AICCU_INTERFACE [ "$?" -ne 0 ] && retval=$? fi return $retval } stop () { $DAEMON stop /mod/etc/$DAEMON.conf local retval=$? #aiccu terminates slow, so wait for it: local tries=0 while pidof aiccu >/dev/null; do let tries++ [ $tries -gt 9 ] && break sleep 1 done return $retval } case $1 in ""|load) [ ! -d "/tmp/flash/$DAEMON" ] && mkdir -p /tmp/flash/$DAEMON [ ! -e $AICCU_SH ] && cat /mod/etc/default.$DAEMON/aiccu_sh.conf > $AICCU_SH [ ! -x $AICCU_SH ] && chmod +x $AICCU_SH modreg cgi $DAEMON 'aiccu' modreg daemon $DAEMON modreg file $DAEMON aiccu_sh 'aiccu.sh' 1 "aiccu_sh" modlib_start $AICCU_ENABLED ;; unload) modunreg daemon $DAEMON modunreg cgi $DAEMON modunreg file $DAEMON modlib_stop ;; start) modlib_start ;; stop) modlib_stop ;; restart) modlib_restart ;; status) modlib_status ;; *) echo "Usage: $0 [load|unload|start|stop|restart|status]" 1>&2 exit 1 ;; esac exit 0