Last active
October 5, 2015 16:09
-
-
Save philipp-spiess/6a1b4794a61d71210508 to your computer and use it in GitHub Desktop.
Fan Control for NAS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # case is closed | |
| echo 0 > /sys/class/hwmon/hwmon2/device/intrusion0_alarm | |
| # space seperated list of hdd's | |
| HDDS="/dev/sdb" | |
| CASE_FAN=0 | |
| for disk in $HDDS | |
| do | |
| HDSTATE=$(hdparm -C $disk) | |
| HDTEMP=$(smartctl -A $disk | grep Temperature_Celsius | awk '{print $10}') | |
| if [[ $HDSTATE != *standby* ]]; then | |
| CASE_FAN=100 | |
| fi | |
| # echo $disk | |
| # echo $HDSTATE | |
| # echo $HDTEMP | |
| done | |
| if [ $HDTEMP -ge 55 2>&- ]; then | |
| CASE_FAN=255 | |
| fi | |
| # echo $CASE_FAN | |
| # Enable manual fan control | |
| echo 1 > /sys/class/hwmon/hwmon2/device/pwm2_enable | |
| # set manual fan control PWM | |
| echo $CASE_FAN > /sys/class/hwmon/hwmon2/device/pwm2 | |
| # Set the fan to full speed for one second. If we need the fan to rotate and | |
| # the current RPM is zero | |
| if [ $CASE_FAN -ne 0 2>&- ]; then | |
| CURRENTRPM=$(sensors | grep fan2 | awk '{print $2}') | |
| if [ $CURRENTRPM -eq 0 2>&- ]; then | |
| echo 2 > /sys/class/hwmon/hwmon2/device/pwm2_enable | |
| sleep 1 | |
| echo 1 > /sys/class/hwmon/hwmon2/device/pwm2_enable | |
| sleep 1 | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment