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,27 +715,27 @@ done
}
#Dashboard
getdb(){
getdb() {
dblink="${update_url}/"
echo "-----------------------------------------------"
echo 正在连接服务器获取安装文件…………
echo "正在连接服务器获取安装文件…………"
get_bin "$TMPDIR"/clashdb.tar.gz bin/dashboard/${db_type}.tar.gz
if [ "$?" = "1" ];then
if [ "$?" = "1" ]; then
echo "-----------------------------------------------"
echo -e "\033[31m文件下载失败\033[0m"
echo "-----------------------------------------------"
error_down
setdb
return 1
else
echo -e "\033[33m下载成功正在解压文件\033[0m"
mkdir -p $dbdir > /dev/null
tar -zxf "$TMPDIR/clashdb.tar.gz" ${tar_para} -C $dbdir > /dev/null
mkdir -p $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
#修改默认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/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
else
sed -i "s/127.0.0.1:9090/${host}:${db_port}/g" $dbdir/*.html
@@ -748,9 +748,9 @@ getdb(){
fi
sleep 1
}
setdb(){
dbdir(){
if [ -f /www/clash/CNAME -o -f "$CRASHDIR"/ui/CNAME ];then
dbdir() {
if [ -f /www/clash/CNAME -o -f "$CRASHDIR"/ui/CNAME ]; then
echo "-----------------------------------------------"
echo -e "\033[31m检测到您已经安装过本地面板了\033[0m"
echo "-----------------------------------------------"
@@ -761,10 +761,10 @@ setdb(){
[ -f "$CRASHDIR"/ui/CNAME ] && rm -rf "$CRASHDIR"/ui && dbdir="$CRASHDIR"/ui
getdb
else
setdb
echo -e "\033[33m安装已取消\033[0m"
return 1
fi
elif [ -w /www -a -n "$(pidof nginx)" ];then
elif [ -w /www -a -n "$(pidof nginx)" ]; then
echo "-----------------------------------------------"
echo -e "请选择面板\033[33m安装目录\033[0m"
echo "-----------------------------------------------"
@@ -773,26 +773,35 @@ setdb(){
echo "-----------------------------------------------"
echo " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ "$num" = '1' ]; then
case "$num" in
"" | 0)
return 0
;;
1)
dbdir="$CRASHDIR"/ui
hostdir=":$db_port/ui"
hostdir=": $db_port/ui"
getdb
elif [ "$num" = '2' ]; then
;;
2)
dbdir=/www/clash
hostdir='/clash'
getdb
else
setdb
echo -e "\033[33m安装已取消\033[0m"
fi
;;
*)
errornum
sleep 1
return 1
;;
esac
else
dbdir="$CRASHDIR"/ui
hostdir=":$db_port/ui"
getdb
fi
}
}
setdb() {
while true; do
echo "-----------------------------------------------"
echo -e "\033[36m安装本地版dashboard管理面板\033[0m"
echo -e "\033[32m打开管理面板的速度更快且更稳定\033[0m"
@@ -810,9 +819,10 @@ setdb(){
echo -e " 9 卸载\033[33m本地面板\033[0m"
echo " 0 返回上级菜单"
read -p "请输入对应数字 > " num
case "$num" in
0) ;;
"" | 0)
break
;;
1)
db_type=zashboard
setconfig external_ui_url "https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip"
@@ -841,7 +851,7 @@ setdb(){
;;
9)
read -p "确认卸载本地面板?(1/0) > " res
if [ "$res" = 1 ];then
if [ "$res" = 1 ]; then
rm -rf /www/clash
rm -rf "$CRASHDIR"/ui
rm -rf "$BINDIR"/ui
@@ -852,8 +862,11 @@ setdb(){
;;
*)
errornum
sleep 1
break
;;
esac
done
}
#根证书