#!/bin/sh
#
# NODE ID LED control script
#
# To tell which system that users are interested in
# this script on/off the front panel LEDs.
# In node indication mode, Red LED will stay on and amber LED will blink in 2Hz
# In normal mode, Red LED will stay off and amber LED will blink depends on CPU load.
#
# This script accepts one argument [on/off]
#


if [ x$1 = x"on" ] ; then
	cp -f /proc/sys/dev/sysactled/redled /tmp/___redled
	cat /proc/sys/dev/sysactled/mode > /tmp/___ledmode
	if [ -x /tmp/___redled ] ; then
		/tmp/___redled 0
	fi
	echo 2 > /proc/sys/dev/sysactled/mode
	rm -f /tmp/___redled

elif [ x$1 = x"off" ] ; then
	cp -f /proc/sys/dev/sysactled/redled /tmp/___redled
	if [ -x /tmp/___redled ] ; then
		/tmp/___redled 2
	fi
	if [ -s /tmp/___ledmode ] ; then
		cat /tmp/___ledmode > /proc/sys/dev/sysactled/mode
	else
		echo 0 > /proc/sys/dev/sysactled/mode
	fi
	rm -f /tmp/___redled /tmp/___ledmode
else
	echo Usage:
	echo nodeid [on/off]
fi

	
