Merge pull request #1083 from sofia-riese/patch-5

Continue to address the issue of function self-invocation
This commit is contained in:
juewuy
2026-01-07 11:12:01 +08:00
committed by GitHub

View File

@@ -715,145 +715,158 @@ done
} }
#Dashboard #Dashboard
getdb(){ getdb() {
dblink="${update_url}/" dblink="${update_url}/"
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo 正在连接服务器获取安装文件………… echo "正在连接服务器获取安装文件…………"
get_bin "$TMPDIR"/clashdb.tar.gz bin/dashboard/${db_type}.tar.gz get_bin "$TMPDIR"/clashdb.tar.gz bin/dashboard/${db_type}.tar.gz
if [ "$?" = "1" ];then if [ "$?" = "1" ]; then
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[31m文件下载失败\033[0m" echo -e "\033[31m文件下载失败\033[0m"
echo "-----------------------------------------------" echo "-----------------------------------------------"
error_down error_down
setdb return 1
else else
echo -e "\033[33m下载成功正在解压文件\033[0m" echo -e "\033[33m下载成功正在解压文件\033[0m"
mkdir -p $dbdir > /dev/null mkdir -p $dbdir >/dev/null
tar -zxf "$TMPDIR/clashdb.tar.gz" ${tar_para} -C $dbdir > /dev/null tar -zxf "$TMPDIR/clashdb.tar.gz" ${tar_para} -C $dbdir >/dev/null
[ $? -ne 0 ] && echo "文件解压失败!" && rm -rf "$TMPDIR"/clashfm.tar.gz && exit 1 [ $? -ne 0 ] && echo "文件解压失败!" && rm -rf "$TMPDIR"/clashfm.tar.gz && exit 1
#修改默认host和端口 #修改默认host和端口
if [ "$db_type" = "clashdb" -o "$db_type" = "meta_db" -o "$db_type" = "zashboard" ];then if [ "$db_type" = "clashdb" -o "$db_type" = "meta_db" -o "$db_type" = "zashboard" ]; then
sed -i "s/127.0.0.1/${host}/g" $dbdir/assets/*.js sed -i "s/127.0.0.1/${host}/g" $dbdir/assets/*.js
sed -i "s/9090/${db_port}/g" $dbdir/assets/*.js sed -i "s/9090/${db_port}/g" $dbdir/assets/*.js
elif [ "$db_type" = "meta_xd" ];then elif [ "$db_type" = "meta_xd" ]; then
sed -i "s/127.0.0.1:9090/${host}:${db_port}/g" $dbdir/_nuxt/*.js sed -i "s/127.0.0.1:9090/${host}:${db_port}/g" $dbdir/_nuxt/*.js
else else
sed -i "s/127.0.0.1:9090/${host}:${db_port}/g" $dbdir/*.html sed -i "s/127.0.0.1:9090/${host}:${db_port}/g" $dbdir/*.html
fi fi
#写入配置文件 #写入配置文件
setconfig hostdir "'$hostdir'" setconfig hostdir "'$hostdir'"
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[32m面板安装成功\033[36m如未生效请使用【Ctrl+F5】强制刷新浏览器\033[0m" echo -e "\033[32m面板安装成功\033[36m如未生效请使用【Ctrl+F5】强制刷新浏览器\033[0m"
rm -rf "$TMPDIR"/clashdb.tar.gz rm -rf "$TMPDIR"/clashdb.tar.gz
fi fi
sleep 1 sleep 1
} }
setdb(){
dbdir(){
if [ -f /www/clash/CNAME -o -f "$CRASHDIR"/ui/CNAME ];then
echo "-----------------------------------------------"
echo -e "\033[31m检测到您已经安装过本地面板了\033[0m"
echo "-----------------------------------------------"
read -p "是否升级/覆盖安装?[1/0] > " res
if [ "$res" = 1 ]; then
rm -rf "$BINDIR"/ui
[ -f /www/clash/CNAME ] && rm -rf /www/clash && dbdir=/www/clash
[ -f "$CRASHDIR"/ui/CNAME ] && rm -rf "$CRASHDIR"/ui && dbdir="$CRASHDIR"/ui
getdb
else
setdb
echo -e "\033[33m安装已取消\033[0m"
fi
elif [ -w /www -a -n "$(pidof nginx)" ];then
echo "-----------------------------------------------"
echo -e "请选择面板\033[33m安装目录\033[0m"
echo "-----------------------------------------------"
echo -e " 1 在${CRASHDIR}/ui目录安装"
echo -e " 2 在/www/clash目录安装"
echo "-----------------------------------------------"
echo " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ "$num" = '1' ]; then dbdir() {
dbdir="$CRASHDIR"/ui if [ -f /www/clash/CNAME -o -f "$CRASHDIR"/ui/CNAME ]; then
hostdir=":$db_port/ui" echo "-----------------------------------------------"
getdb echo -e "\033[31m检测到您已经安装过本地面板了\033[0m"
elif [ "$num" = '2' ]; then echo "-----------------------------------------------"
dbdir=/www/clash read -p "是否升级/覆盖安装?[1/0] > " res
hostdir='/clash' if [ "$res" = 1 ]; then
getdb rm -rf "$BINDIR"/ui
else [ -f /www/clash/CNAME ] && rm -rf /www/clash && dbdir=/www/clash
setdb [ -f "$CRASHDIR"/ui/CNAME ] && rm -rf "$CRASHDIR"/ui && dbdir="$CRASHDIR"/ui
echo -e "\033[33m安装已取消\033[0m" getdb
fi else
else echo -e "\033[33m安装已取消\033[0m"
dbdir="$CRASHDIR"/ui return 1
hostdir=":$db_port/ui" fi
getdb elif [ -w /www -a -n "$(pidof nginx)" ]; then
fi echo "-----------------------------------------------"
} echo -e "请选择面板\033[33m安装目录\033[0m"
echo "-----------------------------------------------"
echo -e " 1 在${CRASHDIR}/ui目录安装"
echo -e " 2 在/www/clash目录安装"
echo "-----------------------------------------------"
echo " 0 返回上级菜单"
read -p "请输入对应数字 > " num
case "$num" in
"" | 0)
return 0
;;
1)
dbdir="$CRASHDIR"/ui
hostdir=": $db_port/ui"
getdb
;;
2)
dbdir=/www/clash
hostdir='/clash'
getdb
;;
*)
errornum
sleep 1
return 1
;;
esac
else
dbdir="$CRASHDIR"/ui
hostdir=":$db_port/ui"
getdb
fi
}
echo "-----------------------------------------------" setdb() {
echo -e "\033[36m安装本地版dashboard管理面板\033[0m" while true; do
echo -e "\033[32m打开管理面板的速度更快且更稳定\033[0m" echo "-----------------------------------------------"
echo "-----------------------------------------------" echo -e "\033[36m安装本地版dashboard管理面板\033[0m"
echo -e "请选择面板\033[33m安装类型\033[0m" echo -e "\033[32m打开管理面板的速度更快且更稳定\033[0m"
echo "-----------------维护中------------------------" echo "-----------------------------------------------"
echo -e " 1 安装\033[32mzashboard面板\033[0m(约2.2mb)" echo -e "请选择面板\033[33m安装类型\033[0m"
echo -e " 2 安装\033[32mMetaXD面板\033[0m(约1.5mb)" echo "-----------------维护中------------------------"
echo -e " 3 安装\033[32mYacd-Meta魔改面板\033[0m(约1.7mb)" echo -e " 1 安装\033[32mzashboard面板\033[0m(约2.2mb)"
echo "---------------已停止维护----------------------" echo -e " 2 安装\033[32mMetaXD面板\033[0m(约1.5mb)"
echo -e " 4 安装\033[32m基础面板\033[0m(约500kb)" echo -e " 3 安装\033[32mYacd-Meta魔改面板\033[0m(约1.7mb)"
echo -e " 5 安装\033[32mMeta基础面板\033[0m(约800kb)" echo "---------------已停止维护----------------------"
echo -e " 6 安装\033[32mYacd面板\033[0m(约1.1mb)" echo -e " 4 安装\033[32m基础面板\033[0m(约500kb)"
echo "-----------------------------------------------" echo -e " 5 安装\033[32mMeta基础面板\033[0m(约800kb)"
echo -e " 9 卸载\033[33m本地面板\033[0m" echo -e " 6 安装\033[32mYacd面板\033[0m(约1.1mb)"
echo " 0 返回上级菜单" echo "-----------------------------------------------"
read -p "请输入对应数字 > " num echo -e " 9 卸载\033[33m本地面板\033[0m"
echo " 0 返回上级菜单"
case "$num" in read -p "请输入对应数字 > " num
0) ;; case "$num" in
1) "" | 0)
db_type=zashboard break
setconfig external_ui_url "https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip" ;;
dbdir 1)
;; db_type=zashboard
2) setconfig external_ui_url "https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip"
db_type=meta_xd dbdir
setconfig external_ui_url "https://raw.githubusercontent.com/juewuy/ShellCrash/update/bin/dashboard/meta_xd.tar.gz" ;;
dbdir 2)
;; db_type=meta_xd
3) setconfig external_ui_url "https://raw.githubusercontent.com/juewuy/ShellCrash/update/bin/dashboard/meta_xd.tar.gz"
db_type=meta_yacd dbdir
dbdir ;;
;; 3)
4) db_type=meta_yacd
db_type=clashdb dbdir
dbdir ;;
;; 4)
5) db_type=clashdb
db_type=meta_db dbdir
dbdir ;;
;; 5)
6) db_type=meta_db
db_type=yacd dbdir
dbdir ;;
;; 6)
9) db_type=yacd
read -p "确认卸载本地面板?(1/0) > " res dbdir
if [ "$res" = 1 ];then ;;
rm -rf /www/clash 9)
rm -rf "$CRASHDIR"/ui read -p "确认卸载本地面板?(1/0) > " res
rm -rf "$BINDIR"/ui if [ "$res" = 1 ]; then
echo "-----------------------------------------------" rm -rf /www/clash
echo -e "\033[31m面板已经卸载\033[0m" rm -rf "$CRASHDIR"/ui
sleep 1 rm -rf "$BINDIR"/ui
fi echo "-----------------------------------------------"
;; echo -e "\033[31m面板已经卸载\033[0m"
*) sleep 1
errornum fi
;; ;;
esac *)
errornum
sleep 1
break
;;
esac
done
} }
#根证书 #根证书