Totally fix the usrmsg system by switching from variable to function again
This commit is contained in:
parent
4127d77fe8
commit
edeb7d30b4
1 changed files with 15 additions and 16 deletions
|
@ -9,23 +9,22 @@ outb="/etc/frontview/support/outb"
|
||||||
attempts=0
|
attempts=0
|
||||||
debug=0
|
debug=0
|
||||||
|
|
||||||
|
usrmsg(){
|
||||||
if [[ "$debug" -gt 0 ]]; then
|
if [[ "$debug" -gt 0 ]]; then
|
||||||
usrmsg="printf"
|
printf "$*"
|
||||||
else
|
|
||||||
usrmsg="echo > /dev/null <<"
|
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
get_tools() {
|
get_tools() {
|
||||||
if test -f "$inb" && test -f "$outb"; then
|
if test -f "$inb" && test -f "$outb"; then
|
||||||
$usrmsg "Tools exist - not acquiring again.\n"
|
usrmsg "Tools exist - not acquiring again.\n"
|
||||||
else
|
else
|
||||||
$usrmsg "Acquiring latest tools... \n"
|
usrmsg "Acquiring latest tools... \n"
|
||||||
if ! test -f "$inb"; then
|
if ! test -f "$inb"; then
|
||||||
$usrmsg "Missing inb; downloading now.\n"
|
usrmsg "Missing inb; downloading now.\n"
|
||||||
wget -q "$get_inb" -O "$inb"
|
wget -q "$get_inb" -O "$inb"
|
||||||
fi
|
fi
|
||||||
if ! test -f "$outb"; then
|
if ! test -f "$outb"; then
|
||||||
$usrmsg "Missing outb; downloading now.\n"
|
usrmsg "Missing outb; downloading now.\n"
|
||||||
wget -q "$get_outb" -O "$outb"
|
wget -q "$get_outb" -O "$outb"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -33,39 +32,39 @@ get_tools() {
|
||||||
}
|
}
|
||||||
|
|
||||||
check_problem() {
|
check_problem() {
|
||||||
$usrmsg "Querying the SMBus for its current status...\n"
|
usrmsg "Querying the SMBus for its current status...\n"
|
||||||
problem=$($inb 0xf00f)
|
problem=$($inb 0xf00f)
|
||||||
validate_problem
|
validate_problem
|
||||||
}
|
}
|
||||||
|
|
||||||
validate_problem() {
|
validate_problem() {
|
||||||
if [[ "$problem" -ne 7 ]]; then
|
if [[ "$problem" -ne 7 ]]; then
|
||||||
$usrmsg " SMBus reporting invalid value; reported: %s\n" "$problem"
|
usrmsg " SMBus reporting invalid value; reported: %s\n" "$problem"
|
||||||
fix
|
fix
|
||||||
else
|
else
|
||||||
$usrmsg " The SMBus is currently operating as normal. Exiting script.\n"
|
usrmsg " The SMBus is currently operating as normal. Exiting script.\n"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
fix() {
|
fix() {
|
||||||
attempts=$((attempts+1))
|
attempts=$((attempts+1))
|
||||||
$usrmsg " Attempt %s at fixing the SMBus..." "$attempts"
|
usrmsg " Attempt %s at fixing the SMBus..." "$attempts"
|
||||||
sleep 1
|
sleep 1
|
||||||
$usrmsg " (#3)... "
|
usrmsg " (#3)... "
|
||||||
"$outb" 0xf00f 3 2>/dev/null
|
"$outb" 0xf00f 3 2>/dev/null
|
||||||
sleep 1
|
sleep 1
|
||||||
$usrmsg " (#7)... "
|
usrmsg " (#7)... "
|
||||||
"$outb" 0xf00f 7 2>/dev/null
|
"$outb" 0xf00f 7 2>/dev/null
|
||||||
sleep 1
|
sleep 1
|
||||||
$usrmsg " 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
|
||||||
$usrmsg "Attempted to recover this %s times... seek alternative recovery method.\n" "$attempts"
|
usrmsg "Attempted to recover this %s times... seek alternative recovery method.\n" "$attempts"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue