PKG_NAME:=banip
PKG_VERSION:=1.5.6
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_LICENSE:=GPL-3.0-or-later
$(INSTALL_DIR) $(1)/www/cgi-bin
$(INSTALL_BIN) ./files/banip.cgi $(1)/www/cgi-bin/banip
+
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/95-banip-housekeeping $(1)/etc/uci-defaults
endef
$(eval $(call BuildPackage,banip))
--- /dev/null
+#!/bin/sh
+# This is free software, licensed under the GNU General Public License v3.
+
+# (s)hellcheck exceptions
+# shellcheck disable=all
+
+export LC_ALL=C
+export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
+
+config="banip"
+old_options="ban_loginput ban_logforwardwan ban_logforwardlan ban_blockinput ban_blockforwardwan ban_blockforwardlan"
+
+for option in ${old_options}; do
+ if uci -q get ${config}.global.${option} >/dev/null 2>&1; then
+ old_values="$(uci -q get "${config}.global.${option}")"
+ for value in ${old_values}; do
+ case "${option}" in
+ "ban_loginput" | "ban_logforwardwan")
+ uci -q set "${config}".global.ban_loginbound="${value}"
+ ;;
+ "ban_logforwardlan")
+ uci -q set "${config}".global.ban_logoutbound="${value}"
+ ;;
+ esac
+ done
+ uci -q delete "${config}.global.${option}"
+ fi
+done
+[ -n "$(uci -q changes "${config}")" ] && uci -q commit "${config}"
+exit 0
if [ -z "${etag_id}" ]; then
etag_id="$(printf "%s" "${http_head}" | "${ban_awkcmd}" 'tolower($0)~/^[[:space:]]*last-modified: /{gsub(/[Ll]ast-[Mm]odified:|[[:space:]]|,|:/,"");printf "%s\n",$1}')"
fi
- etag_cnt="$("${ban_grepcmd}" -c "^${feed}" "${ban_backupdir}/banIP.etag")"
+ etag_cnt="$("${ban_grepcmd}" -c "^${feed} " "${ban_backupdir}/banIP.etag")"
if [ "${http_code}" = "200" ] && [ "${etag_cnt}" = "${feed_cnt}" ] && [ -n "${etag_id}" ] &&
- "${ban_grepcmd}" -q "^${feed}${feed_suffix}[[:space:]]\+${etag_id}\$" "${ban_backupdir}/banIP.etag"; then
+ "${ban_grepcmd}" -q "^${feed} ${feed_suffix}[[:space:]]\+${etag_id}\$" "${ban_backupdir}/banIP.etag"; then
out_rc="0"
elif [ -n "${etag_id}" ]; then
if [ "${feed_cnt}" -lt "${etag_cnt}" ]; then
- "${ban_sedcmd}" -i "/^${feed}/d" "${ban_backupdir}/banIP.etag"
+ "${ban_sedcmd}" -i "/^${feed} /d" "${ban_backupdir}/banIP.etag"
else
- "${ban_sedcmd}" -i "/^${feed}${feed_suffix}/d" "${ban_backupdir}/banIP.etag"
+ "${ban_sedcmd}" -i "/^${feed} ${feed_suffix//\//\\/}/d" "${ban_backupdir}/banIP.etag"
fi
- printf "%-50s%s\n" "${feed}${feed_suffix}" "${etag_id}" >>"${ban_backupdir}/banIP.etag"
+ printf "%-50s%s\n" "${feed} ${feed_suffix}" "${etag_id}" >>"${ban_backupdir}/banIP.etag"
out_rc="2"
fi
fi
if [ "${feed_rc}" = "0" ]; then
for split_file in "${tmp_file}".*; do
if [ -s "${split_file}" ]; then
- "${ban_sedcmd}" -i "1 i #!${ban_nftcmd} -f\nadd element inet banIP "${feed}" { " "${split_file}"
+ "${ban_sedcmd}" -i "1 i #!${ban_nftcmd} -f\nadd element inet banIP ${feed} { " "${split_file}"
printf "%s\n" "}" >>"${split_file}"
# load split file to nftset
#
else
json_get_var value "${key}" >/dev/null 2>&1
if [ "${key}" = "status" ]; then
- [ "${value}" = "active" ] && value="${value} ($(f_actual))" || value="${value}"
+ [ "${value}" = "active" ] && value="${value} ($(f_actual))"
fi
fi
if [ "${key}" != "wan_interfaces" ] && [ "${key}" != "vlan_allow" ] && [ "${key}" != "vlan_block" ]; then