73 lines
1.6 KiB
Bash
Executable File
73 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# description: RR4360 PSU fix
|
|
# Runs for 10 attempts to try resolve PSU failure messages
|
|
|
|
get_inb="https://gitlab.codycook.us/readynas-scripts/4360psufix.sh/-/raw/master/etc/frontview/support/inb"
|
|
get_outb="https://gitlab.codycook.us/readynas-scripts/4360psufix.sh/-/raw/master/etc/frontview/support/outb"
|
|
inb="/etc/frontview/support/inb"
|
|
outb="/etc/frontview/support/outb"
|
|
attempts=0
|
|
debug=0
|
|
|
|
usrmsg(){
|
|
if [[ "$debug" -gt 0 ]]; then
|
|
echo "$*"
|
|
fi
|
|
}
|
|
get_tools() {
|
|
if test -f "$inb" && test -f "$outb"; then
|
|
usrmsg "Tools exist - not acquiring again."
|
|
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"
|
|
}
|
|
|
|
check_problem() {
|
|
usrmsg "Querying the SMBus for its current status..."
|
|
problem=$($inb 0xf00f)
|
|
validate_problem
|
|
}
|
|
|
|
validate_problem() {
|
|
if [[ "$problem" -ne 7 ]]; then
|
|
usrmsg "SMBus reporting invalid value: $problem"
|
|
fix
|
|
else
|
|
usrmsg "SMBus is currently operating as normal. Exiting script."
|
|
exit 0
|
|
fi
|
|
}
|
|
|
|
fix() {
|
|
attempts=$((attempts+1))
|
|
usrmsg "Attempt $attempts at fixing the SMBus..."
|
|
sleep 1
|
|
usrmsg " (#3)... "
|
|
"$outb" 0xf00f 3 2>/dev/null
|
|
sleep 1
|
|
usrmsg " (#7)... "
|
|
"$outb" 0xf00f 7 2>/dev/null
|
|
sleep 1
|
|
usrmsg " fix applied."
|
|
verify_fix
|
|
}
|
|
verify_fix(){
|
|
if [[ "$attempts" -lt 10 ]]; then
|
|
check_problem
|
|
else
|
|
usrmsg "Failed to recover this after $attempts times... seek alternative recovery method."
|
|
exit 1
|
|
fi
|
|
}
|
|
get_tools
|
|
check_problem
|