-#!/bin/sh
+#!/bin/ash
# Copyright (C)2022 Johannes Truschnigg (https://johannes.truschnigg.info/)
#
_goon() {
echo "" >&2
echo "${1:-Hit the [ENTER] key when ready, or [CTRL]+[C] to abort...}" >&2
- read -s _ >/dev/null
+ read -r -s _ >/dev/null
printf '\n\n' >&2
}
_bar() {
- local lcnt=0
- while [ $lcnt -lt $1 ]
+ lcnt=0
+ while [ "$lcnt" -lt "$1" ]
do
printf '='
let lcnt++
then
printf 'Auto-detected downstream (rx) network device to adjust:\n\t%s\n\n' "${ifb_dev}" >&2
printf 'Please confirm this by supplying either this sysfs path again,\nor provide a custom value to replace it:\n\t' >&2
- read ifb_dev
+ read -r ifb_dev
else
printf 'FATAL: No SQM shaping (rx) network device could be determined.\nAre you sure SQM has been set up, e.g. via luci-app-sqm?\n' >&2
exit 1
else
printf 'Failed to auto-detect a suitable upstream/tx interface.\nPlease key in the proper interface name.\n\t' >&2
fi
-read iface_tx
+read -r iface_tx
if ! [ -f /sys/class/net/"${iface_tx}"///statistics/tx_bytes ]
then
_h 'set bandwidth limits'
printf 'Please key in the positive integer LOWER bound (=minimum) bandwidth in Kbps\nfor your downstream Internet connection that you want to shape to: ' >&2
-read bw_down_min
+read -r bw_down_min
echo "" >&2
printf 'Please key in the positive integer UPPER bound (=maximum) bandwidth in Kbps\nfor your downstream Internet connection that you want to shape to: ' >&2
-read bw_down_max
+read -r bw_down_max
echo "" >&2
-if ! [ ${bw_down_min}0 -lt ${bw_down_max}0 ]
+if ! [ "${bw_down_min}"0 -lt "${bw_down_max}"0 ]
then
printf 'FATAL: Maximum shaping bandwidth must be greater than the minimum.\n'
exit 1
_h 'configure sqm_lagthrottle bias'
printf 'sqm_lagthrottle can be configured to prioritize bandwidth over latency,\nor vice versa.\n\nIf you would prefer to keep the dynamic target bandwidth high even in\nthe face of worsening latency/bufferbloat, please key in "bandwidth" below.\n\nAll other inputs will lead to a preference for lower latency.\n\n\t'
-read bw_or_lat_bias
+read -r bw_or_lat_bias
if [ x"${bw_or_lat_bias}" = xbandwidth ]
then
bw_or_lat_bias="bandwidth"
_h 'configure sqm_lagthrottle eagerness'
printf 'sqm_lagthrottle can be configured to be eager or relaxed\nwhen making shaper adjustment decisions.\n\nIn eager mode, decisions to try to react meaningfully to changing\ncircumstances (incrasing latency) are taken more often.\n\nIn relaxed mode, bandwidth limits will be adjusted less frequently,\nwhich MAY save some CPU time.\n\nKeying in "relaxed" below chooses that mode.\nAll other inputs will lead to eager operation.\n\n\t'
-read relaxed_or_eager
+read -r relaxed_or_eager
if [ x"${relaxed_or_eager}" = xrelaxed ]
then
relaxed_or_eager="relaxed"