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 #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
@@ -748,9 +748,9 @@ getdb(){
fi fi
sleep 1 sleep 1
} }
setdb(){
dbdir(){ dbdir() {
if [ -f /www/clash/CNAME -o -f "$CRASHDIR"/ui/CNAME ];then if [ -f /www/clash/CNAME -o -f "$CRASHDIR"/ui/CNAME ]; then
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[31m检测到您已经安装过本地面板了\033[0m" echo -e "\033[31m检测到您已经安装过本地面板了\033[0m"
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -761,10 +761,10 @@ setdb(){
[ -f "$CRASHDIR"/ui/CNAME ] && rm -rf "$CRASHDIR"/ui && dbdir="$CRASHDIR"/ui [ -f "$CRASHDIR"/ui/CNAME ] && rm -rf "$CRASHDIR"/ui && dbdir="$CRASHDIR"/ui
getdb getdb
else else
setdb
echo -e "\033[33m安装已取消\033[0m" echo -e "\033[33m安装已取消\033[0m"
return 1
fi fi
elif [ -w /www -a -n "$(pidof nginx)" ];then elif [ -w /www -a -n "$(pidof nginx)" ]; then
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "请选择面板\033[33m安装目录\033[0m" echo -e "请选择面板\033[33m安装目录\033[0m"
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -773,26 +773,35 @@ setdb(){
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo " 0 返回上级菜单" echo " 0 返回上级菜单"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in
if [ "$num" = '1' ]; then "" | 0)
return 0
;;
1)
dbdir="$CRASHDIR"/ui dbdir="$CRASHDIR"/ui
hostdir=":$db_port/ui" hostdir=": $db_port/ui"
getdb getdb
elif [ "$num" = '2' ]; then ;;
2)
dbdir=/www/clash dbdir=/www/clash
hostdir='/clash' hostdir='/clash'
getdb getdb
else ;;
setdb *)
echo -e "\033[33m安装已取消\033[0m" errornum
fi sleep 1
return 1
;;
esac
else else
dbdir="$CRASHDIR"/ui dbdir="$CRASHDIR"/ui
hostdir=":$db_port/ui" hostdir=":$db_port/ui"
getdb getdb
fi fi
} }
setdb() {
while true; do
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[36m安装本地版dashboard管理面板\033[0m" echo -e "\033[36m安装本地版dashboard管理面板\033[0m"
echo -e "\033[32m打开管理面板的速度更快且更稳定\033[0m" echo -e "\033[32m打开管理面板的速度更快且更稳定\033[0m"
@@ -810,9 +819,10 @@ setdb(){
echo -e " 9 卸载\033[33m本地面板\033[0m" echo -e " 9 卸载\033[33m本地面板\033[0m"
echo " 0 返回上级菜单" echo " 0 返回上级菜单"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in case "$num" in
0) ;; "" | 0)
break
;;
1) 1)
db_type=zashboard db_type=zashboard
setconfig external_ui_url "https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip" setconfig external_ui_url "https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip"
@@ -841,7 +851,7 @@ setdb(){
;; ;;
9) 9)
read -p "确认卸载本地面板?(1/0) > " res read -p "确认卸载本地面板?(1/0) > " res
if [ "$res" = 1 ];then if [ "$res" = 1 ]; then
rm -rf /www/clash rm -rf /www/clash
rm -rf "$CRASHDIR"/ui rm -rf "$CRASHDIR"/ui
rm -rf "$BINDIR"/ui rm -rf "$BINDIR"/ui
@@ -852,8 +862,11 @@ setdb(){
;; ;;
*) *)
errornum errornum
sleep 1
break
;; ;;
esac esac
done
} }
#根证书 #根证书