mirror of
https://github.com/remittor/zapret-openwrt.git
synced 2025-12-06 11:36:48 +03:00
install: Patch luci header.ut for force update browser-cache
Aux info: https://github.com/openwrt/luci/pull/7725
This commit is contained in:
@@ -156,3 +156,35 @@ function init_before_start
|
|||||||
remove_cron_task_logs
|
remove_cron_task_logs
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function patch_luci_header_ut
|
||||||
|
{
|
||||||
|
# INFO: https://github.com/openwrt/luci/pull/7725
|
||||||
|
local header_ut=/usr/share/ucode/luci/template/header.ut
|
||||||
|
local runtime_uc=/usr/share/ucode/luci/runtime.uc
|
||||||
|
local newenv
|
||||||
|
[ ! -f $header_ut ] && return 0
|
||||||
|
[ ! -f $runtime_uc ] && return 0
|
||||||
|
if grep -q "pkgs_update_time" $runtime_uc; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if grep -q "pkgs_update_time" $header_ut; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
sed -i "/^import { access/i import { stat } from 'fs';" $runtime_uc
|
||||||
|
if ! grep -q "{ stat }" $runtime_uc; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
newenv="self.env.pkgs_update_time = stat('/lib/apk/db/installed')?.mtime ?? stat('/usr/lib/opkg/status')?.mtime ?? 0;"
|
||||||
|
newenv=`adapt_for_sed "$newenv"`
|
||||||
|
sed -i "/self.env.include =/i $newenv" $runtime_uc
|
||||||
|
if ! grep -q "pkgs_update_time" $runtime_uc; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
sed -i 's/luci.js?v=\(.*\)"><\/script>/luci.js?v=\1-{{ pkgs_update_time }}"><\/script>/g' $header_ut
|
||||||
|
if ! grep -q "pkgs_update_time" $header_ut; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
logger -p notice -t ZAPRET "patch_luci_header_ut: OK"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ is_run_on_boot && IS_RUN_ON_BOOT=1 || IS_RUN_ON_BOOT=0
|
|||||||
function enable
|
function enable
|
||||||
{
|
{
|
||||||
local run_on_boot=""
|
local run_on_boot=""
|
||||||
|
patch_luci_header_ut
|
||||||
if [ "$IS_RUN_ON_BOOT" = "1" ]; then
|
if [ "$IS_RUN_ON_BOOT" = "1" ]; then
|
||||||
if [ -n "$ZAPRET_CFG_SEC_NAME" ]; then
|
if [ -n "$ZAPRET_CFG_SEC_NAME" ]; then
|
||||||
run_on_boot=$( get_run_on_boot_option )
|
run_on_boot=$( get_run_on_boot_option )
|
||||||
@@ -59,6 +60,7 @@ function enabled
|
|||||||
function boot
|
function boot
|
||||||
{
|
{
|
||||||
local run_on_boot=""
|
local run_on_boot=""
|
||||||
|
patch_luci_header_ut
|
||||||
if [ "$IS_RUN_ON_BOOT" = "1" ]; then
|
if [ "$IS_RUN_ON_BOOT" = "1" ]; then
|
||||||
if [ -n "$ZAPRET_CFG_SEC_NAME" ]; then
|
if [ -n "$ZAPRET_CFG_SEC_NAME" ]; then
|
||||||
run_on_boot=$( get_run_on_boot_option )
|
run_on_boot=$( get_run_on_boot_option )
|
||||||
|
|||||||
Reference in New Issue
Block a user