#!/bin/sh

if [ -z ${RC_CMD} ]; then
	cmd=$1
else
	cmd=${RC_CMD}
fi
STARTUP_LIST=/etc/startup.list
if [ ".${cmd}" = ".stop" ]; then
	if [ -f /etc/persistent/rc.prestop ]; then
		. /etc/persistent/rc.prestop
	fi
	origlist=`grep -v '#' ${STARTUP_LIST}`
	startuplist=""
	for a in ${origlist}; do 
		startuplist="$a ${startuplist}"
	done
else
	if [ -f /etc/persistent/rc.prestart ]; then
		. /etc/persistent/rc.prestart
	fi
	startuplist=`grep -v '#' ${STARTUP_LIST}`
fi

PLUGIN_NORUN=yes
. /usr/etc/init.d/plugin

for app in ${startuplist}
do
	if [ -e /etc/sysinit/${app}.conf ]; then
		run_plugin ${app} ${cmd}
	else
		echo "Config file for plugin ${app} does not exist!"
	fi
done

if [ ".${cmd}" != ".stop" ]; then
	sysled -r 1
	bgnd -r garp -- /sbin/garp -s 2 &
	if [ -f /etc/persistent/rc.poststart ]; then
		. /etc/persistent/rc.poststart
	fi
else
	sysled -r 0
	if [ -f /etc/persistent/rc.poststop ]; then
		. /etc/persistent/rc.poststop
	fi
fi
