Fixed shell issue

This commit is contained in:
Sam Latsin 2026-10-15 13:28:14 +03:00
parent 1abb5e50af
commit 00d0ffafcb

View File

@ -309,7 +309,10 @@ hhmm_to_min() {
*) return 1 ;;
esac
_h=${1%:*} _m=${1#*:}
_h=$((10#$_h)) _m=$((10#$_m))
# strip one leading zero so 08/09 are not read as octal, without the
# bash-only 10# radix (busybox ash lacks it)
_h=${_h#0} _m=${_m#0}
_h=${_h:-0} _m=${_m:-0}
[ "$_h" -le 23 ] && [ "$_m" -le 59 ] || return 1
echo $((_h * 60 + _m))
}
@ -327,7 +330,7 @@ jitter_min() {
# true when now is inside the (jittered) schedule window; handles a window that
# wraps past midnight (END <= START). NOW_MIN/SCHED_DAY override the clock in tests.
in_window() {
_now=${NOW_MIN:-$((10#$(date +%H) * 60 + 10#$(date +%M)))}
_now=${NOW_MIN:-$(hhmm_to_min "$(date +%H:%M)")}
_day=${SCHED_DAY:-$(date +%F)}
_s=$(hhmm_to_min "$OVPN_SCHED_START") || { log "bad OVPN_SCHED_START=$OVPN_SCHED_START"; return 0; }
_e=$(hhmm_to_min "$OVPN_SCHED_END") || { log "bad OVPN_SCHED_END=$OVPN_SCHED_END"; return 0; }