#!/sbin/runscript
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /etc/init.d/ruijie$

#depend() {
#	
#}
checkconfig() {
		if [ ! -f "/etc/xmuruijie.conf" ] ; then
			eerror "You must set configs in /etc/xmuruijie.conf first"
			return 1
		fi
}

DEV=$(sed -n '/interface/p' /etc/xmuruijie.conf | awk '{print $2}')


start() {
	checkconfig || return 1

	ebegin "Starting XMU-Ruijie"
		/usr/sbin/xmuruijie -dD
	eend $?
	ebegin "Running dhcp client to get ip address"
	if [ -f "/sbin/dhcpcd" ] ; then
		/sbin/dhcpcd  ${DEV}
	elif [ -f "/sbin/dhclient" ] ; then
		/sbin/dhclient ${DEV}
	fi
}

stop() {
	ebegin "Stopping dhcp client"
	if [ -f "/sbin/dhcpcd" ] ; then
		/sbin/dhcpcd -k ${DEV}
	elif [ -f "/sbin/dhclient" ] ; then
		/sbin/dhclient -r ${DEV}
	fi
	eend $?
	ebegin "Stopping XMU-Ruijie"
		/usr/sbin/xmuruijie -p
	eend $?
}
#
#restart() {
#
#}
