From 7fd68e4b502b5378fb87a07679d3266bba7f93ca Mon Sep 17 00:00:00 2001 From: Cody Cook Date: Sun, 10 Sep 2017 19:41:50 -0700 Subject: [PATCH] Add new file --- rr4360psu.sh | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 rr4360psu.sh diff --git a/rr4360psu.sh b/rr4360psu.sh new file mode 100644 index 0000000..956b1a9 --- /dev/null +++ b/rr4360psu.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# description: RR4360 PSU fix, pre-6.8.0 +# NETGEAR Proprietary +# email: readynassupport@netgear.com +# usage: ./scriptname + + + +#set variables +get_inb="http://ntgr.support/tools/inb" +get_outb="http://ntgr.support/tools/outb" +inb="/etc/frontview/support/inb" +outb="/etc/frontview/support/outb" +attempts=0 + +echo "This tool attempts to resolve RR4360 PSU issues by resetting the SMBus if necessary. It will try 10 times and if it fails, will need to try and be resolved manually." + +get_tools() { + printf "Acquiring tools... " + wget -q "$get_inb" -O "$inb" + wget -q "$get_outb" -O "$outb" + chmod +x "$inb" "$outb" + printf " done! \n" +} + +check_problem() { + printf "Querying the SMBus for its current status..." + problem=$($inb 0xf00f) + validate_problem +} + +validate_problem() { +if [[ "$problem" -ne 7 ]] +then + printf " SMBus reporting invalid value." + fix +else + echo " The SMBus is currently operating as normal. Exiting script." + exit 0 +fi +} + +fix() { + attempts=$((attempts+1)) + printf " Attempt %s at fixing the SMBus..." "$attempts" + "$outb" 0xf00f 3 + sleep 1 + "$outb" 0xf00f 7 + sleep 1 + printf " fix applied. \n" + verify_fix +} +verify_fix(){ +if [[ "$attempts" -lt 10 ]] +then + check_problem + +else + printf "Attempted to recover this %s times... seek alternative recovery method." "$attempts" + exit 1 +fi + + +} + +get_tools +check_problem \ No newline at end of file