Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v1.5.1 (06-Sep-2025)
- FIXED: Properly compare version by using arithmetic conversion
- FIXED: Fixed new schedule keeping Flow Cache disabled when disabling QoS

v1.5.0 (06-Sep-2025)
- FIXED: Allow script versions with double-digit segments.

Expand Down
2 changes: 1 addition & 1 deletion flexqos.asp
Original file line number Diff line number Diff line change
Expand Up @@ -3104,7 +3104,7 @@ function DelCookie(cookiename){
<table width="100%" border="1" cellspacing="0" cellpadding="4" class="FormTable_table">
<thead>
<tr>
<td colspan="4">Add schedule window</td>
<td colspan="4">Add schedule</td>
</tr>
</thead>
<tbody>
Expand Down
107 changes: 73 additions & 34 deletions flexqos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Contributors: @maghuro
# shellcheck disable=SC1090,SC1091,SC2039,SC2154,SC3043
# amtm NoMD5check
version=1.5.0
version=1.5.1
release=2025-09-06
# Forked from FreshJR_QOS v8.8, written by FreshJR07 https://github.com/FreshJR07/FreshJR_QOS
# License
Expand Down Expand Up @@ -1029,20 +1029,28 @@ compare_remote_version() {
# Check version on Github and determine the difference with the installed version
# Outcomes: Version update, or no update
local remotever
# Fetch version of the shell script on Github
remotever="$(curl -fsN --retry 3 --connect-timeout 3 \

remotever="$(curl -fsS --retry 3 --connect-timeout 3 \
"${GIT_URL}/$(basename "${SCRIPTPATH}")" \
| /bin/grep '^version=' \
| sed -e 's/^version=//' -e 's/"//g' -e 's/\r//g')"
| sed -e 's/^version=//' -e 's/"//g' -e 's/\r//g' -e 's/[^0-9.]//g')"

# Convert 1.5.0 -> 001005000 (4 parts just in case)
ver2int() {
local a b c d IFS=.
set -- $1
a=${1:-0}; b=${2:-0}; c=${3:-0}; d=${4:-0}
printf '%03d%03d%03d%03d\n' "$a" "$b" "$c" "$d"
}

if [ "$( echo "${version}" | sed 's/\.//g' )" -lt \
"$( echo "${remotever}" | sed 's/\.//g' )" ]; then
# version upgrade
echo "${remotever}"
[ -z "$remotever" ] && { printf 'Error\n'; return; }

if [ "$(ver2int "$version")" -lt "$(ver2int "$remotever")" ]; then
printf '%s\n' "$remotever"
else
printf "NoUpdate\n"
printf 'NoUpdate\n'
fi
} # compare_remote_version
}

update() {
# Check for, and optionally apply updates.
Expand Down Expand Up @@ -1114,6 +1122,54 @@ _flush_conntrack_(){
fi
}

_fc_apply_policy() {
# $1 = "on" (QoS being enabled) -> maybe DISABLE FC (Auto/Force)
# $1 = "off" (QoS being disabled) -> maybe ENABLE FC (Auto)
case "$(uname -r)" in
4.19.*)
# Make sure we have current settings
[ -z "${fccontrol}${iptables_rules}" ] && get_config

case "${1}" in
on)
# Mirror the existing startup() logic
if [ -n "${iptables_rules}" ]; then
if [ "${fccontrol}" = "1" ]; then
# Force disable
if [ "$(nvram get fc_disable)" != "1" ]; then
logmsg "Disabling flowcache"
fc disable
fc flush
fi
elif [ "${fccontrol}" = "2" ]; then
# Auto: only if <400 Mbps both ways and FC currently enabled
if \
[ "$(printf "%.0f" "$(nvram get qos_ibw)")" -lt 409600 ] && \
[ "$(printf "%.0f" "$(nvram get qos_obw)")" -lt 409600 ] && \
[ "$(nvram get fc_disable)" = "0" ]
then
logmsg "Auto-disabling flowcache"
fc disable
fc flush
fi
fi
fi
;;
off)
# When QoS is turned off by schedule, *re-enable* FC in Auto mode
if [ "${fccontrol}" = "2" ]; then
if [ "$(nvram get fc_disable)" != "0" ]; then
logmsg "QoS disabled by schedule; re-enabling flowcache (Auto)"
fc enable
fc flush
fi
fi
;;
esac
;;
esac
}

prompt_restart() {
# Restart QoS so that FlexQoS changes can take effect.
# Possible values for $needrestart:
Expand Down Expand Up @@ -1152,6 +1208,7 @@ qos_stop() {

if [ "${need_stop}" = "1" ]; then
service stop_qos
_fc_apply_policy off
prompt_restart
_flush_conntrack_
# Only persist if explicitly requested
Expand Down Expand Up @@ -1180,6 +1237,7 @@ qos_start() {

if [ "${need_start}" = "1" ]; then
service start_qos
_fc_apply_policy on
prompt_restart
_flush_conntrack_
# Only persist if explicitly requested
Expand Down Expand Up @@ -2218,30 +2276,11 @@ startup() {
generate_bwdpi_arrays
get_config
qos_schedule_apply_from_config

case "$(uname -r)" in
4.19.*)
if \
[ "$(printf "%.0f" "$(nvram get qos_ibw)")" -lt 409600 ] && \
[ "$(printf "%.0f" "$(nvram get qos_obw)")" -lt 409600 ] && \
[ "$(nvram get fc_disable)" = "0" ] && \
[ -n "${iptables_rules}" ] && \
[ "${fccontrol}" = "2" ]
then
logmsg "Auto-disabling flowcache"
fc disable
fc flush
elif \
[ -n "${iptables_rules}" ] && \
[ "${fccontrol}" = "1" ]
then
logmsg "Disabling flowcache"
fc disable
fc flush
fi
;;
esac

if [ "$(nvram get qos_enable)" = "1" ]; then
_fc_apply_policy on
else
_fc_apply_policy off
fi
_flush_conntrack_

cru d "${SCRIPTNAME}"_5min 2>/dev/null
Expand Down