AtOM/lib/config/getGeneral
2025-11-09 02:06:02 +01:00

86 lines
1.6 KiB
Bash

#!/bin/bash
getConfigGeneral() {
case $key in
'max-load')
expr='^[0-9]*$'
if [[ $value =~ $expr ]]
then
maxload="$value"
else
echo "Invalid max-load value: $value" >&2
exit $ELOAD
fi
unset expr
;;
'load-interval')
expr='^[0-9]*$'
if [[ $value =~ $expr ]]
then
loadinterval="$value"
else
echo "Invalid load-interval value: $value" >&2
exit $EINTERVAL
fi
unset expr
;;
'ionice')
if which ionice >/dev/null
then
read class niceness <<<"$value"
case $class in
1)
# real-time class, only root can do that
if (( UID ))
then
echo "IO class 'realtime' is"\
"not available to unprivileged"\
"users" >&2
exit $EIONICE
fi
if [ -n "$niceness" ] \
&& (( niceness >= 0 && niceness <= 7 ))
then
ionice="ionice -c1 -n$niceness "
else
echo "Invalid IO priority"\
"'$niceness'" >&2
exit $EIONICE
fi
;;
2)
if [ -n "$niceness" ] \
&& (( niceness >= 0 && niceness <= 7 ))
then
ionice="ionice -c2 -n$niceness "
else
echo "Invalid IO priority"\
"'$niceness'" >&2
exit $EIONICE
fi
;;
3)
ionice="ionice -c3 "
;;
*)
echo "Invalid ionice parameters $value"\
>&2
exit $EIONICE
;;
esac
fi
;;
'temporary-directory')
tempdir="$value"
;;
'database')
database="$value"
;;
'skip-timestamp-microsec')
skip_us_timestamp="$value"
;;
debug)
(( value > debug )) && debug=$value
;;
esac
}