#!/bin/sh /etc/rc.common
START=70

run_h3c()
{
	local enable
	config_get_bool enable $1 enable
	
	if [ "$enable" == 1 ]; then
		local username
		local password
		local method
		local ifname
		local blockstartup

		config_get username $1 username
		config_get password $1 password
		config_get method $1 method
		config_get ifname $1 ifname
		config_get_bool blockstartup $1 blockstartup

		if [ "$blockstartup" == 1 ]; then
			while ! sysuh3c -u $username -p $password -i $ifname -m $method ; do
				echo sysuh3c: process exited unexpectedly, restarting..
				sleep 1
			done
		else
			sleep 5
			sysuh3c -u $username -p $password -i $ifname -m $method &
		fi
	fi
}

start()
{
	config_load sysuh3c
	config_foreach run_h3c login
}

stop()
{
	killall sysuh3c >/dev/null 2>&1
}
