From 9be192b29d4a3a93e54712ee74664c0e876a81e3 Mon Sep 17 00:00:00 2001 From: juewuy Date: Sun, 14 Dec 2025 10:45:14 +0800 Subject: [PATCH] =?UTF-8?q?~=E5=A2=9E=E5=8A=A0=E8=AE=BE=E7=BD=AE=E5=88=AB?= =?UTF-8?q?=E5=90=8D=E6=97=B6=E4=B8=8E=E7=B3=BB=E7=BB=9F=E5=86=85=E7=BD=AE?= =?UTF-8?q?=E5=91=BD=E4=BB=A4/=E5=88=AB=E5=90=8D=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E7=9A=84=E5=8A=9F=E8=83=BD=20~=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E8=87=AA=E5=AE=9A=E4=B9=89=E5=88=AB=E5=90=8D=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E7=9A=84bug=20~=E4=BF=AE=E5=A4=8D=E8=BF=98=E5=8E=9F?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E8=8A=82=E7=82=B9=E6=97=B6=E5=9B=A0=E4=B8=BA?= =?UTF-8?q?=E9=83=A8=E5=88=86=E8=8A=82=E7=82=B9=E5=90=8D=E5=8C=85=E5=90=AB?= =?UTF-8?q?=E5=86=92=E5=8F=B7=E8=80=8C=E8=BF=98=E5=8E=9F=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 21 +++++++++++++-------- scripts/init.sh | 1 + scripts/start.sh | 6 +++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/install.sh b/install.sh index 35650bd..e70be35 100644 --- a/install.sh +++ b/install.sh @@ -13,9 +13,8 @@ echo "***********************************************" dir_avail() { df $2 $1 | awk '{ for(i=1;i<=NF;i++){ if(NR==1){ arr[i]=$i; }else{ arr[i]=arr[i]" "$i; } } } END{ for(i=1;i<=NF;i++){ print arr[i]; } }' | grep -E 'Ava|可用' | awk '{print $2}' } -setconfig() { - configpath=$CRASHDIR/configs/ShellCrash.cfg - [ -n "$(grep ${1} $configpath)" ] && sed -i "s#${1}=.*#${1}=${2}#g" $configpath || echo "${1}=${2}" >>$configpath +ckcmd() { #检查命令 + command -v sh >/dev/null 2>&1 && command -v "$1" || type "$1" } webget() { #参数【$1】代表下载目录,【$2】代表在线地址 @@ -44,11 +43,12 @@ error_down() { } #安装及初始化 set_alias(){ - $echo "\033[32m请选择一个别名\033[0m" echo ----------------------------------------------- - $echo " 1 【\033[32m crash \033[0m】" - $echo " 2 【\033[32m sc \033[0m】" - $echo " 3 【\033[32m mm \033[0m】" + $echo "\033[36m请选择一个别名,或使用自定义别名:\033[0m" + echo ----------------------------------------------- + $echo " 1 【\033[32mcrash\033[0m】" + $echo " 2 【\033[32m sc \033[0m】" + $echo " 3 【\033[32m mm \033[0m】" $echo " 0 退出安装" echo ----------------------------------------------- read -p "请输入相应数字或自定义别名 > " res @@ -58,7 +58,12 @@ set_alias(){ 3) my_alias=mm ;; *) my_alias=$res ;; esac - setconfig my_alias $my_alias + cmd=$(ckcmd "$my_alias" | grep 'menu.sh') + ckcmd "$my_alias" >/dev/null 2>&1 && [ -z "$cmd" ] && { + $echo "\033[33m此别名和当前系统内置命令/别名冲突,请换一个!\033[0m" + sleep 1 + set_alias + } } gettar() { webget /tmp/ShellCrash.tar.gz "$url/ShellCrash.tar.gz" diff --git a/scripts/init.sh b/scripts/init.sh index 4bcb962..2f392a6 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -261,6 +261,7 @@ if [ -n "$profile" ]; then set_profile "$profile" #适配zsh环境变量 zsh --version >/dev/null 2>&1 && [ -z "$(cat ~/.zshrc 2>/dev/null | grep CRASHDIR)" ] && set_profile '~/.zshrc' 2>/dev/null + setconfig my_alias "$my_alias" else echo -e "\033[33m无法写入环境变量!请检查安装权限!\033[0m" exit 1 diff --git a/scripts/start.sh b/scripts/start.sh index e6bd3ab..44eae3a 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -1674,10 +1674,10 @@ web_save() { #最小化保存面板节点选择 #使用get_save获取面板节点设置 get_save http://127.0.0.1:${db_port}/proxies | sed 's/:{/!/g' | awk -F '!' '{for(i=1;i<=NF;i++) print $i}' | grep -aE '"Selector"' | grep -aoE '"name":.*"now":".*",' >"$TMPDIR"/web_proxies [ -s "$TMPDIR"/web_proxies ] && while read line; do - def=$(echo $line | grep -oE '"all".*",' | awk -F "[:\"]" '{print $5}') - now=$(echo $line | grep -oE '"now".*",' | awk -F "[:\"]" '{print $5}') + def=$(echo $line | grep -oE '"all".*",' | awk -F "[\"]" '{print $4}') + now=$(echo $line | grep -oE '"now".*",' | awk -F "[\"]" '{print $4}') [ "$def" != "$now" ] && { - name=$(echo $line | grep -oE '"name".*",' | awk -F "[:\"]" '{print $5}') + name=$(echo $line | grep -oE '"name".*",' | awk -F "[\"]" '{print $4}') echo "${name},${now}" >>"$TMPDIR"/web_save } done <"$TMPDIR"/web_proxies