Now more silent by default to prevent log spam hourly.

Change debug to any value above 0 to enable output.
This commit is contained in:
Cody Cook 2019-06-12 14:50:38 -07:00
commit 598f73ba85
2 changed files with 43 additions and 29 deletions

View file

@ -1,62 +1,71 @@
#!/bin/bash #!/bin/bash
# description: RR4360 PSU fix, pre-6.8.0 # description: RR4360 PSU fix
# NETGEAR Proprietary # Runs for 10 attempts to try resolve PSU failure messages
# email: readynassupport@netgear.com
# usage: ./scriptname
#set variables
get_inb="http://ntgr.support/tools/inb" get_inb="http://ntgr.support/tools/inb"
get_outb="http://ntgr.support/tools/outb" get_outb="http://ntgr.support/tools/outb"
inb="/etc/frontview/support/inb" inb="/etc/frontview/support/inb"
outb="/etc/frontview/support/outb" outb="/etc/frontview/support/outb"
attempts=0 attempts=0
debug=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." if [[ "$debug" -gt 0 ]]; then
usrmsg="printf"
else
usrmsg="#"
fi
get_tools() { get_tools() {
printf "Acquiring latest tools... " if test -f "$inb" && test -f "$outb"; then
wget -q "$get_inb" -O "$inb" $usrmsg "Tools exist - not acquiring again."
wget -q "$get_outb" -O "$outb" else
$usrmsg "Acquiring latest tools... "
if ! test -f "$inb"; then
$usrmsg "Missing inb; downloading now."
wget -q "$get_inb" -O "$inb"
fi
if ! test -f "$outb"; then
$usrmsg "Missing outb; downloading now."
wget -q "$get_outb" -O "$outb"
fi
fi
chmod +x "$inb" "$outb" chmod +x "$inb" "$outb"
printf " done! \n"
} }
check_problem() { check_problem() {
printf "Querying the SMBus for its current status..." $usrmsg "Querying the SMBus for its current status..."
problem=$($inb 0xf00f) problem=$($inb 0xf00f)
validate_problem validate_problem
} }
validate_problem() { validate_problem() {
if [[ "$problem" -ne 7 ]]; then if [[ "$problem" -ne 7 ]]; then
printf " SMBus reporting invalid value; reported: %s" "$problem" $usrmsg " SMBus reporting invalid value; reported: %s" "$problem"
fix fix
else else
echo " The SMBus is currently operating as normal. Exiting script." $usrmsg " The SMBus is currently operating as normal. Exiting script."
exit 0 exit 0
fi fi
} }
fix() { fix() {
attempts=$((attempts+1)) attempts=$((attempts+1))
printf " Attempt %s at fixing the SMBus..." "$attempts" $usrmsg " Attempt %s at fixing the SMBus..." "$attempts"
sleep 1 sleep 1
printf " (#3)... " $usrmsg " (#3)... "
"$outb" 0xf00f 3 2>/dev/null "$outb" 0xf00f 3 2>/dev/null
sleep 1 sleep 1
printf " (#7)... " $usrmsg " (#7)... "
"$outb" 0xf00f 7 2>/dev/null "$outb" 0xf00f 7 2>/dev/null
sleep 1 sleep 1
printf " fix applied. \n" $usrmsg " fix applied. \n"
verify_fix verify_fix
} }
verify_fix(){ verify_fix(){
if [[ "$attempts" -lt 10 ]]; then if [[ "$attempts" -lt 10 ]]; then
check_problem check_problem
else else
printf "Attempted to recover this %s times... seek alternative recovery method." "$attempts" $usrmsg "Attempted to recover this %s times... seek alternative recovery method." "$attempts"
exit 1 exit 1
fi fi
} }

View file

@ -1,26 +1,31 @@
#!/bin/bash #!/bin/bash
# Installer for RR4360 PSU fix
# RR4360 PSU reports offline inappropriately and annoys the user.
# This installs persistent service to check, refault to run every hour on the hour.
# to install, `curl https://gitlab.codycook.us/readynas-scripts/4360psufix.sh/raw/master/rr4360psu_install.sh | bash`
# alternatively, `wget https://gitlab.codycook.us/readynas-scripts/4360psufix.sh/raw/master/rr4360psu_install.sh; bash rr4360psu_install.sh`
# alternatively, `wget https://gitlab.codycook.us/readynas-scripts/4360psufix.sh/raw/master/rr4360psu_install.sh; chmod +x rr4360psu_install.sh; ./rr4360psu_install.sh`
# if internet is a problem, download files from below and copy/paste the details into via SSH/SDM/Console.
get_service="http://ntgr.support/scripts/readynas_os_6/rr4360psu.service" get_service="http://ntgr.support/scripts/readynas_os_6/rr4360psu.service"
get_script="http://ntgr.support/scripts/readynas_os_6/rr4360psu.sh" get_script="http://ntgr.support/scripts/readynas_os_6/rr4360psu.sh"
get_timer="http://ntgr.support/scripts/readynas_os_6/rr4360psu.timer" get_timer="http://ntgr.support/scripts/readynas_os_6/rr4360psu.timer"
script="/etc/frontview/support/rr4360psu.sh" script="/etc/frontview/support/rr4360psu.sh"
echo "This is the installer for the RR4360 PSU reporting Offline issue." echo "Downloading and installing systemd components."
echo "It installs files in their appropriate locations and then schedules a run at the top of every hour."
echo "Installing systemd components. "
wget -q "$get_script" -O "$script" wget -q "$get_script" -O "$script"
chmod +x "$script" chmod +x "$script"
wget -q "$get_service" -O "/etc/systemd/system/rr4360psu.service" wget -q "$get_service" -O "/etc/systemd/system/rr4360psu.service"
wget -q "$get_timer" -O "/etc/systemd/system/rr4360psu.timer" wget -q "$get_timer" -O "/etc/systemd/system/rr4360psu.timer"
echo "Enabling the systemd timer." echo "Enabling and starting systemd timer."
systemctl daemon-reload systemctl daemon-reload
systemctl enable rr4360psu.timer systemctl enable rr4360psu.timer
systemctl start rr4360psu.timer systemctl start rr4360psu.timer
echo "Done" echo "First time run."
echo "Since this is freshly installed, running for the first time, then removing the installer."
$script $script
if [ "$0" == "bash" ] || [ "$0" == "sh" ]; then if [ "$0" == "bash" ] || [ "$0" == "sh" ]; then
echo "Script ran from STDOUT, cannot remove installer." echo "Not removing installing. exiting."
echo "Exiting the installation procedure. Cya!"
else else
rm "$0" && echo "Removed the installer and exiting the installation procedure. Cya!" rm "$0" && echo "Cleaned up installation and exiting."
fi fi