-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.完善和优化代码运行的安全性、稳定性及可靠性。
- Loading branch information
Showing
15 changed files
with
116 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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"; } | ||
|
||
{ | ||
|
@@ -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 | ||
|
@@ -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 | ||
{ | ||
|
@@ -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 | ||
|
||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 进程误删关键文件导致 | ||
安装失败的问题。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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上创建附加地 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | ||
|
||
## 清除用户自定义脚本数据 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(首次运行标识,切勿修改) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | ||
|
||
## 初始化脚本配置 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | ||
|
||
## 网址信息查询脚本 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | ||
|
||
## 显示脚本运行状态脚本 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | ||
|
||
## 虚拟专网客户端路由刷新处理后台守护进程脚本 | ||
|
@@ -10,7 +10,7 @@ | |
#BEGIN | ||
|
||
## 版本号 | ||
LZ_VERSION=v4.6.7 | ||
LZ_VERSION=v4.6.8 | ||
|
||
## 项目接口文件部署路径 | ||
PATH_INTERFACE="${0%/*}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | ||
|
||
## 服务接口脚本 | ||
|
@@ -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/" | ||
|
@@ -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 )" | ||
|
@@ -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}" )" | ||
|
@@ -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 | ||
{ | ||
|
@@ -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 & | ||
;; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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上创建附加地 | ||
|
@@ -86,7 +86,7 @@ | |
## -------------全局数据定义及初始化------------------- | ||
|
||
## 版本号 | ||
LZ_VERSION=v4.6.7 | ||
LZ_VERSION=v4.6.8 | ||
|
||
## 治理ASD进程删我文件 | ||
## 0--启用(缺省);非0--躺平 | ||
|
@@ -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 | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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"; } | ||
|
||
|
@@ -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 | ||
|
@@ -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" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters