#!/bin/sh

action="$1"

case "${action}" in
	primarydns)
		dns1="`cat /etc/resolv.conf  | grep nameserver | sed -n '1p' | awk '{print $2}'`"
		[ -z "${dns1}" ] && dns1="None"
		echo -n "${dns1}"
	;;

	alternativedns)
                dns2="`cat /etc/resolv.conf  | grep nameserver | sed -n '2p' | awk '{print $2}'`"
                [ -z "${dns2}" ] && dns2="None"
		echo -n "${dns2}"
        ;;

	uptime)
                uptime="`cat /proc/uptime | awk '{print $1}' | tr -d ' ' | cut -d '.' -f1`"
                [ -z "${uptime}" ] && uptime=0
		echo -n "${uptime}"
        ;;

	camera_model)
		MODEL="`curl --connect-timeout 0.5 -X GET "http://10.231.132.139/cgi-bin/web.cgi?action=get&cmd=language" 2>/dev/null | cut -d: -f1`"
		if [ "abc_${MODEL}" = "abc_{\"language\"" ];then
			echo -n "1"
		else
			echo -n "0"
		fi
	;;

	get_ip)
		ip="`ifconfig eth1 | grep 'inet ' | awk '{print $2}'`"

		echo -n "${ip}"
	;;

	*)
		submask="`/sbin/ifconfig eth1 | grep netmask | awk '{print $4}'`"
		echo -n "${submask}"
esac

exit 0
