Skip to content

Commit

Permalink
v4.6.8
Browse files Browse the repository at this point in the history
1.完善和优化代码运行的安全性、稳定性及可靠性。
  • Loading branch information
larsonzh authored Nov 8, 2024
1 parent 72c3f2e commit 8139ec3
Show file tree
Hide file tree
Showing 15 changed files with 116 additions and 28 deletions.
24 changes: 19 additions & 5 deletions source_codes/install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# install.sh v4.6.7
# install.sh v4.6.8
# By LZ 妙妙呜 ([email protected])

# LZ RULE script for Asuswrt-Merlin Router
Expand All @@ -13,13 +13,19 @@

# shellcheck disable=SC2317 # Don't warn about unreachable commands in this function

LZ_VERSION=v4.6.7
LZ_VERSION=v4.6.8
TIMEOUT=10
CURRENT_PATH="${0%/*}"
[ "${CURRENT_PATH:0:1}" != '/' ] && CURRENT_PATH="$( pwd )${CURRENT_PATH#*.}"
SYSLOG="/tmp/syslog.log"
PATH_LOCK="/var/lock" LOCK_FILE_ID="555"
LOCK_FILE="${PATH_LOCK}/lz_rule.lock"
PATH_BASE="/jffs/scripts"
[ "$( echo "${1}" | tr T t )" = t ] && PATH_BASE="${HOME}"
HANNER="$( echo "${1}" | tr T t )"
[ "${HANNER}" = t ] && {
PATH_BASE="$( readlink -f "/root" )"
{ [ -z "${PATH_BASE}" ] || [ "${PATH_BASE}" = '/' ]; } && PATH_BASE="$( readlink -f "/tmp" )"
}
SYSLOG="/tmp/syslog.log"
lzdate() { date +"%F %T"; }

{
Expand Down Expand Up @@ -51,7 +57,7 @@ elif [ "${USER}" = "root" ]; then
fi

AVAL_SPACE=
if [ "${1}" = "entware" ]; then
if { [ "${HANNER}" = "entware" ] || [ "${HANNER}" = "entwareX" ]; }; then
if which opkg > /dev/null 2>&1; then
for sditem in $( df | awk '$1 ~ /^\/dev\/sd/ {print $1":-"$4":-"$6}' )
do
Expand Down Expand Up @@ -134,6 +140,11 @@ fi

echo " Installation in progress..." | tee -ai "${SYSLOG}" 2> /dev/null

if { [ "${HANNER}" != "X" ] && [ "${HANNER}" != "entwareX" ]; }; then
[ ! -d "${PATH_LOCK}" ] && { mkdir -p "${PATH_LOCK}" > /dev/null 2>&1; chmod 777 "${PATH_LOCK}" > /dev/null 2>&1; }
eval "exec ${LOCK_FILE_ID}<>${LOCK_FILE}"; flock -x "${LOCK_FILE_ID}" > /dev/null 2>&1;
fi

PATH_LZ="${PATH_BASE}/lz"
if ! mkdir -p "${PATH_LZ}" > /dev/null 2>&1; then
{
Expand All @@ -144,6 +155,7 @@ if ! mkdir -p "${PATH_LZ}" > /dev/null 2>&1; then
echo " LZ script installation failed."
echo -e " $(lzdate)\n"
} | tee -ai "${SYSLOG}" 2> /dev/null
{ [ "${HANNER}" != "X" ] && [ "${HANNER}" != "entwareX" ]; } && flock -u "${LOCK_FILE_ID}" > /dev/null 2>&1
exit 1
fi

Expand Down Expand Up @@ -432,6 +444,8 @@ fi
echo -e " $(lzdate)\n"
} | tee -ai "${SYSLOG}" 2> /dev/null

{ [ "${HANNER}" != "X" ] && [ "${HANNER}" != "entwareX" ]; } && flock -u "${LOCK_FILE_ID}" > /dev/null 2>&1

exit 0

#END
3 changes: 3 additions & 0 deletions source_codes/lz/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v4.6.8 (2024/11/8)
1.完善和优化代码运行的安全性、稳定性及可靠性。

v4.6.7 (2024/11/8)
1.解决本软件网络安装过程中,ASD 进程误删关键文件导致
安装失败的问题。
Expand Down
2 changes: 1 addition & 1 deletion source_codes/lz/configs/lz_rule_config.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_rule_config.sh v4.6.7
# lz_rule_config.sh v4.6.8
# By LZ 妙妙呜 ([email protected])

# 本软件采用CIDR(无类别域间路由,Classless Inter-Domain Routing)技术,是一个在Internet上创建附加地
Expand Down
2 changes: 1 addition & 1 deletion source_codes/lz/func/lz_clear_custom_scripts_data.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_clear_custom_scripts_data.sh v4.6.7
# lz_clear_custom_scripts_data.sh v4.6.8
# By LZ 妙妙呜 ([email protected])

## 清除用户自定义脚本数据
Expand Down
2 changes: 1 addition & 1 deletion source_codes/lz/func/lz_define_global_variables.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_define_global_variables.sh v4.6.7
# lz_define_global_variables.sh v4.6.8
# By LZ 妙妙呜 ([email protected])
# QnkgTFog5aaZ5aaZ5ZGc77yI6Juk6J+G5aKp5YS/77yJ(首次运行标识,切勿修改)

Expand Down
2 changes: 1 addition & 1 deletion source_codes/lz/func/lz_initialize_config.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_initialize_config.sh v4.6.7
# lz_initialize_config.sh v4.6.8
# By LZ 妙妙呜 ([email protected])

## 初始化脚本配置
Expand Down
2 changes: 1 addition & 1 deletion source_codes/lz/func/lz_rule_address_query.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_rule_address_query.sh v4.6.7
# lz_rule_address_query.sh v4.6.8
# By LZ 妙妙呜 ([email protected])

## 网址信息查询脚本
Expand Down
2 changes: 1 addition & 1 deletion source_codes/lz/func/lz_rule_func.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_rule_func.sh v4.6.7
# lz_rule_func.sh v4.6.8
# By LZ 妙妙呜 ([email protected])

#BEGIN
Expand Down
2 changes: 1 addition & 1 deletion source_codes/lz/func/lz_rule_status.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_rule_status.sh v4.6.7
# lz_rule_status.sh v4.6.8
# By LZ 妙妙呜 ([email protected])

## 显示脚本运行状态脚本
Expand Down
4 changes: 2 additions & 2 deletions source_codes/lz/func/lz_vpn_daemon.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_vpn_daemon.sh v4.6.7
# lz_vpn_daemon.sh v4.6.8
# By LZ 妙妙呜 ([email protected])

## 虚拟专网客户端路由刷新处理后台守护进程脚本
Expand All @@ -10,7 +10,7 @@
#BEGIN

## 版本号
LZ_VERSION=v4.6.7
LZ_VERSION=v4.6.8

## 项目接口文件部署路径
PATH_INTERFACE="${0%/*}"
Expand Down
43 changes: 39 additions & 4 deletions source_codes/lz/interface/lz_rule_service.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_rule_service.sh v4.6.7
# lz_rule_service.sh v4.6.8
# By LZ 妙妙呜 ([email protected])

## 服务接口脚本
Expand All @@ -15,6 +15,8 @@ PATH_LZ="${PATH_LZ%/*}"
[ ! -s "${PATH_LZ}/lz_rule.sh" ] && return
[ "${1}" = "stop" ] && [ "${2}" = "LZRule" ] && "${PATH_LZ}/lz_rule.sh" "STOP"
[ "${1}" != "start" ] && [ "${1}" != "restart" ] && return
PATH_LOCK="/var/lock" LOCK_FILE_ID="555"
LOCK_FILE="${PATH_LOCK}/lz_rule.lock"

get_repo_site() {
local remoteRepo="https://gitee.com/"
Expand Down Expand Up @@ -207,6 +209,8 @@ case "${2}" in
;;
LZDetectVersion)
detect_version() {
[ ! -d "${PATH_LOCK}" ] && { mkdir -p "${PATH_LOCK}" > /dev/null 2>&1; chmod 777 "${PATH_LOCK}" > /dev/null 2>&1; }
eval "exec ${LOCK_FILE_ID}<>${LOCK_FILE}"; flock -x "${LOCK_FILE_ID}" > /dev/null 2>&1;
local PATH_WEB_LZR="$( readlink "/www/user" )/lzr"
echo 'var versionStatus = "InProgress";' > "${PATH_WEB_LZR}/detect_version.js"
local LZ_REPO="$( get_repo_site )"
Expand All @@ -226,11 +230,14 @@ case "${2}" in
printf "%s [%s]:\n" "$( date +"%F %T" )" "${$}"
} >> "/tmp/syslog.log"
fi
flock -u "${LOCK_FILE_ID}" > /dev/null 2>&1
}
detect_version &
;;
LZDoUpdate)
do_update() {
[ ! -d "${PATH_LOCK}" ] && { mkdir -p "${PATH_LOCK}" > /dev/null 2>&1; chmod 777 "${PATH_LOCK}" > /dev/null 2>&1; }
eval "exec ${LOCK_FILE_ID}<>${LOCK_FILE}"; flock -x "${LOCK_FILE_ID}" > /dev/null 2>&1;
[ -d "${PATH_LZ}/tmp/doupdate" ] && rm -rf "${PATH_LZ}/tmp/doupdate" 2> /dev/null
local LZ_REPO="$( get_repo_site )"
local remoteVer="$( get_last_version "${LZ_REPO}" )"
Expand Down Expand Up @@ -286,10 +293,36 @@ case "${2}" in
if [ -s "${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" ]; then
chmod 775 "${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh"
sed -i "s/elif \[ \"\${USER}\" = \"root\" \]; then/elif \[ \"\${USER}\" = \"\" \]; then/g" "${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" 2> /dev/null
if [ "${PATH_LZ}" = "/jffs/scripts/lz" ]; then
"${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" && [ -s "${PATH_LZ}/lz_rule.sh" ] && "${PATH_LZ}/lz_rule.sh"
local oldRemote="$( awk -v ver="${remoteVer##*v}" 'BEGIN{
ret = 0;
split(ver, arr, ".");
for (i = 1; i < 4; ++i) {
if (arr[i] !~ /[0-9]+/)
arr[i] = 0 + 0;
else
arr[i] = arr[i] + 0;
}
if (arr[1] == 4 && arr[2] == 6 && arr[3] >= 8)
ret = 1;
else if (arr[1] == 4 && arr[2] > 6)
ret = 1;
else if (arr[1] > 4)
ret = 1;
delete arr;
print ret;
}' )"
if [ "${oldRemote}" != "0" ]; then
if [ "${PATH_LZ}" = "/jffs/scripts/lz" ]; then
"${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" "X" && upgrade_restart="1"
else
"${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" "entwareX" && upgrade_restart="1"
fi
else
"${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" "entware" && [ -s "${PATH_LZ}/lz_rule.sh" ] && "${PATH_LZ}/lz_rule.sh"
if [ "${PATH_LZ}" = "/jffs/scripts/lz" ]; then
"${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" && upgrade_restart="1"
else
"${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" "entware" && upgrade_restart="1"
fi
fi
else
{
Expand All @@ -313,6 +346,8 @@ case "${2}" in
printf "%s [%s]:\n" "$( date +"%F %T" )" "${$}"
} >> "/tmp/syslog.log"
fi
flock -u "${LOCK_FILE_ID}" > /dev/null 2>&1
[ "${upgrade_restart}" ] && [ -s "${PATH_LZ}/lz_rule.sh" ] && "${PATH_LZ}/lz_rule.sh"
}
do_update &
;;
Expand Down
2 changes: 1 addition & 1 deletion source_codes/lz/js/lz_policy_routing.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
# lz_policy_routing.js v4.6.7
# lz_policy_routing.js v4.6.8
# By LZ 妙妙呜 ([email protected])
# LZ JavaScript for Asuswrt-Merlin Router
Expand Down
36 changes: 31 additions & 5 deletions source_codes/lz/lz_rule.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_rule.sh v4.6.7
# lz_rule.sh v4.6.8
# By LZ 妙妙呜 ([email protected])

# 本软件采用CIDR(无类别域间路由,Classless Inter-Domain Routing)技术,是一个在Internet上创建附加地
Expand Down Expand Up @@ -86,7 +86,7 @@
## -------------全局数据定义及初始化-------------------

## 版本号
LZ_VERSION=v4.6.7
LZ_VERSION=v4.6.8

## 治理ASD进程删我文件
## 0--启用(缺省);非0--躺平
Expand Down Expand Up @@ -1744,10 +1744,36 @@ if lz_project_file_management "${1}"; then
if [ -s "${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" ]; then
chmod 775 "${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh"
sed -i "s/elif \[ \"\${USER}\" = \"root\" \]; then/elif \[ \"\${USER}\" = \"\" \]; then/g" "${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" 2> /dev/null
if [ "${PATH_LZ}" = "/jffs/scripts/lz" ]; then
"${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" && upgrade_restart="1"
local oldRemote="$( awk -v ver="${remoteVer##*v}" 'BEGIN{
ret = 0;
split(ver, arr, ".");
for (i = 1; i < 4; ++i) {
if (arr[i] !~ /[0-9]+/)
arr[i] = 0 + 0;
else
arr[i] = arr[i] + 0;
}
if (arr[1] == 4 && arr[2] == 6 && arr[3] >= 8)
ret = 1;
else if (arr[1] == 4 && arr[2] > 6)
ret = 1;
else if (arr[1] > 4)
ret = 1;
delete arr;
print ret;
}' )"
if [ "${oldRemote}" != "0" ]; then
if [ "${PATH_LZ}" = "/jffs/scripts/lz" ]; then
"${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" "X" && upgrade_restart="1"
else
"${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" "entwareX" && upgrade_restart="1"
fi
else
"${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" "entware" && upgrade_restart="1"
if [ "${PATH_LZ}" = "/jffs/scripts/lz" ]; then
"${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" && upgrade_restart="1"
else
"${PATH_LZ}/tmp/doupdate/lz_rule-${remoteVer}/install.sh" "entware" && upgrade_restart="1"
fi
fi
else
{
Expand Down
16 changes: 13 additions & 3 deletions source_codes/lz/uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# uninstall.sh v4.6.7
# uninstall.sh v4.6.8
# By LZ ([email protected])

# LZ RULE script for Asuswrt-Merlin Router
Expand All @@ -8,9 +8,13 @@

#BEGIN

LZ_VERSION=v4.6.7
LZ_VERSION=v4.6.8
CURRENT_PATH="${0%/*}"
[ "${CURRENT_PATH:0:1}" != '/' ] && CURRENT_PATH="$( pwd )${CURRENT_PATH#*.}"
PATH_LOCK="/var/lock" LOCK_FILE_ID="555"
LOCK_FILE="${PATH_LOCK}/lz_rule.lock"
PATH_HOME="$( readlink -f "/root" )"
{ [ -z "${PATH_HOME}" ] || [ "${PATH_HOME}" = '/' ]; } && PATH_HOME="$( readlink -f "/tmp" )"
SYSLOG="/tmp/syslog.log"
lzdate() { date +"%F %T"; }

Expand All @@ -22,13 +26,17 @@ lzdate() { date +"%F %T"; }
echo
} | tee -ai "${SYSLOG}" 2> /dev/null

[ ! -d "${PATH_LOCK}" ] && { mkdir -p "${PATH_LOCK}" > /dev/null 2>&1; chmod 777 "${PATH_LOCK}" > /dev/null 2>&1; }
eval "exec ${LOCK_FILE_ID}<>${LOCK_FILE}"; flock -x "${LOCK_FILE_ID}" > /dev/null 2>&1;

if [ ! -f "${CURRENT_PATH}/lz_rule.sh" ]; then
{
echo "$(lzdate)" [$$]: "${CURRENT_PATH}/lz_rule.sh" does not exist.
echo
echo " LZ script uninstallation failed."
echo -e " $(lzdate)\n\n"
} | tee -ai "${SYSLOG}" 2> /dev/null
flock -u "${LOCK_FILE_ID}" > /dev/null 2>&1
exit "1"
else
chmod +x "${CURRENT_PATH}/lz_rule.sh" > /dev/null 2>&1
Expand Down Expand Up @@ -105,7 +113,9 @@ rmdir "${CURRENT_PATH}" > /dev/null 2>&1
echo -e " $(lzdate)\n\n"
} | tee -ai "${SYSLOG}" 2> /dev/null

[ ! -d "${CURRENT_PATH}" ] && { cd "${CURRENT_PATH%/*}/" || { cd "${HOME}/" || exit "0"; }; }
flock -u "${LOCK_FILE_ID}" > /dev/null 2>&1

[ ! -d "${CURRENT_PATH}" ] && { cd "${CURRENT_PATH%/*}/" || { cd "${PATH_HOME}/" || exit "0"; }; }

exit "0"

Expand Down
2 changes: 1 addition & 1 deletion source_codes/lz/webs/LZ_Policy_Routing_Content.asp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
url: '/ext/lzr/LZRGlobal.html',
dataType: 'text',
success: function(response) {
// v4.6.7
// v4.6.8
retVal = (response.match(/QnkgTFog5aaZ5aaZ5ZGc77yI6Juk6J[\+]G5aKp5YS[\/]77yJ/m) != null) ? true : false;
}
});
Expand Down

0 comments on commit 8139ec3

Please sign in to comment.