From e94f272209bc76fd8073178093750669af2fc152 Mon Sep 17 00:00:00 2001 From: Cody Cook Date: Sun, 1 Dec 2019 10:53:00 -0800 Subject: [PATCH] Add new file --- install.sh | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..af16618 --- /dev/null +++ b/install.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +bye() { + echo "$1" + cd / + rm -rf $orig_dir + exit +} + +orig_dir=`pwd` + +# Make sure this is a NV +if ! grep -q "model:.*ReadyNAS NV" /proc/sys/dev/boot/info; then + mesg="Unsuccessful setting minimum fan speed. Wrong system detected." + bye "$mesg" +fi + +# Make sure this is running the right system rev +if ! grep -q "system_rev:.*0005" /proc/sys/dev/boot/info; then + mesg="Unsuccessful setting minimum fan speed. Wrong system rev detected." + bye "$mesg" +fi + + +# Check fan speed to make sure it's in range. This tells us if the fan +# adapter is installed +echo 255 > /proc/sys/dev/hwmon/fan0_speed_control +sleep 5 +speed=`cat /proc/sys/dev/hwmon/fan_0` + +if [ $speed -gt 2500 ]; then + mesg="Unsuccessful setting minimum fan speed. Fan adapter not installed." + bye "$mesg" +fi + + +# After install fan adaptor, change VPD to version 4 + +# Remove USB modules if neccessary +rmmod usb-uhci ehci-hcd +if lsmod | egrep -q "usb-uhci|ehci-hcd"; then + mesg="Unsuccessful setting minimum fan speed. Disconnect USB devices and try again." + bye "$mesg" +fi + +# Temp working directory, use system temp if possible +mkdir vpd_change_temp_dir +cd vpd_change_temp_dir + +# Min RPM 1900 / 64 = 29 = 0x1d * 64 = 1856 RPM +printf "\x1d" > min_rpm +dd if=min_rpm of=/dev/mtdblock0 bs=1 seek=33153 count=1 + +# Min PWM 16 +printf "\x10" > min_pwm +dd if=min_pwm of=/dev/mtdblock0 bs=1 seek=33154 count=1 + +# CFT PWM 255 +printf "\xff" > cft_pwm +dd if=cft_pwm of=/dev/mtdblock0 bs=1 seek=33155 count=1 + +# Change System revision number +printf "\x04" > sys_rev +dd if=sys_rev of=/dev/mtdblock0 bs=1 seek=33159 + +# Force fan recalibration +rm -f /etc/frontview/fan_setting_* + + +# Clean up +cd .. +rm -rf vpd_change_temp_dir + +mesg="Successfully set minimum fan speed. Please reboot the ReadyNAS now." +bye "$mesg" +