This commit is contained in:
juewuy
2026-01-31 18:04:17 +08:00
3 changed files with 34 additions and 88 deletions

View File

@@ -32,13 +32,9 @@ load_lang common
load_lang menu load_lang menu
checkrestart() { checkrestart() {
line_break comp_box "\033[32m$MENU_RESTART_NOTICE\033[0m"
separator_line "=" btm_box "1) 立即重启" \
content_line "\033[32m$MENU_RESTART_NOTICE\033[0m" "0) 暂不重启"
separator_line "="
content_line "1) 立即重启"
content_line "0) 暂不重启"
separator_line "="
read -r -p "$COMMON_INPUT> " res read -r -p "$COMMON_INPUT> " res
if [ "$res" = 1 ]; then if [ "$res" = 1 ]; then
start_service start_service
@@ -59,12 +55,10 @@ checkport() {
conflict_line=$(echo "$current_listening" | grep ":$portx ") conflict_line=$(echo "$current_listening" | grep ":$portx ")
if [ -n "$conflict_line" ]; then if [ -n "$conflict_line" ]; then
line_break
separator_line "=" comp_box "$portx】:$MENU_PORT_CONFLICT_TITLE" \
content_line "$portx】:$MENU_PORT_CONFLICT_TITLE" "\033[0m$(echo "$conflict_line" | head -n 1)\033[0m" \
content_line "\033[0m$(echo "$conflict_line" | head -n 1)\033[0m" "\033[36m$MENU_PORT_CONFLICT_HINT\033[0m"
content_line "\033[36m$MENU_PORT_CONFLICT_HINT\033[0m"
separator_line "="
. "$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
@@ -86,7 +80,6 @@ checkport() {
# 脚本启动前检查 # 脚本启动前检查
ckstatus() { ckstatus() {
versionsh=$(cat "$CRASHDIR"/version) versionsh=$(cat "$CRASHDIR"/version)
[ -n "$versionsh" ] && versionsh_l=$versionsh [ -n "$versionsh" ] && versionsh_l=$versionsh
[ -z "$redir_mod" ] && redir_mod="$MENU_PURE_MOD" [ -z "$redir_mod" ] && redir_mod="$MENU_PURE_MOD"
@@ -140,7 +133,7 @@ ckstatus() {
line_break line_break
separator_line "=" separator_line "="
content_line "\033[30;43m$MENU_WELCOME\033[0m" content_line "\033[30;43m$MENU_WELCOME\033[0m"
content_right "Ver: $versionsh_l" content_line "Ver: $versionsh_l"
content_line "$MENU_TG_CHANNEL\033[36;4mhttps://t.me/ShellClash\033[0m" content_line "$MENU_TG_CHANNEL\033[36;4mhttps://t.me/ShellClash\033[0m"
separator_line "-" separator_line "-"
content_line "$corename$run\t $auto" content_line "$corename$run\t $auto"
@@ -151,46 +144,33 @@ ckstatus() {
# 检查/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 -Ev ".*(zip|7z|tar)$" | grep -iE 'CrashCore|^clash$|^clash-linux.*|^mihomo.*|^sing.*box'); do
line_break comp_box "$MENU_TMP_CORE_FOUND \033[36m/tmp/$file\033[0m" \
separator_line "=" "$MENU_TMP_CORE_ASK"
content_line "$MENU_TMP_CORE_FOUND \033[36m/tmp/$file\033[0m" btm_box "1) 立即加载" \
content_line "$MENU_TMP_CORE_ASK" "0) 暂不加载"
separator_line "="
content_line "1) 立即加载"
content_line "0) 暂不加载"
separator_line "="
read -r -p "$COMMON_INPUT> " res read -r -p "$COMMON_INPUT> " res
[ "$res" = 1 ] && { [ "$res" = 1 ] && {
line_break
separator_line "="
zip_type=$(echo "$file" | grep -oE 'tar.gz$|upx$|gz$') zip_type=$(echo "$file" | grep -oE 'tar.gz$|upx$|gz$')
. "$CRASHDIR"/menus/9_upgrade.sh && setcoretype . "$CRASHDIR"/menus/9_upgrade.sh && setcoretype
. "$CRASHDIR"/libs/core_tools.sh && core_check "/tmp/$file" . "$CRASHDIR"/libs/core_tools.sh && core_check "/tmp/$file"
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
content_line "\033[32m$MENU_CORE_LOADED_OK\033[0m" msg_alert "\033[32m$MENU_CORE_LOADED_OK\033[0m"
separator_line "="
switch_core switch_core
else else
content_line "\033[33m$MENU_CORE_LOADED_BAD\033[0m"
rm -rf /tmp/"$file" rm -rf /tmp/"$file"
content_line "\033[33m$MENU_CORE_REMOVED\033[0m" msg_alert "\033[33m$MENU_CORE_LOADED_BAD\033[0m" \
"\033[33m$MENU_CORE_REMOVED\033[0m"
fi fi
separator_line "="
sleep 1
} }
done done
# 检查/tmp配置文件 # 检查/tmp配置文件
for file in $(ls /tmp | grep -v [/$] | grep -v ' ' | grep -iE 'config.yaml$|config.yml$|config.json$'); do for file in $(ls /tmp | grep -v [/$] | grep -v ' ' | grep -iE 'config.yaml$|config.yml$|config.json$'); do
tmp_file=/tmp/$file tmp_file=/tmp/$file
line_break comp_box "$MENU_TMP_CFG_FOUND \033[36m/tmp/$file\033[0m" \
separator_line "=" "$MENU_TMP_CFG_ASK"
content_line "$MENU_TMP_CFG_FOUND \033[36m/tmp/$file\033[0m" btm_box "1) 立即加载" \
content_line "$MENU_TMP_CFG_ASK" "0) 暂不加载"
separator_line "="
content_line "1) 立即加载"
content_line "0) 暂不加载"
separator_line "="
read -p "$COMMON_INPUT> " res read -p "$COMMON_INPUT> " res
[ "$res" = 1 ] && { [ "$res" = 1 ] && {
if [ -n "$(echo /tmp/$file | grep -iE '.json$')" ]; then if [ -n "$(echo /tmp/$file | grep -iE '.json$')" ]; then
@@ -198,24 +178,16 @@ ckstatus() {
else else
mv -f /tmp/$file "$CRASHDIR"/yamls/config.yaml mv -f /tmp/$file "$CRASHDIR"/yamls/config.yaml
fi fi
line_break msg_alert "\033[32m$MENU_CFG_LOADED_OK\033[0m "
separator_line "="
content_line "\033[32m$MENU_CFG_LOADED_OK\033[0m "
separator_line "="
sleep 1
} }
done done
# 检查禁用配置覆写 # 检查禁用配置覆写
[ "$disoverride" = "1" ] && { [ "$disoverride" = "1" ] && {
line_break comp_box "\033[33m$MENU_OVERRIDE_WARN\033[0m" \
separator_line "=" "$MENU_OVERRIDE_ASK"
content_line "\033[33m$MENU_OVERRIDE_WARN\033[0m" btm_box "1) 是" \
content_line "$MENU_OVERRIDE_ASK" "0) 否"
separator_line "="
content_line "1) 是"
content_line "0) 否"
separator_line "="
read -p "$COMMON_INPUT> " res read -p "$COMMON_INPUT> " res
[ "$res" = 1 ] && unset disoverride && setconfig disoverride [ "$res" = 1 ] && unset disoverride && setconfig disoverride
} }
@@ -245,8 +217,8 @@ main_menu() {
;; ;;
1) 1)
start_service start_service
exit
line_break line_break
exit
;; ;;
2) 2)
checkcfg=$(cat "$CFG_PATH") checkcfg=$(cat "$CFG_PATH")
@@ -260,11 +232,7 @@ main_menu() {
[ "$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
line_break msg_alert "\033[31m$corename$MENU_SERVICE_STOPPED\033[0m"
separator_line "="
content_line "\033[31m$corename$MENU_SERVICE_STOPPED\033[0m"
separator_line "="
sleep 1
;; ;;
4) 4)
. "$CRASHDIR"/menus/4_setboot.sh && setboot . "$CRASHDIR"/menus/4_setboot.sh && setboot
@@ -298,7 +266,6 @@ main_menu() {
;; ;;
*) *)
errornum errornum
sleep 1
;; ;;
esac esac
done done
@@ -333,16 +300,13 @@ case "$1" in
;; ;;
-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"
content_line "$MENU_TEST_RUNNING_2\033[36;4mhttps://t.me/ShellClash\033[0m"
separator_line "="
"$shtype" "$CRASHDIR"/start.sh debug >/dev/null 2>"$TMPDIR"/debug_sh_bug.log "$shtype" "$CRASHDIR"/start.sh debug >/dev/null 2>"$TMPDIR"/debug_sh_bug.log
"$shtype" -x "$CRASHDIR"/start.sh debug >/dev/null 2>"$TMPDIR"/debug_sh.log "$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 cat "$TMPDIR"/debug_sh_bug.log | grep 'start\.sh' >"$TMPDIR"/sh_bug
if [ -s "$TMPDIR"/sh_bug ]; then if [ -s "$TMPDIR"/sh_bug ]; then
line_break
echo "===========================================================" echo "==========================================================="
while read line; do while read line; do
echo -e "$MENU_ERROR_FOUND\033[33;4m$line\033[0m" echo -e "$MENU_ERROR_FOUND\033[33;4m$line\033[0m"
@@ -350,16 +314,11 @@ case "$1" in
echo "===========================================================" echo "==========================================================="
done <"$TMPDIR"/sh_bug done <"$TMPDIR"/sh_bug
rm -rf "$TMPDIR"/sh_bug rm -rf "$TMPDIR"/sh_bug
line_break comp_box "\033[32m$MENU_TEST_DONE_FAIL\033[0m" \
separator_line "=" "$MENU_TEST_LOG_HINT\033[36m$TMPDIR/debug_sh.log\033[0m"
content_line "\033[32m$MENU_TEST_DONE_FAIL\033[0m"
content_line "$MENU_TEST_LOG_HINT\033[36m$TMPDIR/debug_sh.log\033[0m"
separator_line "="
else else
rm -rf "$TMPDIR"/debug_sh.log rm -rf "$TMPDIR"/debug_sh.log
separator_line "=" comp_box "\033[32m$MENU_TEST_DONE_OK\033[0m"
content_line "\033[32m$MENU_TEST_DONE_OK\033[0m"
separator_line "="
line_break line_break
fi fi
"$CRASHDIR"/start.sh stop "$CRASHDIR"/start.sh stop
@@ -368,10 +327,7 @@ case "$1" in
. "$CRASHDIR"/menus/uninstall.sh && uninstall . "$CRASHDIR"/menus/uninstall.sh && uninstall
;; ;;
*) *)
line_break comp_box "$MENU_WELCOME"
separator_line "="
content_line "$MENU_WELCOME"
separator_line "="
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"

View File

@@ -113,11 +113,7 @@ content_line() {
END {} END {}
' '
} }
# function for right side text
# color sould be disabled
content_right() {
content_line "$(printf "%$((${TABLE_WIDTH:-60} - 3))s" "$1")"
}
# function to print sub content lines # function to print sub content lines
# for printing accompanying instructions # for printing accompanying instructions
sub_content_line() { sub_content_line() {
@@ -150,5 +146,3 @@ separator_line() {
line_break() { line_break() {
printf "\n\n" printf "\n\n"
} }

View File

@@ -5,9 +5,6 @@ content_line() {
printf '%b' " $1\n" printf '%b' " $1\n"
} }
content_right() {
printf "%$((TABLE_WIDTH - 13))s\n" "$1"
}
sub_content_line() { sub_content_line() {
content_line " $1" content_line " $1"
} }
@@ -19,4 +16,3 @@ separator_line() {
line_break() { line_break() {
return return
} }