Skip to content
Open
17 changes: 17 additions & 0 deletions 2_ls-wvl_extras/Readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
This is a work in progress. I am currently attending college and working a full-time job so please don't expect immediate results.
I can only test these steps on the LS-WVL (Buffalo Linkstation Pro Duo). If anybody wants to try it on another device be my guest.
Know that if anything happens it is not my responsibility. Proceed at your own risk. Feedback is appreciated.

The only thing that needs to be done is "chmod +x" the install.sh and then run it.
This will install
- a gpio interface
an interface for the rest of these things to work
- hdd temperature monitoring
adjusts fan speed automatically
- hdd activity monitoring
info led light will blink when hdd is working
- shutdown monitoring
the switch in the back will shutdown the device again
- more scripts for gpio controls in /usr/local/sbin/

Note: cat the files for the credits and sources
58 changes: 58 additions & 0 deletions 2_ls-wvl_extras/init.d/gpio_interface
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/sh
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides: gpio_interface
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d. This example start a
# single forking daemon capable of writing a pid
# file. To get other behavoirs, implemend
# do_start(), do_stop() or other functions to
# override the defaults in /lib/init/init-d-script.
### END INIT INFO
#
# Author: David Slama <dslam127@gmail.com>

# fan low
echo 16 >/sys/class/gpio/export
echo out > /sys/class/gpio/gpio16/direction
# fan high
echo 17 >/sys/class/gpio/export
echo out > /sys/class/gpio/gpio17/direction
# hdd0 internal red led
echo 34 >/sys/class/gpio/export
echo out > /sys/class/gpio/gpio34/direction
# hdd1 internet red led
echo 35 >/sys/class/gpio/export
echo out > /sys/class/gpio/gpio35/direction
# alarm led (red info led)
echo 36 >/sys/class/gpio/export
echo out > /sys/class/gpio/gpio36/direction
# red function led
echo 37 >/sys/class/gpio/export
echo out > /sys/class/gpio/gpio37/direction
# info led (orange info led)
echo 38 >/sys/class/gpio/export
echo out > /sys/class/gpio/gpio38/direction
# blue function led
echo 39 >/sys/class/gpio/export
echo out > /sys/class/gpio/gpio39/direction
# power led
echo 40 >/sys/class/gpio/export
echo out > /sys/class/gpio/gpio40/direction
# function button
echo 45 >/sys/class/gpio/export
echo in > /sys/class/gpio/gpio45/direction
# power button (switch)
echo 46 >/sys/class/gpio/export
echo in > /sys/class/gpio/gpio46/direction
# auto power button (switch)
echo 47 >/sys/class/gpio/export
echo in > /sys/class/gpio/gpio47/direction
53 changes: 53 additions & 0 deletions 2_ls-wvl_extras/init.d/hddled_activity
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/sh

### BEGIN INIT INFO
# Provides: hdd_led_activity
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Monitor Linkstation LS-CHL
# Description: Enable service provided by daemon.
### END INIT INFO

#
# hddled:
# - monitors hdd activity and displays it using info/error led
#
# Author: David Slama <dslam127@gmail.com>
# Date: 7 November 2015
#
# Credits:
# This is not all my work, but I can't find the original source.

LED_INFO=/sys/class/gpio/gpio38/value

run_daemon()
{ # this part is not my code only modified
iostat -z -d 1 sda | sed -u -e '1d' -e 's/Device.*/0/' -e 's/sd.*/1/' -e '/^$/d' > $LED_INFO &
}

kill_daemon()
{
pkill iostat
}

# Main loop
case $1 in
start)
echo "starting hdd led daemon."
run_daemon
;;
stop)
echo "stopping hdd led daemon."
kill_daemon
;;
restart|force-reload)
$0 stop && sleep 2 && $0 start
;;

*)
echo "Usage: $0 {start|stop|restart|force-reload}"
exit 2
;;
esac
43 changes: 43 additions & 0 deletions 2_ls-wvl_extras/init.d/hddtemp_monitor
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides: hdd_temperature_monitoring
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: adjusts fan speed based on the temperature of the hdds
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d. This example start a
# single forking daemon capable of writing a pid
# file. To get other behavoirs, implemend
# do_start(), do_stop() or other functions to
# override the defaults in /lib/init/init-d-script.
### END INIT INFO

# Author: David Slama <dslam127@gmail.com>
# Date: 7 November 2015

DESC="HDD Temperature Monitor"
DAEMON=/usr/local/sbin/hddtemp_daemon
NAME=hddtemp_daemon

case $1 in
start)
$DAEMON &
;;
stop)
pkill $NAME
;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
echo "arguments: start, stop, and restart"
;;
esac
43 changes: 43 additions & 0 deletions 2_ls-wvl_extras/init.d/shutdown_monitor
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides: shutdown_monitor
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts or stops the daemon watching the power switch
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d. This example start a
# single forking daemon capable of writing a pid
# file. To get other behavoirs, implemend
# do_start(), do_stop() or other functions to
# override the defaults in /lib/init/init-d-script.
### END INIT INFO

# Author: David Slama <dslam127@gmail.com>
# Date: 7 November 2015

DESC="Shutdown Switch Monitor"
DAEMON=/usr/local/sbin/shutdown_daemon
NAME=shutdown_daemon

case $1 in
start)
$DAEMON &
;;
stop)
pkill $NAME
;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
echo "arguments: start, stop, and restart"
;;
esac
69 changes: 69 additions & 0 deletions 2_ls-wvl_extras/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

# Purpose:
# To install gpio interface at startup (unfortunately it's the only hack I've found)
# accidentally resulted in fixing the blinking power light after boot.
# Usage:
# Place this script in ~/ or /root/ (initial directory after logging in via ssh)
# Dependency:
# Need to have ssh root access
# Need to install rogers0 OpenLinkstation first
# Credit:
# http://lists.infradead.org/pipermail/linux-arm-kernel/2015-June/352973.html
#
# Author: David Slama (dslam127@gmail.com)
# Date: 6, 2015-June
#
# Note: only tested on ls-wvl (linkstation pro duo)

echo "getting dependencies"
apt-get install -y sysstat busybox

echo "copying files"
cp init.d/gpio_interface /etc/init.d/
cp init.d/hddled_activity /etc/init.d/
cp init.d/hddtemp_monitor /etc/init.d/
cp init.d/shutdown_monitor /etc/init.d/
cp sbin/button_function /usr/local/sbin/
cp sbin/button_power /usr/local/sbin/
cp sbin/button_power_auto /usr/local/sbin/
cp sbin/fan_speed /usr/local/sbin/
cp sbin/hddtemp_daemon /usr/local/sbin/
cp sbin/led_alarm /usr/local/sbin/
cp sbin/led_function_blue /usr/local/sbin/
cp sbin/led_function_red /usr/local/sbin/
cp sbin/led_hdd0 /usr/local/sbin/
cp sbin/led_hdd1 /usr/local/sbin/
cp sbin/led_info /usr/local/sbin/
cp sbin/led_power /usr/local/sbin/
cp sbin/shutdown_daemon /usr/local/sbin/


echo "making the files executable"
chmod +x /etc/init.d/gpio_interface
chmod +x /etc/init.d/hddled_activity
chmod +x /etc/init.d/hddtemp_monitor
chmod +x /etc/init.d/shutdown_monitor
chmod +x /usr/local/sbin/button_function
chmod +x /usr/local/sbin/button_power
chmod +x /usr/local/sbin/button_power_auto
chmod +x /usr/local/sbin/fan_speed
chmod +x /usr/local/sbin/hddtemp_daemon
chmod +x /usr/local/sbin/led_alarm
chmod +x /usr/local/sbin/led_function_blue
chmod +x /usr/local/sbin/led_function_red
chmod +x /usr/local/sbin/led_hdd0
chmod +x /usr/local/sbin/led_hdd1
chmod +x /usr/local/sbin/led_info
chmod +x /usr/local/sbin/led_power
chmod +x /usr/local/sbin/shutdown_daemon

echo "updating boot preferences"
update-rc.d gpio_interface defaults
update-rc.d hddled_activity defaults
update-rc.d hddtemp_monitor defaults
update-rc.d shutdown_monitor defaults

echo "rebooting in 5 seconds"
sleep 5
reboot
10 changes: 10 additions & 0 deletions 2_ls-wvl_extras/sbin/button_function
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# shell script to output function button state
BUTTON=/sys/class/gpio/gpio45/value

if [ $(cat $BUTTON) -eq 0 ]; then
echo "on"
else
echo "off"
fi
10 changes: 10 additions & 0 deletions 2_ls-wvl_extras/sbin/button_power
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# simple shell script to output auto power button position
BUTTON=/sys/clas/gpio/gpio46/value

if [ $(cat $BUTTON) -eq 0 ]; then
echo "on"
else
echo "off"
fi
10 changes: 10 additions & 0 deletions 2_ls-wvl_extras/sbin/button_power_auto
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# simple shell script to output auto power button position
BUTTON=/sys/clas/gpio/gpio47/value

if [ $(cat $BUTTON) -eq 0 ]; then
echo "on"
else
echo "off"
fi
48 changes: 48 additions & 0 deletions 2_ls-wvl_extras/sbin/fan_speed
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

# shell script to control the fan speed

# ++ = stop 0rpm
# +- = low 1500rpm
# -+ = med 3250rpm
# -- = high 5000rpm

PIN1=/sys/class/gpio/gpio16/value
PIN2=/sys/class/gpio/gpio17/value

case $1 in
off)
echo 1 > $PIN1
echo 1 > $PIN2
;;
low)
echo 1 > $PIN1
echo 0 > $PIN2
;;
mid)
echo 0 > $PIN1
echo 1 > $PIN2
;;
high)
echo 0 > $PIN1
echo 0 > $PIN2
;;
state)
P1=$(cat $PIN1)
P2=$(cat $PIN2)
if [ $P1 -eq $P2 ] && [ $P1 -eq 1 ]; then
echo "off"
elif [ $P1 -eq $P2 ] && [ $P1 -eq 0 ]; then
echo "high"
elif [ $P1 -gt $P2 ]; then
echo "mid"
elif [ $P1 -lt $P2 ]; then
echo "low"
else
echo "state of the fan undetermined"
fi
;;
*)
echo "arguments: off, low, mid, high, or state"
;;
esac
Loading