Skip to content

Commit

Permalink
1.解决cf节点访问webssh报Websocket authentication failed的问题
Browse files Browse the repository at this point in the history
2.alist模块修改,融合新的建站模式(如果需要用新版,之前安装过alist的,需要用旧版先卸载再更新代码安装)
3.sun-panel和webssh都补充上“卸载”选项。
frankiejun committed Nov 21, 2024
1 parent 0fc5a51 commit 7876c68
Showing 2 changed files with 108 additions and 80 deletions.
2 changes: 1 addition & 1 deletion keepalive.sh
Original file line number Diff line number Diff line change
@@ -175,7 +175,7 @@ startSunPanel(){
startWebSSH(){
cd ${installpath}/serv00-play/webssh
ssh_port=$(jq -r ".port" config.json)
cmd="nohup ./wssh --port=$ssh_port --fbidhttp=False >/dev/null 2>&1 &"
cmd="nohup ./wssh --port=$ssh_port --fbidhttp=False --xheaders=False --encoding='utf-8' --delay=10 >/dev/null 2>&1 &"
eval "$cmd"
}

186 changes: 107 additions & 79 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1295,60 +1295,52 @@ update_http_port() {
}

installAlist(){
if ! checkInstalled "serv00-play"; then
return 1
fi
cd ${installpath}/serv00-play/ || return 1
user="$(whoami)"
if isServ00 ; then
domain="alist.$user.serv00.net"
else
domain="alist.$user.ct8.pl"
fi
host="$(hostname | cut -d '.' -f 1)"
sno=${host/s/web}
webpath="${installpath}/domains/$domain/public_html/"

if [[ -d "$webpath/data" && -e "$webpath/alist" ]]; then
alistpath="${installpath}/serv00-play/alist"

if [[ ! -e "$alistpath" ]]; then
mkdir -p $alistpath
fi
if [[ -d "$alistpath/data" && -e "$alistpath/alist" ]]; then
echo "已安装,请勿重复安装。"
return
else
if [ ! -e "alist" ]; then
mkdir -p alist
fi
else
cd "alist" || return 1
if [ ! -e "alist" ]; then
# read -p "请输入使用密码:" password
if ! checkDownload "alist"; then
return 1
fi
fi
fi
fi

loadPort
randomPort tcp alist
if [[ -n "$port" ]]; then
alist_port="$port"
fi
echo "正在安装alist,请等待..."
resp=$(devil www add $domain proxy localhost $alist_port)
echo "resp:$resp"
if [[ ! "$resp" =~ .*succesfully.*$ && ! "$resp" =~ .*Ok.*$ ]]; then
if [[ ! "$resp" =~ "This domain already exists" ]]; then
red "申请域名$domain 失败!"
return 1
fi
domain=""
webIp=""
if ! makeWWW alist $alist_port ; then
echo "绑定域名失败!"
return 1
fi
webIp=$(devil vhost list public | grep "$sno" | awk '{print $1}')
resp=$(devil ssl www add $webIp le le $domain)

if [[ ! "$resp" =~ .*succesfully.*$ && ! "$resp" =~ .*Ok.*$ ]]; then
red "申请ssl证书失败!$resp"
read -p "是否可以不要证书使用,后面自己再申请证书? [y/n] [y]:" input
input=${input:-y}
if [[ "$input" != "y" ]]; then
resp=$(devil www del $domain --remove)
return 1
fi
fi
cp ./alist ${installpath}/domains/$domain/public_html/ || return 1
cd ${installpath}/domains/$domain/public_html/ || return 1
if ! applyLE $domain $webIp; then
echo "申请证书失败!"
return 1
fi
cd $alistpath
rt=$(chmod +x ./alist && ./alist admin random 2>&1 )
extract_user_and_password "$rt"
update_http_port "$alist_port"
@@ -1357,32 +1349,22 @@ installAlist(){

}

checkAlistAlive(){
if ps aux | grep alist | grep -v "grep" >/dev/null ; then
return 0
else
return 1
fi
}

startAlist(){
alistpath="${installpath}/serv00-play/alist"
cd $alistpath
user="$(whoami)"
if isServ00 ; then
domain="alist.$user.serv00.net"
else
domain="alist.$user.ct8.pl"
fi
webpath="${installpath}/domains/$domain/public_html/"
domain=$(jq -r ".domain" config.json)
alistpath="${installpath}/serv00-play/alist"

if [[ -d "$webpath/data" && -e "$webpath/alist" ]]; then
cd $webpath
if [[ -d "$alistpath/data" && -e "$alistpath/alist" ]]; then
cd $alistpath
echo "正在启动alist..."
if checkAlistAlive; then
if checkProcAlive alist; then
echo "alist已启动,请勿重复启动!"
else
nohup ./alist server > /dev/null 2>&1 &
sleep 3
if ! checkAlistAlive; then
if ! checkProcAlive alist; then
red "启动失败,请检查!"
return 1
else
@@ -1394,62 +1376,67 @@ startAlist(){
red "请先行安装再启动!"
return
fi

}

stopAlist(){
r=$(ps aux | grep alist| grep -v "grep" | awk '{print $2}' )
if [ -z "$r" ]; then
return 0
else
kill -9 $r
if checkProcAlive "alist"; then
stopProc "alist"
sleep 3
fi
echo "已停掉alist!"
}

uninstallAlist(){
read -p "确定卸载alist吗? [y/n] [n]:" input
uninstallProc(){
local path=$1
local procname=$2

if [ ! -e "$path" ]; then
red "未安装$procname!!!"
return 1
fi
cd $path
read -p "确定卸载${procname}吗? [y/n] [n]:" input
input=${input:-n}
if [[ "$input" == "y" ]]; then
stopAlist
user="$(whoami)"
host="$(hostname | cut -d '.' -f 1)"
sno=${host/s/web}
if isServ00 ; then
domain="alist.$user.serv00.net"
else
domain="alist.$user.ct8.pl"
fi
webIp=$(devil vhost list public | grep "$sno" | awk '{print $1}')
stopProc "$procname"
domain=$(jq -r ".domain" config.json)
webip=$(jq -r ".webip" config.json)
resp=$(devil ssl www del $webIp $domain)
resp=$(devil www del $domain --remove)
cd ..
rm -rf $path
green "卸载完毕!"
fi

}

uninstallAlist(){
alistpath="${installpath}/serv00-play/alist"
uninstallProc "$alistpath" alist

}

resetAdminPass(){
user="$(whoami)"
if isServ00 ; then
domain="alist.$user.serv00.net"
else
domain="alist.$user.ct8.pl"
fi
webpath="${installpath}/domains/$domain/public_html/"
alistpath="${installpath}/serv00-play/alist"
cd $alistpath

cd $webpath
output=$(./alist admin random 2>&1)
extract_user_and_password "$output"
}

alistServ(){
if ! checkInstalled "serv00-play"; then
return 1
fi
while true; do
yellow "----------------------"
echo "alist:"
echo "服务状态: $(checkProcStatus alist)"
echo "1. 安装部署alist "
echo "2. 启动alist"
echo "3. 停掉alist"
echo "4. 重置admin密码"
echo "5. 卸载alist"
echo "8. 卸载alist"
echo "9. 返回主菜单"
echo "0. 退出脚本"
yellow "----------------------"
@@ -1464,7 +1451,7 @@ alistServ(){
;;
4) resetAdminPass
;;
5) uninstallAlist
8) uninstallAlist
;;
9) break
;;
@@ -1920,6 +1907,9 @@ checkProcStatus(){
}

sunPanelServ(){
if ! checkInstalled "serv00-play"; then
return 1
fi
while true; do
yellow "---------------------"
echo "sun-panel:"
@@ -1928,6 +1918,7 @@ sunPanelServ(){
echo "2. 启动"
echo "3. 停止"
echo "4. 初始化密码"
echo "8. 卸载"
echo "9. 返回主菜单"
echo "0. 退出脚本"
yellow "---------------------"
@@ -1942,6 +1933,8 @@ sunPanelServ(){
;;
4) resetSunPanelPwd
;;
8) uninstallSunPanel
;;
9) break
;;
0) exit 0
@@ -1953,6 +1946,11 @@ sunPanelServ(){
showMenu
}

uninstallSunPanel(){
local workdir="${installpath}/serv00-play/sunpanel"
uninstallProc "$workdir" "sun-panel"
}

resetSunPanelPwd(){
local exepath="${installpath}/serv00-play/sunpanel/sun-panel"
if [[ ! -e $exepath ]]; then
@@ -2088,7 +2086,13 @@ makeWWW(){
else
webIp=$(get_default_webip)
fi

# 保存信息
cat > config.json <<EOF
{
"webip": "$webIp",
"domain": "$domain"
}
EOF
green "域名绑定成功,你的域名是:$domain"
green "你的webip是:$webIp"
}
@@ -2124,13 +2128,17 @@ startSunPanel(){
}

websshServ(){
if ! checkInstalled "serv00-play"; then
return 1
fi
while true; do
yellow "---------------------"
echo "webssh:"
echo "服务状态: $(checkProcStatus wssh)"
echo "1. 安装/修改配置"
echo "2. 启动"
echo "3. 停止"
echo "8. 卸载"
echo "9. 返回主菜单"
echo "0. 退出脚本"
yellow "---------------------"
@@ -2143,6 +2151,8 @@ websshServ(){
;;
3) stopWebSSH
;;
8) uninstallWebSSH
;;
9) break
;;
0) exit 0
@@ -2154,6 +2164,11 @@ websshServ(){
showMenu
}

uninstallWebSSH(){
local workdir="${installpath}/serv00-play/webssh"
uninstallProc "$workdir" "wssh"
}

installWebSSH(){
local workdir="${installpath}/serv00-play/webssh"
if [[ ! -e "$workdir" ]]; then
@@ -2253,7 +2268,7 @@ startWebSSH(){
if checkProcAlive "wssh"; then
stopProc "wssh"
fi
cmd="nohup ./wssh --port=$port --fbidhttp=False $args &"
cmd="nohup ./wssh --port=$port --fbidhttp=False --xheaders=False --encoding='utf-8' --delay=10 $args &"
eval "$cmd"
if checkProcAlive wssh; then
green "启动成功!"
@@ -2271,6 +2286,19 @@ nonServ(){
EOF
}

checkInstalled(){
local model=$1
if [[ "$model" == "serv00-play" ]]; then
if [[ ! -d "${installpath}/$model" ]]; then
red "请先安装$model !!!"
return 1
else
return 0
fi
fi
return 1
}

showMenu(){
art_wrod=$(figlet "serv00-play")
echo "<------------------------------------------------------------------>"

0 comments on commit 7876c68

Please sign in to comment.