mirror of
https://github.com/juewuy/ShellCrash.git
synced 2026-03-12 00:11:31 +00:00
update
This commit is contained in:
548
scripts/menu.sh
548
scripts/menu.sh
@@ -2,8 +2,8 @@
|
|||||||
# Copyright (C) Juewuy
|
# Copyright (C) Juewuy
|
||||||
|
|
||||||
CRASHDIR=$(
|
CRASHDIR=$(
|
||||||
cd $(dirname $0)
|
cd $(dirname $0)
|
||||||
pwd
|
pwd
|
||||||
)
|
)
|
||||||
|
|
||||||
CFG_PATH="$CRASHDIR"/configs/ShellCrash.cfg
|
CFG_PATH="$CRASHDIR"/configs/ShellCrash.cfg
|
||||||
@@ -32,320 +32,316 @@ load_lang common
|
|||||||
load_lang menu
|
load_lang menu
|
||||||
|
|
||||||
checkrestart() {
|
checkrestart() {
|
||||||
comp_box "\033[32m$MENU_RESTART_NOTICE\033[0m"
|
comp_box "\033[32m$MENU_RESTART_NOTICE\033[0m"
|
||||||
btm_box "1) 立即重启" \
|
btm_box "1) 立即重启" \
|
||||||
"0) 暂不重启"
|
"0) 暂不重启"
|
||||||
read -r -p "$COMMON_INPUT> " res
|
read -r -p "$COMMON_INPUT> " res
|
||||||
if [ "$res" = 1 ]; then
|
if [ "$res" = 1 ]; then
|
||||||
start_service
|
start_service
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# 检查端口冲突
|
# 检查端口冲突
|
||||||
checkport() {
|
checkport() {
|
||||||
while true; do
|
while true; do
|
||||||
# Before each round of checks begins, execute netstat only once and cache the results
|
# Before each round of checks begins, execute netstat only once and cache the results
|
||||||
# Avoid calling the system command once for each port
|
# Avoid calling the system command once for each port
|
||||||
current_listening=$(netstat -ntul 2>&1)
|
current_listening=$(netstat -ntul 2>&1)
|
||||||
|
|
||||||
conflict_found=0
|
conflict_found=0
|
||||||
|
|
||||||
for portx in $dns_port $mix_port $redir_port $((redir_port + 1)) $db_port; do
|
for portx in $dns_port $mix_port $redir_port $((redir_port + 1)) $db_port; do
|
||||||
# Use `grep` to search within the cached variables instead of re-running `netstat`
|
# Use `grep` to search within the cached variables instead of re-running `netstat`
|
||||||
conflict_line=$(echo "$current_listening" | grep ":$portx ")
|
conflict_line=$(echo "$current_listening" | grep ":$portx ")
|
||||||
|
|
||||||
if [ -n "$conflict_line" ]; then
|
if [ -n "$conflict_line" ]; then
|
||||||
|
|
||||||
comp_box "【$portx】:$MENU_PORT_CONFLICT_TITLE" \
|
comp_box "【$portx】:$MENU_PORT_CONFLICT_TITLE" \
|
||||||
"\033[0m$(echo "$conflict_line" | head -n 1)\033[0m" \
|
"\033[0m$(echo "$conflict_line" | head -n 1)\033[0m" \
|
||||||
"\033[36m$MENU_PORT_CONFLICT_HINT\033[0m"
|
"\033[36m$MENU_PORT_CONFLICT_HINT\033[0m"
|
||||||
|
|
||||||
. "$CRASHDIR"/menus/2_settings.sh && set_adv_config
|
. "$CRASHDIR"/menus/2_settings.sh && set_adv_config
|
||||||
. "$CRASHDIR"/libs/get_config.sh
|
. "$CRASHDIR"/libs/get_config.sh
|
||||||
|
|
||||||
# Mark conflict and exit the for loop, triggering the while loop to restart the check
|
# Mark conflict and exit the for loop, triggering the while loop to restart the check
|
||||||
# This replaces the original recursive call to `checkport`
|
# This replaces the original recursive call to `checkport`
|
||||||
conflict_found=1
|
conflict_found=1
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# If no conflicts are found after the entire for loop completes,
|
# If no conflicts are found after the entire for loop completes,
|
||||||
# the while loop exits and the function terminates.
|
# the while loop exits and the function terminates.
|
||||||
if [ "$conflict_found" -eq 0 ]; then
|
if [ "$conflict_found" -eq 0 ]; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# 脚本启动前检查
|
# 脚本启动前检查
|
||||||
ckstatus() {
|
ckstatus() {
|
||||||
|
versionsh=$(cat "$CRASHDIR"/version)
|
||||||
|
[ -n "$versionsh" ] && versionsh_l=$versionsh
|
||||||
|
[ -z "$redir_mod" ] && redir_mod="$MENU_PURE_MOD"
|
||||||
|
|
||||||
versionsh=$(cat "$CRASHDIR"/version)
|
# 获取本机host地址
|
||||||
[ -n "$versionsh" ] && versionsh_l=$versionsh
|
[ -z "$host" ] && host=$(ubus call network.interface.lan status 2>&1 | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')
|
||||||
[ -z "$redir_mod" ] && redir_mod="$MENU_PURE_MOD"
|
[ -z "$host" ] && host=$(ip a 2>&1 | grep -w 'inet' | grep 'global' | grep 'lan' | grep -E ' 1(92|0|72)\.' | sed 's/.*inet.//g' | sed 's/\/[0-9][0-9].*$//g' | head -n 1)
|
||||||
|
[ -z "$host" ] && host=$(ip a 2>&1 | grep -w 'inet' | grep 'global' | grep -E ' 1(92|0|72)\.' | sed 's/.*inet.//g' | sed 's/\/[0-9][0-9].*$//g' | head -n 1)
|
||||||
|
[ -z "$host" ] && host='$MENU_IP_DF'
|
||||||
|
|
||||||
# 获取本机host地址
|
# dashboard目录位置
|
||||||
[ -z "$host" ] && host=$(ubus call network.interface.lan status 2>&1 | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')
|
if [ -f /www/clash/index.html ]; then
|
||||||
[ -z "$host" ] && host=$(ip a 2>&1 | grep -w 'inet' | grep 'global' | grep 'lan' | grep -E ' 1(92|0|72)\.' | sed 's/.*inet.//g' | sed 's/\/[0-9][0-9].*$//g' | head -n 1)
|
dbdir=/www/clash
|
||||||
[ -z "$host" ] && host=$(ip a 2>&1 | grep -w 'inet' | grep 'global' | grep -E ' 1(92|0|72)\.' | sed 's/.*inet.//g' | sed 's/\/[0-9][0-9].*$//g' | head -n 1)
|
hostdir=/clash
|
||||||
[ -z "$host" ] && host='$MENU_IP_DF'
|
else
|
||||||
|
dbdir="$CRASHDIR"/ui
|
||||||
|
hostdir=":$db_port/ui"
|
||||||
|
fi
|
||||||
|
|
||||||
# dashboard目录位置
|
if check_autostart; then
|
||||||
if [ -f /www/clash/index.html ]; then
|
auto="\033[32m$MENU_AUTOSTART_ON\033[0m"
|
||||||
dbdir=/www/clash
|
else
|
||||||
hostdir=/clash
|
auto="\033[31m$MENU_AUTOSTART_OFF\033[0m"
|
||||||
else
|
fi
|
||||||
dbdir="$CRASHDIR"/ui
|
|
||||||
hostdir=":$db_port/ui"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if check_autostart; then
|
PID=$(pidof CrashCore | awk '{print $NF}')
|
||||||
auto="\033[32m$MENU_AUTOSTART_ON\033[0m"
|
if [ -n "$PID" ]; then
|
||||||
else
|
run="\033[32m$MENU_RUN_ON($redir_mod$MENU_MOD)\033[0m"
|
||||||
auto="\033[31m$MENU_AUTOSTART_OFF\033[0m"
|
running_status
|
||||||
fi
|
elif [ "$firewall_area" = 5 ] && [ -n "$(ip route list table 100)" ]; then
|
||||||
|
run="\033[32m$MENU_RUN_SET($redir_mod$MENU_MOD)\033[0m"
|
||||||
|
else
|
||||||
|
run="\033[31m$MENU_RUN_OFF($redir_mod$MENU_MOD)\033[0m"
|
||||||
|
# 检测系统端口占用
|
||||||
|
checkport
|
||||||
|
fi
|
||||||
|
corename=$(echo $crashcore | sed 's/singboxr/SingBoxR/' | sed 's/singbox/SingBox/' | sed 's/clash/Clash/' | sed 's/meta/Mihomo/')
|
||||||
|
# [ "$firewall_area" = 5 ] && corename='转发'
|
||||||
|
[ -f "$TMPDIR"/debug.log -o -f "$CRASHDIR"/debug.log -a -n "$PID" ] && auto="\033[33m$MENU_AUTOSTART_DEBUG\033[0m"
|
||||||
|
|
||||||
PID=$(pidof CrashCore | awk '{print $NF}')
|
# 检查新手引导
|
||||||
if [ -n "$PID" ]; then
|
if [ -z "$userguide" ]; then
|
||||||
run="\033[32m$MENU_RUN_ON($redir_mod$MENU_MOD)\033[0m"
|
userguide=1
|
||||||
running_status
|
. "$CRASHDIR"/menus/userguide.sh && userguide
|
||||||
elif [ "$firewall_area" = 5 ] && [ -n "$(ip route list table 100)" ]; then
|
setconfig userguide 1
|
||||||
run="\033[32m$MENU_RUN_SET($redir_mod$MENU_MOD)\033[0m"
|
fi
|
||||||
else
|
|
||||||
run="\033[31m$MENU_RUN_OFF($redir_mod$MENU_MOD)\033[0m"
|
|
||||||
# 检测系统端口占用
|
|
||||||
checkport
|
|
||||||
fi
|
|
||||||
corename=$(echo $crashcore | sed 's/singboxr/SingBoxR/' | sed 's/singbox/SingBox/' | sed 's/clash/Clash/' | sed 's/meta/Mihomo/')
|
|
||||||
# [ "$firewall_area" = 5 ] && corename='转发'
|
|
||||||
[ -f "$TMPDIR"/debug.log -o -f "$CRASHDIR"/debug.log -a -n "$PID" ] && auto="\033[33m$MENU_AUTOSTART_DEBUG\033[0m"
|
|
||||||
|
|
||||||
# 检查新手引导
|
# 检查执行权限
|
||||||
if [ -z "$userguide" ]; then
|
[ ! -x "$CRASHDIR"/start.sh ] && chmod +x "$CRASHDIR"/start.sh
|
||||||
userguide=1
|
|
||||||
. "$CRASHDIR"/menus/userguide.sh && userguide
|
|
||||||
setconfig userguide 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 检查执行权限
|
line_break
|
||||||
[ ! -x "$CRASHDIR"/start.sh ] && chmod +x "$CRASHDIR"/start.sh
|
separator_line "="
|
||||||
|
content_line "\033[30;43m$MENU_WELCOME\033[0m"
|
||||||
|
content_line "Ver: $versionsh_l"
|
||||||
|
content_line "$MENU_TG_CHANNEL\033[36;4mhttps://t.me/ShellClash\033[0m"
|
||||||
|
separator_line "-"
|
||||||
|
content_line "$corename$run\t $auto"
|
||||||
|
if [ -n "$PID" ]; then
|
||||||
|
content_line "$MENU_MEM_USED\033[44m$VmRSS\033[0m\t $MENU_RUNNING_TIME\033[46;30m$day\033[44;37m$time\033[0m"
|
||||||
|
fi
|
||||||
|
separator_line "="
|
||||||
|
|
||||||
line_break
|
# 检查/tmp内核文件
|
||||||
separator_line "="
|
for file in $(ls /tmp | grep -v [/$] | grep -v ' ' | grep -Ev ".*(zip|7z|tar)$" | grep -iE 'CrashCore|^clash$|^clash-linux.*|^mihomo.*|^sing.*box'); do
|
||||||
content_line "\033[30;43m$MENU_WELCOME\033[0m"
|
comp_box "$MENU_TMP_CORE_FOUND \033[36m/tmp/$file\033[0m" \
|
||||||
content_line "Ver: $versionsh_l"
|
"$MENU_TMP_CORE_ASK"
|
||||||
content_line "$MENU_TG_CHANNEL\033[36;4mhttps://t.me/ShellClash\033[0m"
|
btm_box "1) 立即加载" \
|
||||||
separator_line "-"
|
"0) 暂不加载"
|
||||||
content_line "$corename$run\t $auto"
|
read -r -p "$COMMON_INPUT> " res
|
||||||
if [ -n "$PID" ]; then
|
[ "$res" = 1 ] && {
|
||||||
content_line "$MENU_MEM_USED\033[44m$VmRSS\033[0m\t $MENU_RUNNING_TIME\033[46;30m$day\033[44;37m$time\033[0m"
|
zip_type=$(echo "$file" | grep -oE 'tar.gz$|upx$|gz$')
|
||||||
fi
|
. "$CRASHDIR"/menus/9_upgrade.sh && setcoretype
|
||||||
separator_line "="
|
. "$CRASHDIR"/libs/core_tools.sh && core_check "/tmp/$file"
|
||||||
|
if [ "$?" = 0 ]; then
|
||||||
|
msg_alert "\033[32m$MENU_CORE_LOADED_OK\033[0m"
|
||||||
|
switch_core
|
||||||
|
else
|
||||||
|
rm -rf /tmp/"$file"
|
||||||
|
msg_alert "\033[33m$MENU_CORE_LOADED_BAD\033[0m" \
|
||||||
|
"\033[33m$MENU_CORE_REMOVED\033[0m"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
# 检查/tmp内核文件
|
# 检查/tmp配置文件
|
||||||
for file in $(ls /tmp | grep -v [/$] | grep -v ' ' | grep -Ev ".*(zip|7z|tar)$" | grep -iE 'CrashCore|^clash$|^clash-linux.*|^mihomo.*|^sing.*box'); do
|
for file in $(ls /tmp | grep -v [/$] | grep -v ' ' | grep -iE 'config.yaml$|config.yml$|config.json$'); do
|
||||||
comp_box "$MENU_TMP_CORE_FOUND \033[36m/tmp/$file\033[0m" \
|
tmp_file=/tmp/$file
|
||||||
"$MENU_TMP_CORE_ASK"
|
comp_box "$MENU_TMP_CFG_FOUND \033[36m/tmp/$file\033[0m" \
|
||||||
btm_box "1) 立即加载" \
|
"$MENU_TMP_CFG_ASK"
|
||||||
"0) 暂不加载"
|
btm_box "1) 立即加载" \
|
||||||
read -r -p "$COMMON_INPUT> " res
|
"0) 暂不加载"
|
||||||
[ "$res" = 1 ] && {
|
read -p "$COMMON_INPUT> " res
|
||||||
zip_type=$(echo "$file" | grep -oE 'tar.gz$|upx$|gz$')
|
[ "$res" = 1 ] && {
|
||||||
. "$CRASHDIR"/menus/9_upgrade.sh && setcoretype
|
if [ -n "$(echo /tmp/$file | grep -iE '.json$')" ]; then
|
||||||
. "$CRASHDIR"/libs/core_tools.sh && core_check "/tmp/$file"
|
mv -f /tmp/$file "$CRASHDIR"/jsons/config.json
|
||||||
if [ "$?" = 0 ]; then
|
else
|
||||||
msg_alert "\033[32m$MENU_CORE_LOADED_OK\033[0m"
|
mv -f /tmp/$file "$CRASHDIR"/yamls/config.yaml
|
||||||
switch_core
|
fi
|
||||||
else
|
msg_alert "\033[32m$MENU_CFG_LOADED_OK\033[0m "
|
||||||
rm -rf /tmp/"$file"
|
}
|
||||||
msg_alert "\033[33m$MENU_CORE_LOADED_BAD\033[0m" \
|
done
|
||||||
"\033[33m$MENU_CORE_REMOVED\033[0m"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
done
|
|
||||||
|
|
||||||
# 检查/tmp配置文件
|
# 检查禁用配置覆写
|
||||||
for file in $(ls /tmp | grep -v [/$] | grep -v ' ' | grep -iE 'config.yaml$|config.yml$|config.json$'); do
|
[ "$disoverride" = "1" ] && {
|
||||||
tmp_file=/tmp/$file
|
comp_box "\033[33m$MENU_OVERRIDE_WARN\033[0m" \
|
||||||
comp_box "$MENU_TMP_CFG_FOUND \033[36m/tmp/$file\033[0m" \
|
"$MENU_OVERRIDE_ASK"
|
||||||
"$MENU_TMP_CFG_ASK"
|
btm_box "1) 是" \
|
||||||
btm_box "1) 立即加载" \
|
"0) 否"
|
||||||
"0) 暂不加载"
|
read -p "$COMMON_INPUT> " res
|
||||||
read -p "$COMMON_INPUT> " res
|
[ "$res" = 1 ] && unset disoverride && setconfig disoverride
|
||||||
[ "$res" = 1 ] && {
|
}
|
||||||
if [ -n "$(echo /tmp/$file | grep -iE '.json$')" ]; then
|
|
||||||
mv -f /tmp/$file "$CRASHDIR"/jsons/config.json
|
|
||||||
else
|
|
||||||
mv -f /tmp/$file "$CRASHDIR"/yamls/config.yaml
|
|
||||||
fi
|
|
||||||
msg_alert "\033[32m$MENU_CFG_LOADED_OK\033[0m "
|
|
||||||
}
|
|
||||||
done
|
|
||||||
|
|
||||||
# 检查禁用配置覆写
|
|
||||||
[ "$disoverride" = "1" ] && {
|
|
||||||
comp_box "\033[33m$MENU_OVERRIDE_WARN\033[0m" \
|
|
||||||
"$MENU_OVERRIDE_ASK"
|
|
||||||
btm_box "1) 是" \
|
|
||||||
"0) 否"
|
|
||||||
read -p "$COMMON_INPUT> " res
|
|
||||||
[ "$res" = 1 ] && unset disoverride && setconfig disoverride
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main_menu() {
|
main_menu() {
|
||||||
while true; do
|
while true; do
|
||||||
ckstatus
|
ckstatus
|
||||||
|
|
||||||
content_line "1) \033[32m$MENU_MAIN_1\033[0m"
|
content_line "1) \033[32m$MENU_MAIN_1\033[0m"
|
||||||
content_line "2) \033[36m$MENU_MAIN_2\033[0m"
|
content_line "2) \033[36m$MENU_MAIN_2\033[0m"
|
||||||
content_line "3) \033[31m$MENU_MAIN_3\033[0m"
|
content_line "3) \033[31m$MENU_MAIN_3\033[0m"
|
||||||
content_line "4) \033[33m$MENU_MAIN_4\033[0m"
|
content_line "4) \033[33m$MENU_MAIN_4\033[0m"
|
||||||
content_line "5) \033[32m$MENU_MAIN_5\033[0m"
|
content_line "5) \033[32m$MENU_MAIN_5\033[0m"
|
||||||
content_line "6) \033[36m$MENU_MAIN_6\033[0m"
|
content_line "6) \033[36m$MENU_MAIN_6\033[0m"
|
||||||
content_line "7) \033[33m$MENU_MAIN_7\033[0m"
|
content_line "7) \033[33m$MENU_MAIN_7\033[0m"
|
||||||
content_line "8) $MENU_MAIN_8"
|
content_line "8) $MENU_MAIN_8"
|
||||||
content_line "9) \033[32m$MENU_MAIN_9\033[0m"
|
content_line "9) \033[32m$MENU_MAIN_9\033[0m"
|
||||||
content_line "0) $MENU_MAIN_0"
|
content_line "0) $MENU_MAIN_0"
|
||||||
separator_line "="
|
separator_line "="
|
||||||
read -r -p "$MENU_MAIN_PROMPT" num
|
read -r -p "$MENU_MAIN_PROMPT" num
|
||||||
|
|
||||||
case "$num" in
|
case "$num" in
|
||||||
"" | 0)
|
"" | 0)
|
||||||
line_break
|
line_break
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
1)
|
1)
|
||||||
start_service
|
start_service
|
||||||
line_break
|
line_break
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
checkcfg=$(cat "$CFG_PATH")
|
checkcfg=$(cat "$CFG_PATH")
|
||||||
. "$CRASHDIR"/menus/2_settings.sh && settings
|
. "$CRASHDIR"/menus/2_settings.sh && settings
|
||||||
if [ -n "$PID" ]; then
|
if [ -n "$PID" ]; then
|
||||||
checkcfg_new=$(cat "$CFG_PATH")
|
checkcfg_new=$(cat "$CFG_PATH")
|
||||||
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
|
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
[ "$bot_tg_service" = ON ] && . "$CRASHDIR"/menus/bot_tg_service.sh && bot_tg_stop
|
[ "$bot_tg_service" = ON ] && . "$CRASHDIR"/menus/bot_tg_service.sh && bot_tg_stop
|
||||||
"$CRASHDIR"/start.sh stop
|
"$CRASHDIR"/start.sh stop
|
||||||
sleep 1
|
sleep 1
|
||||||
msg_alert "\033[31m$corename$MENU_SERVICE_STOPPED\033[0m"
|
msg_alert "\033[31m$corename$MENU_SERVICE_STOPPED\033[0m"
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
. "$CRASHDIR"/menus/4_setboot.sh && setboot
|
. "$CRASHDIR"/menus/4_setboot.sh && setboot
|
||||||
;;
|
;;
|
||||||
5)
|
5)
|
||||||
. "$CRASHDIR"/menus/5_task.sh && task_menu
|
. "$CRASHDIR"/menus/5_task.sh && task_menu
|
||||||
;;
|
;;
|
||||||
6)
|
6)
|
||||||
. "$CRASHDIR"/menus/6_core_config.sh && set_core_config
|
. "$CRASHDIR"/menus/6_core_config.sh && set_core_config
|
||||||
;;
|
;;
|
||||||
7)
|
7)
|
||||||
GT_CFG_PATH="$CRASHDIR"/configs/gateway.cfg
|
GT_CFG_PATH="$CRASHDIR"/configs/gateway.cfg
|
||||||
touch "$GT_CFG_PATH"
|
touch "$GT_CFG_PATH"
|
||||||
checkcfg=$(cat "$CFG_PATH" "$GT_CFG_PATH")
|
checkcfg=$(cat "$CFG_PATH" "$GT_CFG_PATH")
|
||||||
. "$CRASHDIR"/menus/7_gateway.sh && gateway
|
. "$CRASHDIR"/menus/7_gateway.sh && gateway
|
||||||
if [ -n "$PID" ]; then
|
if [ -n "$PID" ]; then
|
||||||
checkcfg_new=$(cat "$CFG_PATH" "$GT_CFG_PATH")
|
checkcfg_new=$(cat "$CFG_PATH" "$GT_CFG_PATH")
|
||||||
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
|
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
8)
|
8)
|
||||||
. "$CRASHDIR"/menus/8_tools.sh && tools
|
. "$CRASHDIR"/menus/8_tools.sh && tools
|
||||||
;;
|
;;
|
||||||
9)
|
9)
|
||||||
checkcfg=$(cat "$CFG_PATH")
|
checkcfg=$(cat "$CFG_PATH")
|
||||||
. "$CRASHDIR"/menus/9_upgrade.sh && upgrade
|
. "$CRASHDIR"/menus/9_upgrade.sh && upgrade
|
||||||
if [ -n "$PID" ]; then
|
if [ -n "$PID" ]; then
|
||||||
checkcfg_new=$(cat "$CFG_PATH")
|
checkcfg_new=$(cat "$CFG_PATH")
|
||||||
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
|
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
errornum
|
errornum
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"")
|
"")
|
||||||
main_menu
|
main_menu
|
||||||
;;
|
;;
|
||||||
-l)
|
-l)
|
||||||
main_menu
|
main_menu
|
||||||
;;
|
;;
|
||||||
-t)
|
-t)
|
||||||
shtype=sh
|
shtype=sh
|
||||||
[ -n "$(ls -l /bin/sh | grep -o dash)" ] && shtype=bash
|
[ -n "$(ls -l /bin/sh | grep -o dash)" ] && shtype=bash
|
||||||
"$shtype" -x "$CRASHDIR"/menu.sh -l
|
"$shtype" -x "$CRASHDIR"/menu.sh -l
|
||||||
;;
|
;;
|
||||||
-s)
|
-s)
|
||||||
"$CRASHDIR"/start.sh "$2" "$3" "$4" "$5" "$6"
|
"$CRASHDIR"/start.sh "$2" "$3" "$4" "$5" "$6"
|
||||||
;;
|
;;
|
||||||
-i)
|
-i)
|
||||||
. "$CRASHDIR"/init.sh 2>/dev/null
|
. "$CRASHDIR"/init.sh 2>/dev/null
|
||||||
;;
|
;;
|
||||||
-st)
|
-st)
|
||||||
shtype=sh
|
shtype=sh
|
||||||
ckcmd bash && shtype=bash
|
ckcmd bash && shtype=bash
|
||||||
"$shtype" -x "$CRASHDIR"/starts/bfstart.sh
|
"$shtype" -x "$CRASHDIR"/starts/bfstart.sh
|
||||||
. "$CRASHDIR"/starts/start_legacy.sh
|
. "$CRASHDIR"/starts/start_legacy.sh
|
||||||
start_legacy "$COMMAND" 'shellcrash'
|
start_legacy "$COMMAND" 'shellcrash'
|
||||||
"$shtype" -x "$CRASHDIR"/starts/afstart.sh
|
"$shtype" -x "$CRASHDIR"/starts/afstart.sh
|
||||||
"$CRASHDIR"/start.sh stop
|
"$CRASHDIR"/start.sh stop
|
||||||
;;
|
;;
|
||||||
-d)
|
-d)
|
||||||
shtype=sh && [ -n "$(ls -l /bin/sh | grep -o dash)" ] && shtype=bash
|
shtype=sh && [ -n "$(ls -l /bin/sh | grep -o dash)" ] && shtype=bash
|
||||||
line_break
|
comp_box "$MENU_TEST_RUNNING_1" \
|
||||||
separator_line "="
|
"$MENU_TEST_RUNNING_2\033[36;4mhttps://t.me/ShellClash\033[0m"
|
||||||
content_line "$MENU_TEST_RUNNING_1"
|
"$shtype" "$CRASHDIR"/start.sh debug >/dev/null 2>"$TMPDIR"/debug_sh_bug.log
|
||||||
content_line "$MENU_TEST_RUNNING_2\033[36;4mhttps://t.me/ShellClash\033[0m"
|
"$shtype" -x "$CRASHDIR"/start.sh debug >/dev/null 2>"$TMPDIR"/debug_sh.log
|
||||||
separator_line "="
|
cat "$TMPDIR"/debug_sh_bug.log | grep 'start\.sh' >"$TMPDIR"/sh_bug
|
||||||
"$shtype" "$CRASHDIR"/start.sh debug >/dev/null 2>"$TMPDIR"/debug_sh_bug.log
|
if [ -s "$TMPDIR"/sh_bug ]; then
|
||||||
"$shtype" -x "$CRASHDIR"/start.sh debug >/dev/null 2>"$TMPDIR"/debug_sh.log
|
line_break
|
||||||
cat "$TMPDIR"/debug_sh_bug.log | grep 'start\.sh' >"$TMPDIR"/sh_bug
|
echo "==========================================================="
|
||||||
if [ -s "$TMPDIR"/sh_bug ]; then
|
while read line; do
|
||||||
line_break
|
echo -e "$MENU_ERROR_FOUND\033[33;4m$line\033[0m"
|
||||||
echo "==========================================================="
|
grep -A 1 -B 3 "$line" "$TMPDIR"/debug_sh.log
|
||||||
while read line; do
|
echo "==========================================================="
|
||||||
echo -e "$MENU_ERROR_FOUND\033[33;4m$line\033[0m"
|
done <"$TMPDIR"/sh_bug
|
||||||
grep -A 1 -B 3 "$line" "$TMPDIR"/debug_sh.log
|
rm -rf "$TMPDIR"/sh_bug
|
||||||
echo "==========================================================="
|
comp_box "\033[32m$MENU_TEST_DONE_FAIL\033[0m" \
|
||||||
done <"$TMPDIR"/sh_bug
|
"$MENU_TEST_LOG_HINT\033[36m$TMPDIR/debug_sh.log\033[0m"
|
||||||
rm -rf "$TMPDIR"/sh_bug
|
else
|
||||||
comp_box "\033[32m$MENU_TEST_DONE_FAIL\033[0m" \
|
rm -rf "$TMPDIR"/debug_sh.log
|
||||||
"$MENU_TEST_LOG_HINT\033[36m$TMPDIR/debug_sh.log\033[0m"
|
comp_box "\033[32m$MENU_TEST_DONE_OK\033[0m"
|
||||||
else
|
line_break
|
||||||
rm -rf "$TMPDIR"/debug_sh.log
|
fi
|
||||||
comp_box "\033[32m$MENU_TEST_DONE_OK\033[0m"
|
"$CRASHDIR"/start.sh stop
|
||||||
line_break
|
;;
|
||||||
fi
|
|
||||||
"$CRASHDIR"/start.sh stop
|
|
||||||
;;
|
|
||||||
-u)
|
-u)
|
||||||
. "$CRASHDIR"/menus/uninstall.sh && uninstall
|
. "$CRASHDIR"/menus/uninstall.sh && uninstall
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
comp_box "$MENU_WELCOME"
|
comp_box "$MENU_WELCOME"
|
||||||
content_line "-t $MENU_CLI_TEST"
|
content_line "-t $MENU_CLI_TEST"
|
||||||
content_line "-h $MENU_CLI_HELP"
|
content_line "-h $MENU_CLI_HELP"
|
||||||
content_line "-u $MENU_CLI_UNINSTALL"
|
content_line "-u $MENU_CLI_UNINSTALL"
|
||||||
content_line "-i $MENU_CLI_INIT"
|
content_line "-i $MENU_CLI_INIT"
|
||||||
content_line "-d $MENU_CLI_DEBUG"
|
content_line "-d $MENU_CLI_DEBUG"
|
||||||
separator_line "-"
|
separator_line "-"
|
||||||
content_line "crash -s start $MENU_CLI_START"
|
content_line "crash -s start $MENU_CLI_START"
|
||||||
content_line "crash -s stop $MENU_CLI_STOP"
|
content_line "crash -s stop $MENU_CLI_STOP"
|
||||||
content_line "$CRASHDIR/start.sh init $MENU_CLI_BOOT_INIT"
|
content_line "$CRASHDIR/start.sh init $MENU_CLI_BOOT_INIT"
|
||||||
separator_line "-"
|
separator_line "-"
|
||||||
content_line "$MENU_HELP_ONLINE\033[36mhttps://t.me/ShellClash\033[0m"
|
content_line "$MENU_HELP_ONLINE\033[36mhttps://t.me/ShellClash\033[0m"
|
||||||
content_line "$MENU_HELP_BLOG\033[36mhttps://juewuy.github.io\033[0m"
|
content_line "$MENU_HELP_BLOG\033[36mhttps://juewuy.github.io\033[0m"
|
||||||
content_line "$MENU_HELP_GITHUB\033[36mhttps://github.com/juewuy/ShellCrash\033[0m"
|
content_line "$MENU_HELP_GITHUB\033[36mhttps://github.com/juewuy/ShellCrash\033[0m"
|
||||||
separator_line "="
|
separator_line "="
|
||||||
line_break
|
line_break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user