#!/bin/sh DAEMON=bip . /etc/init.d/modlibrc CONFIG_USER=/tmp/flash/$DAEMON/bip_user.conf config() { modlib_config # merge daemon and user config cat $CONFIG_USER >> $DAEMON_CONFIG } start() { DAEMON_ENV="HOME=$HOME" modlib_startdaemon $DAEMON -f $DAEMON_CONFIG $BIP_CMDLINE } startdaemon_post() { # wait for proper daemon startup, typically 0 seconds local cnt=0 while [ $cnt -le 9 ]; do [ -s $PID_FILE ] && kill -0 "$(cat $PID_FILE)" 2>/dev/null && break let cnt++ sleep 1 done } case $1 in ""|load) [ ! -d "/tmp/flash/$DAEMON" ] && mkdir -p /tmp/flash/$DAEMON [ ! -e "$CONFIG_USER" ] && cat /mod/etc/default.$DAEMON/bip_user.conf > $CONFIG_USER modreg file $DAEMON user_conf 'user config' 1 "bip_user_conf" modreg cgi $DAEMON Bip modreg daemon $DAEMON modlib_start $BIP_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