#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org

. /lib/functions.sh

START=95
boot() {
	[ -d /tmp/root ] && mount_root done

	# process user commands
	[ -f /etc/rc.local ] && {
		sh /etc/rc.local
	}

	# set leds to normal state
	. /etc/diag.sh
	set_state done

	if [ -e /usr/sbin/ubi_make_extra_volume.sh ]; then
		/usr/sbin/ubi_make_extra_volume.sh
	fi

	if [ -e /usr/sbin/log_oops_recovery.sh ]; then
		/usr/sbin/log_oops_recovery.sh
	fi

	ubusd_pid=`pidof ubusd`
	[ -n "$ubusd_pid" ] && {
		echo -1000 > /proc/$ubusd_pid/oom_score_adj
	}

	# whether kill tdpd or not
	if [ -f "/etc/config/uhttpd" ]; then
		config_load uhttpd
		config_get tdpd main tdpd
	fi
	if [ -n "$tdpd" ] && [ "$tdpd" == "0" ]; then
		local pid=` ps | grep tdpd |grep -v grep |awk '{print $1}' `
		kill -TERM $pid
	fi
}
