Controlling LED on front of Pogoplug V2
I've recently been looking for some sort of network storage solution. My requirements were that it should be very flexible, both in terms of what it can be made to do and storage expandability, be easy to backup to something I can take off site, low power usage, low set up cost. I ended up buying a couple of Western Digital 2TB USB drives and attaching them to Pogoplug V2 that I found for sale on Amazon from a third party which I then made run Arch Linux ARM The V2 is a bit old now, the Pogoplug devices are currently on the fourth generation, but everything I read (e.g. http://fortysomethinggeek.blogspot.co.uk/2013/03/pogoplug-series-4-archlinux-review.html) indicated that the V2 is actually better for my purposes. The V4 has USB 3 ports compare to the USB 2 ports on the V2, but it negates the advantage by having a weaker CPU and fewer ports.
Anyway, the Pogoplug V2 (mine is actually black) has an LED illuminated logo on the front and it's possible to control that from within the Arch install. So I wrote I couple of scripts to do that.
One of them can be used to set or save the current colour and restore a saved colour.
#!/bin/bash
# /usr/local/bin/ledcolour
# n.b. blue is actually orange
trigger_green=/sys/class/leds/status\:green\:health/trigger
trigger_orange=/sys/class/leds/status\:blue\:health/trigger
save_green="/tmp/$(basename $0)_save_green"
save_orange="/tmp/$(basename $0)_save_orange"
if [ ! -w "${trigger_green}" ];then
echo "trigger files are not writable or do not exist. try as root"
exit 1
fi
if [ -z "${1}" ];then
echo "Usage: $(basename $0) colour|save|restore"
echo "Examples:"
echo "$(basename $0) green"
echo "$(basename $0) yellow"
echo "$(basename $0) orange"
echo "$(basename $0) off"
echo
echo "Save current led state with"
echo "$(basename $0) save"
echo "and restore it later with"
echo "$(basename $0) restore"
exit 1;
fi
case $1 in
"green" )
echo default-on > "${trigger_green}";
echo none > "${trigger_orange}";
;;
"orange" )
echo none > "${trigger_green}";
echo default-on > "${trigger_orange}";
;;
"yellow" )
echo default-on > "${trigger_green}";
echo default-on > "${trigger_orange}";
;;
"off" )
echo none > "${trigger_green}";
echo none > "${trigger_orange}";
;;
"save" )
grep -o '\[.*\]' "${trigger_orange}" | sed 's/\[//;s/\]//' > "${save_orange}";
grep -o '\[.*\]' "${trigger_green}" | sed 's/\[//;s/\]//' > "${save_green}";
;;
"restore" )
cat "${save_green}" > "${trigger_green}";
cat "${save_orange}" > "${trigger_orange}";
;;
esac
The other can be used to flash between off and a specified colour or cycle through a sequence of colours. It allows specifying the duration for each colour and the number of iterations.
#!/bin/bash
# /usr/local/bin/ledflash
# save current led state
ledcolour save
# restore that state on script exit
trap "ledcolour restore" EXIT
if [ -z "${1}" ];then
echo "Usage: $(basename $0) colour[,colour[,colour]] [interval] [iterations]"
echo "Examples:"
echo "Flash green for ever with default interval:"
echo "$(basename $0) green"
echo "Flash green for ever with interval of 0.5 seconds:"
echo "$(basename $0) green 0.5"
echo "Flash green and yellow for ever with interval of 0.5 seconds:"
echo "$(basename $0) green,yellow 0.5"
echo "Flash green yellow orange five times with interval of 5 seconds:"
echo "$(basename $0) green,yellow,orange 5 5"
exit 1;
fi
p=1;
test -n "${2}" && p=$2
iterations=0
test -n "${3}" && iterations=$3
OIFS=$IFS
IFS=,
colourarray=($1)
IFS=$OIFS
if [ ${#colourarray[@]} = 1 ];then
colourarray[${#colourarray[*]}]='off';
fi
flipon=${#colourarray[@]}
flipcount=0;
loopcount=0;
while true;do
ledcolour ${colourarray[flipcount]};
sleep $p;
((flipcount++))
if [ $flipcount -eq $flipon ];then
flipcount=0
((loopcount++))
test $loopcount -eq $iterations && exit;
fi
done
Edit: forgot to say, there is a file called brightness in the directory along with the trigger file and a max_brightness file that suggests the brightness file takes a value up to 255. Sadly no matter what value I put in the brightness file, the brightness of the LED(s) did not change. I couldn't find any information about controlling the brightness. Which is a shame. I was hoping to write a script to mimic the pulsing power LED of a sleeping Mac.
No comments
Add a comment
You are not allowed to comment on this entry as it has restricted commenting permissions.