add some safety checks
This commit is contained in:
parent
5506545a01
commit
ccee8c418e
@ -1,9 +1,36 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
PROGNAME="$0"
|
||||||
|
|
||||||
echoerr() {
|
echoerr() {
|
||||||
>&2 echo "$@"
|
>&2 echo "error: $@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
die() {
|
||||||
|
echoerr "$@"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<-_EOF
|
||||||
|
Usage: $PROGNAME +|-
|
||||||
|
_EOF
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
command_exists() {
|
||||||
|
command -V "$1" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -z "$1" ] && usage
|
||||||
|
[ "$EUID" != 0 ] && die "must be run as root"
|
||||||
|
|
||||||
|
for c in intel_reg awk; do
|
||||||
|
if ! command_exists $c; then
|
||||||
|
die "$c not found"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
max=$(intel_reg read 0xC8254 2>/dev/null | awk '{print $3}')
|
max=$(intel_reg read 0xC8254 2>/dev/null | awk '{print $3}')
|
||||||
max=${max:2:4}
|
max=${max:2:4}
|
||||||
max_dec=$(printf "%d" $((16#$max)))
|
max_dec=$(printf "%d" $((16#$max)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user