Merge pull request #795 from midoks/dev

国内安装支持多个代理选择
This commit is contained in:
Mr Chen 2025-08-18 21:59:21 +08:00 committed by GitHub
commit 40a6ce7aa7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 773 additions and 272 deletions

View File

@ -118,13 +118,13 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
- 初始安装
```
curl --insecure -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/install.sh | bash
bash <(curl --insecure -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/install.sh)
```
- 直接更新
```
curl --insecure -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/update.sh | bash
bash <(curl --insecure -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/update.sh)
```
- 卸载脚本
@ -138,14 +138,15 @@ wget --no-check-certificate -O uninstall.sh https://cdn.jsdelivr.net/gh/midoks/m
- 初始安装
```
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh | bash
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/master/scripts/install.sh | bash
bash <(curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/install.sh)
bash <(curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/master/scripts/install.sh)
```
- 直接更新
```
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh | bash
bash <(curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh)
```
- 卸载脚本
@ -160,24 +161,30 @@ wget --no-check-certificate -O uninstall.sh https://raw.githubusercontent.com/mi
- 需已经安装mdserver-web
```
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/quick/app.sh | bash
bash <(curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/quick/app.sh)
```
### DEV使用
```
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/install_dev.sh | bash
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash
bash <(curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/install.sh)
bash <(curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update.sh)
bash <(curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/install_dev.sh)
bash <(curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh)
wget --no-check-certificate -O install.sh https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/install.sh && bash install.sh
wget --no-check-certificate -O uninstall.sh https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/uninstall.sh && bash uninstall.sh
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/quick/debug.sh | bash
bash <(curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/quick/debug.sh)
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/install_dev.sh | bash
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/update_dev.sh | bash
bash <(curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/install.sh)
bash <(curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/update.sh)
bash <(curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/install_dev.sh)
bash <(curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/update_dev.sh)
```
### 旧版安装/更新
@ -194,7 +201,7 @@ cd /www/server/mdserver-web && rm -rf lib64
cd /www/server/mdserver-web && rm -rf bin
cd /www/server/mdserver-web && rm -rf include
mw update/mw update_dev
mw update/mw update_dev/mw dev
```
### 捐赠地址 USDTTRC20

View File

@ -170,7 +170,7 @@ class nosqlMongodb():
keys = ["bind_ip", "port"]
result['host'] = '127.0.0.1'
rep = 'port\s*=\s*(.*)'
rep = r'port\s*=\s*(.*)'
ip_re = re.search(rep, mgdb_content)
if ip_re:
result['port'] = int(ip_re.groups()[0].strip())

View File

@ -11,6 +11,9 @@ events
use {$EVENT_MODEL};
worker_connections 51200;
multi_accept on;
# file/video close the mutex lock when under high load
# accept_mutex off;
}
http
@ -32,14 +35,16 @@ http
client_body_buffer_size 50m;
client_max_body_size 50m;
# video big file opt
# aio threads;
directio 4m;
output_buffers 16 512k;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 60;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;

View File

@ -34,6 +34,12 @@ net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.ip_local_port_range = 1024 65001
# vm opt
vm.dirty_ratio = 40
vm.dirty_background_ratio = 10
vm.swappiness = 10
vm.vfs_cache_pressure = 500
vm.overcommit_memory=1
vm.max_map_count = 262144

View File

@ -243,23 +243,136 @@ error_logs()
tail -n 100 ${PANEL_DIR}/logs/panel_error.log
}
# 00----00----00----00----00----00----00----00----00----00----00----00----00----00
function AutoSizeStr(){
NAME_STR=$1
NAME_NUM=$2
NAME_STR_LEN=`echo "$NAME_STR" | wc -L`
NAME_NUM_LEN=`echo "$NAME_NUM" | wc -L`
fix_len=35
remaining_len=`expr $fix_len - $NAME_STR_LEN - $NAME_NUM_LEN`
FIX_SPACE=' '
for ((ass_i=1;ass_i<=$remaining_len;ass_i++))
do
FIX_SPACE="$FIX_SPACE "
done
echo -e " ❖ ${1}${FIX_SPACE}${2})"
}
function ChooseProxyURL(){
clear
echo -e '+---------------------------------------------------+'
echo -e '| |'
echo -e '| ============================================= |'
echo -e '| |'
echo -e '| 欢迎使用 Linux 一键安装mdserver-web面板源码 |'
echo -e '| |'
echo -e '| ============================================= |'
echo -e '| |'
echo -e '+---------------------------------------------------+'
echo -e ''
echo -e '#####################################################'
echo -e ''
echo -e ' 提供以下国内代理地址可供选择: '
echo -e ''
echo -e '#####################################################'
echo -e ''
cm_i=0
for V in ${SOURCE_LIST_KEY[@]}; do
num=`expr $cm_i + 1`
AutoSizeStr "${V}" "$num"
cm_i=`expr $cm_i + 1`
done
echo -e ''
echo -e '#####################################################'
echo -e ''
echo -e " 系统时间 ${BLUE}$(date "+%Y-%m-%d %H:%M:%S")${PLAIN}"
echo -e ''
echo -e '#####################################################'
CHOICE_A=$(echo -e "\n${BOLD}└─ 请选择并输入你想使用的代理地址 [ 1-${SOURCE_LIST_LEN} ]${PLAIN}")
read -p "${CHOICE_A}" INPUT
# echo $INPUT
if [ "$INPUT" == "" ];then
INPUT=1
TMP_INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
echo -e "\n默认选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
fi
if [ "$INPUT" -lt "0" ];then
INPUT=1
TMP_INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
echo -e "\n低于边界错误!选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
sleep 2s
fi
if [ "$INPUT" -gt "${SOURCE_LIST_LEN}" ];then
INPUT=${SOURCE_LIST_LEN}
TMP_INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
echo -e "\n超出边界错误!选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
sleep 2s
fi
INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$INPUT]}
HTTP_PREFIX=${PROXY_URL[$INPUT_KEY]}
}
mw_common_proxy(){
HTTP_PREFIX="https://"
LOCAL_ADDR=common
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
LOCAL_ADDR=cn
fi
if [ "$LOCAL_ADDR" != "common" ];then
declare -A PROXY_URL
PROXY_URL["gh_proxy_com"]="https://gh-proxy.com/"
PROXY_URL["github_do"]="https://github.do/"
PROXY_URL["gh_llkk_cc"]="https://gh.llkk.cc/https://"
PROXY_URL["gh_felicity_ac_cn"]="https://gh.felicity.ac.cn/https://"
PROXY_URL["ghfast_top"]="https://ghfast.top/"
PROXY_URL["ghproxy_net"]="https://ghproxy.net/"
PROXY_URL["source"]="https://"
SOURCE_LIST_KEY_SORT_TMP=$(echo ${!PROXY_URL[@]} | tr ' ' '\n' | sort -n)
SOURCE_LIST_KEY=(${SOURCE_LIST_KEY_SORT_TMP//'\n'/})
SOURCE_LIST_LEN=${#PROXY_URL[*]}
fi
if [ "$LOCAL_ADDR" != "common" ];then
ChooseProxyURL
if [ "$DOMAIN" != "https://" ];then
DOMAIN=`echo $HTTP_PREFIX | sed 's|https://||g'`
DOMAIN=`echo $DOMAIN | sed 's|/||g'`
ping -c 3 $DOMAIN > /dev/null 2>&1
if [ "$?" != "0" ];then
echo "无效代理地址${HTTP_PREFIX}"
exit
fi
fi
fi
}
mw_install(){
if [ -f ${PANEL_DIR}/task.py ];then
echo "与后续版本差异太大,不再提供更新"
exit 0
fi
LOCAL_ADDR=common
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
LOCAL_ADDR=cn
fi
if [ "$LOCAL_ADDR" == "common" ];then
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh | bash
else
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/install.sh | bash
fi
mw_common_proxy
echo "bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh")"
bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh")
}
mw_update()
@ -269,17 +382,9 @@ mw_update()
exit 0
fi
LOCAL_ADDR=common
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
LOCAL_ADDR=cn
fi
if [ "$LOCAL_ADDR" == "common" ];then
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh | bash
else
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/update.sh | bash
fi
mw_common_proxy
echo "bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh")"
bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh")
}
mw_update_dev()
@ -288,18 +393,11 @@ mw_update_dev()
echo "与后续版本差异太大,不再提供更新"
exit 0
fi
mw_common_proxy
echo "bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh")"
bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh")
LOCAL_ADDR=common
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
LOCAL_ADDR=cn
fi
if [ "$LOCAL_ADDR" == "common" ];then
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash
else
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/update_dev.sh | bash
fi
cd ${PANEL_DIR}
}
@ -309,17 +407,10 @@ mw_update_venv()
rm -rf ${PANEL_DIR}/lib64
rm -rf ${PANEL_DIR}/lib
LOCAL_ADDR=common
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
LOCAL_ADDR=cn
fi
mw_common_proxy
echo "bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh")"
bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh")
if [ "$LOCAL_ADDR" == "common" ];then
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash
else
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/update_dev.sh | bash
fi
cd ${PANEL_DIR}
}
@ -380,24 +471,6 @@ mw_debug(){
gunicorn -b :$port -k eventlet -w 1 app:app
}
function AutoSizeStr(){
NAME_STR=$1
NAME_NUM=$2
NAME_STR_LEN=`echo "$NAME_STR" | wc -L`
NAME_NUM_LEN=`echo "$NAME_NUM" | wc -L`
fix_len=35
remaining_len=`expr $fix_len - $NAME_STR_LEN - $NAME_NUM_LEN`
FIX_SPACE=' '
for ((ass_i=1;ass_i<=$remaining_len;ass_i++))
do
FIX_SPACE="$FIX_SPACE "
done
echo -e " ❖ ${1}${FIX_SPACE}${2})"
}
mw_connect_mysql(){
# choose mysql login

View File

@ -1,6 +1,20 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
export PATH
RED='\033[31m'
GREEN='\033[32m'
YELLOW='\033[33m'
BLUE='\033[34m'
PLAIN='\033[0m'
BOLD='\033[1m'
SUCCESS='[\033[32mOK\033[0m]'
COMPLETE='[\033[32mDONE\033[0m]'
WARN='[\033[33mWARN\033[0m]'
ERROR='[\033[31mERROR\033[0m]'
WORKING='[\033[34m*\033[0m]'
# LANG=en_US.UTF-8
is64bit=`getconf LONG_BIT`
@ -12,9 +26,125 @@ if [ -f /www/server/mdserver-web/tools.py ];then
fi
LOG_FILE=/var/log/mw-install.log
{
HTTP_PREFIX="https://"
LOCAL_ADDR=common
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
LOCAL_ADDR=cn
fi
if [ "$LOCAL_ADDR" != "common" ];then
declare -A PROXY_URL
PROXY_URL["gh_proxy_com"]="https://gh-proxy.com/"
PROXY_URL["github_do"]="https://github.do/"
PROXY_URL["gh_llkk_cc"]="https://gh.llkk.cc/https://"
PROXY_URL["gh_felicity_ac_cn"]="https://gh.felicity.ac.cn/https://"
PROXY_URL["ghfast_top"]="https://ghfast.top/"
PROXY_URL["ghproxy_net"]="https://ghproxy.net/"
PROXY_URL["source"]="https://"
SOURCE_LIST_KEY_SORT_TMP=$(echo ${!PROXY_URL[@]} | tr ' ' '\n' | sort -n)
SOURCE_LIST_KEY=(${SOURCE_LIST_KEY_SORT_TMP//'\n'/})
SOURCE_LIST_LEN=${#PROXY_URL[*]}
fi
function AutoSizeStr(){
NAME_STR=$1
NAME_NUM=$2
NAME_STR_LEN=`echo "$NAME_STR" | wc -L`
NAME_NUM_LEN=`echo "$NAME_NUM" | wc -L`
fix_len=35
remaining_len=`expr $fix_len - $NAME_STR_LEN - $NAME_NUM_LEN`
FIX_SPACE=' '
for ((ass_i=1;ass_i<=$remaining_len;ass_i++))
do
FIX_SPACE="$FIX_SPACE "
done
echo -e "${1}${FIX_SPACE}${2})"
}
function ChooseProxyURL(){
clear
echo -e '+---------------------------------------------------+'
echo -e '| |'
echo -e '| ============================================= |'
echo -e '| |'
echo -e '| 欢迎使用 Linux 一键安装mdserver-web面板源码 |'
echo -e '| |'
echo -e '| ============================================= |'
echo -e '| |'
echo -e '+---------------------------------------------------+'
echo -e ''
echo -e '#####################################################'
echo -e ''
echo -e ' 提供以下国内代理地址可供选择: '
echo -e ''
echo -e '#####################################################'
echo -e ''
cm_i=0
for V in ${SOURCE_LIST_KEY[@]}; do
num=`expr $cm_i + 1`
AutoSizeStr "${V}" "$num"
cm_i=`expr $cm_i + 1`
done
echo -e ''
echo -e '#####################################################'
echo -e ''
echo -e " 系统时间 ${BLUE}$(date "+%Y-%m-%d %H:%M:%S")${PLAIN}"
echo -e ''
echo -e '#####################################################'
CHOICE_A=$(echo -e "\n${BOLD}└─ 请选择并输入你想使用的代理地址 [ 1-${SOURCE_LIST_LEN} ]${PLAIN}")
read -p "${CHOICE_A}" INPUT
# echo $INPUT
if [ "$INPUT" == "" ];then
INPUT=1
TMP_INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
echo -e "\n默认选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
fi
if [ "$INPUT" -lt "0" ];then
INPUT=1
TMP_INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
echo -e "\n低于边界错误!选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
sleep 2s
fi
if [ "$INPUT" -gt "${SOURCE_LIST_LEN}" ];then
INPUT=${SOURCE_LIST_LEN}
TMP_INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
echo -e "\n超出边界错误!选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
sleep 2s
fi
INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$INPUT]}
HTTP_PREFIX=${PROXY_URL[$INPUT_KEY]}
}
if [ "$LOCAL_ADDR" != "common" ];then
ChooseProxyURL
if [ "$DOMAIN" != "https://" ];then
DOMAIN=`echo $HTTP_PREFIX | sed 's|https://||g'`
DOMAIN=`echo $DOMAIN | sed 's|/||g'`
ping -c 3 $DOMAIN > /dev/null 2>&1
if [ "$?" != "0" ];then
echo "无效代理地址:${DOMAIN}"
exit
fi
fi
fi
if [ -f /etc/motd ];then
echo "welcome to mdserver-web panel" > /etc/motd
fi
@ -76,24 +206,8 @@ if [ "$EUID" -ne 0 ] && [ "$OSNAME" != "macos" ];then
exit
fi
# HTTP_PREFIX="https://"
# LOCAL_ADDR=common
# ping -c 1 github.com > /dev/null 2>&1
# if [ "$?" != "0" ];then
# LOCAL_ADDR=cn
# HTTP_PREFIX="https://mirror.ghproxy.com/"
# fi
HTTP_PREFIX="https://"
LOCAL_ADDR=common
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
LOCAL_ADDR=cn
HTTP_PREFIX="https://mirror.ghproxy.com/"
fi
echo "local:${LOCAL_ADDR}"
echo "LOCAL:${LOCAL_ADDR}"
echo "OSNAME:${OSNAME}"
if [ $OSNAME != "macos" ];then
if id www &> /dev/null ;then
@ -109,44 +223,30 @@ if [ $OSNAME != "macos" ];then
mkdir -p /www/backup/database
mkdir -p /www/backup/site
# https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/install.sh
if [ ! -d /www/server/mdserver-web ];then
if [ "$LOCAL_ADDR" == "common" ];then
curl --insecure -sSLo /tmp/master.zip ${HTTP_PREFIX}github.com/midoks/mdserver-web/archive/refs/heads/master.zip
cd /tmp && unzip /tmp/master.zip
mv -f /tmp/mdserver-web-master /www/server/mdserver-web
rm -rf /tmp/master.zip
rm -rf /tmp/mdserver-web-master
else
# curl --insecure -sSLo /tmp/master.zip https://code.midoks.icu/midoks/mdserver-web/archive/master.zip
wget --no-check-certificate -O /tmp/master.zip https://code.midoks.icu/midoks/mdserver-web/archive/master.zip
cd /tmp && unzip /tmp/master.zip
mv -f /tmp/mdserver-web /www/server/mdserver-web
rm -rf /tmp/master.zip
rm -rf /tmp/mdserver-web
fi
curl --insecure -sSLo /tmp/master.zip ${HTTP_PREFIX}github.com/midoks/mdserver-web/archive/refs/heads/master.tar.gz
cd /tmp && tar -zxvf /tmp/master.tar.gz
mv -f /tmp/mdserver-web-master /www/server/mdserver-web
rm -rf /tmp/master.tar.gz
rm -rf /tmp/mdserver-web-master
fi
# install acme.sh
if [ ! -d /root/.acme.sh ];then
if [ "$LOCAL_ADDR" != "common" ];then
curl --insecure -sSLo /tmp/acme.tar.gz https://gitee.com/neilpang/acme.sh/repository/archive/master.tar.gz
tar xvzf /tmp/acme.tar.gz -C /tmp
cd /tmp/acme.sh-master
curl --insecure -sSLo /tmp/acme.sh-master.tar.gz ${HTTP_PREFIX}github.com/acmesh-official/acme.sh/archive/refs/heads/master.tar.gz
tar xvzf /tmp/acme.sh-master.tar.gz -C /tmp
cd /tmp/acme.sh-master.tar.gz
bash acme.sh install
fi
if [ ! -d /root/.acme.sh ];then
curl https://get.acme.sh | sh
else
curl -fsSL https://get.acme.sh | bash
fi
fi
fi
echo "use system version: ${OSNAME}"
if [ "${OSNAME}" == "macos" ];then
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/master/scripts/install/macos.sh | bash
curl --insecure -fsSL ${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/refs/heads/dev/scripts/install/macos.sh | bash
else
cd /www/server/mdserver-web && bash scripts/install/${OSNAME}.sh
fi

View File

@ -1,9 +1,23 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
export PATH
RED='\033[31m'
GREEN='\033[32m'
YELLOW='\033[33m'
BLUE='\033[34m'
PLAIN='\033[0m'
BOLD='\033[1m'
SUCCESS='[\033[32mOK\033[0m]'
COMPLETE='[\033[32mDONE\033[0m]'
WARN='[\033[33mWARN\033[0m]'
ERROR='[\033[31mERROR\033[0m]'
WORKING='[\033[34m*\033[0m]'
# LANG=en_US.UTF-8
is64bit=`getconf LONG_BIT`
if [ -f /www/server/mdserver-web/tools.py ];then
echo -e "存在旧版代码,不能安装!,已知风险的情况下"
echo -e "rm -rf /www/server/mdserver-web"
@ -19,6 +33,123 @@ LOG_FILE=/var/log/mw-install.log
{
HTTP_PREFIX="https://"
LOCAL_ADDR=common
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
LOCAL_ADDR=cn
fi
if [ "$LOCAL_ADDR" != "common" ];then
declare -A PROXY_URL
PROXY_URL["gh_proxy_com"]="https://gh-proxy.com/"
PROXY_URL["github_do"]="https://github.do/"
PROXY_URL["gh_llkk_cc"]="https://gh.llkk.cc/https://"
PROXY_URL["gh_felicity_ac_cn"]="https://gh.felicity.ac.cn/https://"
PROXY_URL["ghfast_top"]="https://ghfast.top/"
PROXY_URL["ghproxy_net"]="https://ghproxy.net/"
PROXY_URL["source"]="https://"
SOURCE_LIST_KEY_SORT_TMP=$(echo ${!PROXY_URL[@]} | tr ' ' '\n' | sort -n)
SOURCE_LIST_KEY=(${SOURCE_LIST_KEY_SORT_TMP//'\n'/})
SOURCE_LIST_LEN=${#PROXY_URL[*]}
fi
function AutoSizeStr(){
NAME_STR=$1
NAME_NUM=$2
NAME_STR_LEN=`echo "$NAME_STR" | wc -L`
NAME_NUM_LEN=`echo "$NAME_NUM" | wc -L`
fix_len=35
remaining_len=`expr $fix_len - $NAME_STR_LEN - $NAME_NUM_LEN`
FIX_SPACE=' '
for ((ass_i=1;ass_i<=$remaining_len;ass_i++))
do
FIX_SPACE="$FIX_SPACE "
done
echo -e "${1}${FIX_SPACE}${2})"
}
function ChooseProxyURL(){
clear
echo -e '+---------------------------------------------------+'
echo -e '| |'
echo -e '| ============================================= |'
echo -e '| |'
echo -e '| 欢迎使用 Linux 一键安装mdserver-web面板源码 |'
echo -e '| |'
echo -e '| ============================================= |'
echo -e '| |'
echo -e '+---------------------------------------------------+'
echo -e ''
echo -e '#####################################################'
echo -e ''
echo -e ' 提供以下国内代理地址可供选择: '
echo -e ''
echo -e '#####################################################'
echo -e ''
cm_i=0
for V in ${SOURCE_LIST_KEY[@]}; do
num=`expr $cm_i + 1`
AutoSizeStr "${V}" "$num"
cm_i=`expr $cm_i + 1`
done
echo -e ''
echo -e '#####################################################'
echo -e ''
echo -e " 系统时间 ${BLUE}$(date "+%Y-%m-%d %H:%M:%S")${PLAIN}"
echo -e ''
echo -e '#####################################################'
CHOICE_A=$(echo -e "\n${BOLD}└─ 请选择并输入你想使用的代理地址 [ 1-${SOURCE_LIST_LEN} ]${PLAIN}")
read -p "${CHOICE_A}" INPUT
# echo $INPUT
if [ "$INPUT" == "" ];then
INPUT=1
TMP_INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
echo -e "\n默认选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
fi
if [ "$INPUT" -lt "0" ];then
INPUT=1
TMP_INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
echo -e "\n低于边界错误!选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
sleep 2s
fi
if [ "$INPUT" -gt "${SOURCE_LIST_LEN}" ];then
INPUT=${SOURCE_LIST_LEN}
TMP_INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
echo -e "\n超出边界错误!选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
sleep 2s
fi
INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$INPUT]}
HTTP_PREFIX=${PROXY_URL[$INPUT_KEY]}
}
if [ "$LOCAL_ADDR" != "common" ];then
ChooseProxyURL
if [ "$DOMAIN" != "https://" ];then
DOMAIN=`echo $HTTP_PREFIX | sed 's|https://||g'`
DOMAIN=`echo $DOMAIN | sed 's|/||g'`
ping -c 3 $DOMAIN > /dev/null 2>&1
if [ "$?" != "0" ];then
echo "无效代理地址:${DOMAIN}"
exit
fi
fi
fi
if [ -f /etc/motd ];then
echo "welcome to mdserver-web panel" > /etc/motd
fi
@ -81,23 +212,8 @@ if [ "$EUID" -ne 0 ] && [ "$OSNAME" != "macos" ];then
exit
fi
# HTTP_PREFIX="https://"
# LOCAL_ADDR=common
# ping -c 1 github.com > /dev/null 2>&1
# if [ "$?" != "0" ];then
# LOCAL_ADDR=cn
# HTTP_PREFIX="https://mirror.ghproxy.com/"
# fi
HTTP_PREFIX="https://"
LOCAL_ADDR=common
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
LOCAL_ADDR=cn
HTTP_PREFIX="https://mirror.ghproxy.com/"
fi
echo "local:${LOCAL_ADDR}"
echo "LOCAL:${LOCAL_ADDR}"
echo "OSNAME:${OSNAME}"
if [ $OSNAME != "macos" ];then
@ -116,35 +232,23 @@ if [ $OSNAME != "macos" ];then
mkdir -p /www/backup/site
if [ ! -d /www/server/mdserver-web ];then
if [ "$LOCAL_ADDR" == "common" ];then
curl --insecure -sSLo /tmp/dev.zip ${HTTP_PREFIX}github.com/midoks/mdserver-web/archive/refs/heads/dev.zip
cd /tmp && unzip /tmp/dev.zip
mv -f /tmp/mdserver-web-dev /www/server/mdserver-web
rm -rf /tmp/dev.zip
rm -rf /tmp/mdserver-web-dev
else
# curl --insecure -sSLo /tmp/dev.zip https://code.midoks.icu/midoks/mdserver-web/archive/dev.zip
wget --no-check-certificate -O /tmp/dev.zip https://code.midoks.icu/midoks/mdserver-web/archive/dev.zip
cd /tmp && unzip /tmp/dev.zip
mv -f /tmp/mdserver-web /www/server/mdserver-web
rm -rf /tmp/dev.zip
rm -rf /tmp/mdserver-web
fi
echo "downloading ${HTTP_PREFIX}github.com/midoks/mdserver-web/archive/refs/heads/dev.zip"
curl --insecure -sSLo /tmp/dev.zip ${HTTP_PREFIX}github.com/midoks/mdserver-web/archive/refs/heads/dev.zip
cd /tmp && unzip /tmp/dev.zip
mv -f /tmp/mdserver-web-dev /www/server/mdserver-web
rm -rf /tmp/dev.zip
rm -rf /tmp/mdserver-web-dev
fi
# install acme.sh
if [ ! -d /root/.acme.sh ];then
if [ "$LOCAL_ADDR" != "common" ];then
# curl -sSL -o /tmp/acme.tar.gz ${HTTP_PREFIX}github.com/acmesh-official/acme.sh/archive/master.tar.gz
curl --insecure -sSLo /tmp/acme.tar.gz https://gitee.com/neilpang/acme.sh/repository/archive/master.tar.gz
curl -sSL -o /tmp/acme.tar.gz ${HTTP_PREFIX}github.com/acmesh-official/acme.sh/archive/master.tar.gz
tar xvzf /tmp/acme.tar.gz -C /tmp
cd /tmp/acme.sh-master
bash acme.sh install
fi
if [ ! -d /root/.acme.sh ];then
curl https://get.acme.sh | sh
else
curl -fsSL https://get.acme.sh | bash
fi
fi
fi
@ -152,7 +256,7 @@ fi
echo "use system version: ${OSNAME}"
if [ "${OSNAME}" == "macos" ];then
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/master/scripts/install/macos.sh | bash
curl --insecure -fsSL ${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/refs/heads/dev/scripts/install/macos.sh | bash
else
cd /www/server/mdserver-web && bash scripts/install/${OSNAME}.sh
fi

View File

@ -57,19 +57,11 @@ fi
echo "system:${OSNAME}:${VERSION_ID}"
# HTTP_PREFIX="https://"
# LOCAL_ADDR=common
# ping -c 1 github.com > /dev/null 2>&1
# if [ "$?" != "0" ];then
# LOCAL_ADDR=cn
# HTTP_PREFIX="https://mirror.ghproxy.com/"
# fi
HTTP_PREFIX="https://"
LOCAL_ADDR=common
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
LOCAL_ADDR=cn
HTTP_PREFIX="https://mirror.ghproxy.com/"
fi
PIPSRC="https://pypi.python.org/simple"

View File

@ -7,10 +7,10 @@ is64bit=`getconf LONG_BIT`
startTime=`date +%s`
if [ -f /www/server/mdserver-web/tools.py ];then
echo -e "存在旧版代码,不能安装!,已知风险的情况下"
echo -e "rm -rf /www/server/mdserver-web"
echo -e "可安装!"
exit 0
echo -e "存在旧版代码,不能安装!,已知风险的情况下"
echo -e "rm -rf /www/server/mdserver-web"
echo -e "可安装!"
exit 0
fi
@ -23,90 +23,192 @@ if [ "$EUID" -ne 0 ]
fi
if [ ${_os} != "Darwin" ] && [ ! -d /www/server/mdserver-web/logs ]; then
mkdir -p /www/server/mdserver-web/logs
mkdir -p /www/server/mdserver-web/logs
fi
LOG_FILE=/var/log/mw-update.log
{
if [ ${_os} == "Darwin" ]; then
OSNAME='macos'
elif grep -Eqi "openSUSE" /etc/*-release; then
OSNAME='opensuse'
zypper refresh
elif grep -Eqi "EulerOS" /etc/*-release || grep -Eqi "openEuler" /etc/*-release; then
OSNAME='euler'
elif grep -Eqi "FreeBSD" /etc/*-release; then
OSNAME='freebsd'
elif grep -Eqi "CentOS" /etc/issue || grep -Eqi "CentOS" /etc/*-release; then
OSNAME='rhel'
yum install -y wget zip unzip
elif grep -Eqi "Fedora" /etc/issue || grep -Eqi "Fedora" /etc/*-release; then
OSNAME='rhel'
yum install -y wget zip unzip
elif grep -Eqi "Rocky" /etc/issue || grep -Eqi "Rocky" /etc/*-release; then
OSNAME='rhel'
yum install -y wget zip unzip
elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eqi "AlmaLinux" /etc/*-release; then
OSNAME='rhel'
yum install -y wget zip unzip
elif grep -Eqi "Anolis" /etc/issue || grep -Eqi "Anolis" /etc/*-release; then
OSNAME='rhel'
yum install -y wget curl zip unzip tar crontabs
elif grep -Eqi "Amazon Linux" /etc/issue || grep -Eqi "Amazon Linux" /etc/*-release; then
OSNAME='amazon'
yum install -y wget zip unzip
elif grep -Eqi "Debian" /etc/issue || grep -Eqi "Debian" /etc/*-release; then
OSNAME='debian'
apt install -y wget zip unzip
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eqi "Ubuntu" /etc/*-release; then
OSNAME='ubuntu'
apt install -y wget zip unzip
elif grep -Eqi "Raspbian" /etc/issue || grep -Eqi "Raspbian" /etc/*-release; then
OSNAME='raspbian'
elif grep -Eqi "Alpine" /etc/issue || grep -Eqi "Alpine" /etc/*-release; then
OSNAME='alpine'
apk update
apk add devscripts -force-broken-world
apk add wget zip unzip tar -force-broken-world
else
OSNAME='unknow'
fi
HTTP_PREFIX="https://"
LOCAL_ADDR=common
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
LOCAL_ADDR=cn
HTTP_PREFIX="https://mirror.ghproxy.com/"
fi
echo "local:${LOCAL_ADDR}"
CP_CMD=/usr/bin/cp
if [ -f /bin/cp ];then
CP_CMD=/bin/cp
LOCAL_ADDR=cn
fi
if [ "$LOCAL_ADDR" != "common" ];then
# curl --insecure -sSLo /tmp/master.zip https://code.midoks.icu/midoks/mdserver-web/archive/master.zip
wget --no-check-certificate -O /tmp/master.zip https://code.midoks.icu/midoks/mdserver-web/archive/master.zip
cd /tmp && unzip /tmp/master.zip
declare -A PROXY_URL
PROXY_URL["gh_proxy_com"]="https://gh-proxy.com/"
PROXY_URL["github_do"]="https://github.do/"
PROXY_URL["gh_llkk_cc"]="https://gh.llkk.cc/https://"
PROXY_URL["gh_felicity_ac_cn"]="https://gh.felicity.ac.cn/https://"
PROXY_URL["ghfast_top"]="https://ghfast.top/"
PROXY_URL["ghproxy_net"]="https://ghproxy.net/"
PROXY_URL["source"]="https://"
$CP_CMD -rf /tmp/mdserver-web/* /www/server/mdserver-web
rm -rf /tmp/master.zip
rm -rf /tmp/mdserver-web
else
curl --insecure -sSLo /tmp/master.zip https://codeload.github.com/midoks/mdserver-web/zip/master
cd /tmp && unzip /tmp/master.zip
$CP_CMD -rf /tmp/mdserver-web-master/* /www/server/mdserver-web
rm -rf /tmp/master.zip
rm -rf /tmp/mdserver-web-master
SOURCE_LIST_KEY_SORT_TMP=$(echo ${!PROXY_URL[@]} | tr ' ' '\n' | sort -n)
SOURCE_LIST_KEY=(${SOURCE_LIST_KEY_SORT_TMP//'\n'/})
SOURCE_LIST_LEN=${#PROXY_URL[*]}
fi
function AutoSizeStr(){
NAME_STR=$1
NAME_NUM=$2
NAME_STR_LEN=`echo "$NAME_STR" | wc -L`
NAME_NUM_LEN=`echo "$NAME_NUM" | wc -L`
fix_len=35
remaining_len=`expr $fix_len - $NAME_STR_LEN - $NAME_NUM_LEN`
FIX_SPACE=' '
for ((ass_i=1;ass_i<=$remaining_len;ass_i++))
do
FIX_SPACE="$FIX_SPACE "
done
echo -e "${1}${FIX_SPACE}${2})"
}
function ChooseProxyURL(){
clear
echo -e '+---------------------------------------------------+'
echo -e '| |'
echo -e '| ============================================= |'
echo -e '| |'
echo -e '| 欢迎使用 Linux 一键安装mdserver-web面板源码 |'
echo -e '| |'
echo -e '| ============================================= |'
echo -e '| |'
echo -e '+---------------------------------------------------+'
echo -e ''
echo -e '#####################################################'
echo -e ''
echo -e ' 提供以下国内代理地址可供选择: '
echo -e ''
echo -e '#####################################################'
echo -e ''
cm_i=0
for V in ${SOURCE_LIST_KEY[@]}; do
num=`expr $cm_i + 1`
AutoSizeStr "${V}" "$num"
cm_i=`expr $cm_i + 1`
done
echo -e ''
echo -e '#####################################################'
echo -e ''
echo -e " 系统时间 ${BLUE}$(date "+%Y-%m-%d %H:%M:%S")${PLAIN}"
echo -e ''
echo -e '#####################################################'
CHOICE_A=$(echo -e "\n${BOLD}└─ 请选择并输入你想使用的代理地址 [ 1-${SOURCE_LIST_LEN} ]${PLAIN}")
read -p "${CHOICE_A}" INPUT
# echo $INPUT
if [ "$INPUT" == "" ];then
INPUT=1
TMP_INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
echo -e "\n默认选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
fi
if [ "$INPUT" -lt "0" ];then
INPUT=1
TMP_INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
echo -e "\n低于边界错误!选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
sleep 2s
fi
if [ "$INPUT" -gt "${SOURCE_LIST_LEN}" ];then
INPUT=${SOURCE_LIST_LEN}
TMP_INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
echo -e "\n超出边界错误!选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
sleep 2s
fi
INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$INPUT]}
HTTP_PREFIX=${PROXY_URL[$INPUT_KEY]}
}
if [ "$LOCAL_ADDR" != "common" ];then
ChooseProxyURL
if [ "$DOMAIN" != "https://" ];then
DOMAIN=`echo $HTTP_PREFIX | sed 's|https://||g'`
DOMAIN=`echo $DOMAIN | sed 's|/||g'`
ping -c 3 $DOMAIN > /dev/null 2>&1
if [ "$?" != "0" ];then
echo "无效代理地址:${DOMAIN}"
exit
fi
fi
fi
if [ ${_os} == "Darwin" ]; then
OSNAME='macos'
elif grep -Eqi "openSUSE" /etc/*-release; then
OSNAME='opensuse'
zypper refresh
elif grep -Eqi "EulerOS" /etc/*-release || grep -Eqi "openEuler" /etc/*-release; then
OSNAME='euler'
elif grep -Eqi "FreeBSD" /etc/*-release; then
OSNAME='freebsd'
elif grep -Eqi "CentOS" /etc/issue || grep -Eqi "CentOS" /etc/*-release; then
OSNAME='rhel'
yum install -y wget zip unzip
elif grep -Eqi "Fedora" /etc/issue || grep -Eqi "Fedora" /etc/*-release; then
OSNAME='rhel'
yum install -y wget zip unzip
elif grep -Eqi "Rocky" /etc/issue || grep -Eqi "Rocky" /etc/*-release; then
OSNAME='rhel'
yum install -y wget zip unzip
elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eqi "AlmaLinux" /etc/*-release; then
OSNAME='rhel'
yum install -y wget zip unzip
elif grep -Eqi "Anolis" /etc/issue || grep -Eqi "Anolis" /etc/*-release; then
OSNAME='rhel'
yum install -y wget curl zip unzip tar crontabs
elif grep -Eqi "Amazon Linux" /etc/issue || grep -Eqi "Amazon Linux" /etc/*-release; then
OSNAME='amazon'
yum install -y wget zip unzip
elif grep -Eqi "Debian" /etc/issue || grep -Eqi "Debian" /etc/*-release; then
OSNAME='debian'
apt install -y wget zip unzip
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eqi "Ubuntu" /etc/*-release; then
OSNAME='ubuntu'
apt install -y wget zip unzip
elif grep -Eqi "Raspbian" /etc/issue || grep -Eqi "Raspbian" /etc/*-release; then
OSNAME='raspbian'
elif grep -Eqi "Alpine" /etc/issue || grep -Eqi "Alpine" /etc/*-release; then
OSNAME='alpine'
apk update
apk add devscripts -force-broken-world
apk add wget zip unzip tar -force-broken-world
else
OSNAME='unknow'
fi
echo "LOCAL:${LOCAL_ADDR}"
CP_CMD=/usr/bin/cp
if [ -f /bin/cp ];then
CP_CMD=/bin/cp
fi
echo "update mdserver-web code start"
curl --insecure -sSLo /tmp/master.tar.gz ${HTTP_PREFIX}github.com/midoks/mdserver-web/archive/refs/heads/master.tar.gz
cd /tmp && tar -zxvf /tmp/master.tar.gz
$CP_CMD -rf /tmp/mdserver-web-master/* /www/server/mdserver-web
rm -rf /tmp/master.tar.gz
rm -rf /tmp/mdserver-web-master
echo "update mdserver-web code end"
#pip uninstall public
echo "use system version: ${OSNAME}"
cd /www/server/mdserver-web && bash scripts/update/${OSNAME}.sh
@ -115,13 +217,13 @@ bash /etc/rc.d/init.d/mw restart
bash /etc/rc.d/init.d/mw default
if [ -f /usr/bin/mw ];then
rm -rf /usr/bin/mw
rm -rf /usr/bin/mw
fi
if [ ! -e /usr/bin/mw ]; then
if [ ! -f /usr/bin/mw ];then
ln -s /etc/rc.d/init.d/mw /usr/bin/mw
fi
if [ ! -f /usr/bin/mw ];then
ln -s /etc/rc.d/init.d/mw /usr/bin/mw
fi
fi
endTime=`date +%s`

View File

@ -1,6 +1,19 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
export PATH
RED='\033[31m'
GREEN='\033[32m'
YELLOW='\033[33m'
BLUE='\033[34m'
PLAIN='\033[0m'
BOLD='\033[1m'
SUCCESS='[\033[32mOK\033[0m]'
COMPLETE='[\033[32mDONE\033[0m]'
WARN='[\033[33mWARN\033[0m]'
ERROR='[\033[31mERROR\033[0m]'
WORKING='[\033[34m*\033[0m]'
# LANG=en_US.UTF-8
is64bit=`getconf LONG_BIT`
@ -29,6 +42,124 @@ LOG_FILE=/var/log/mw-update.log
{
HTTP_PREFIX="https://"
LOCAL_ADDR=common
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
LOCAL_ADDR=cn
fi
if [ "$LOCAL_ADDR" != "common" ];then
declare -A PROXY_URL
PROXY_URL["gh_proxy_com"]="https://gh-proxy.com/"
PROXY_URL["github_do"]="https://github.do/"
PROXY_URL["gh_llkk_cc"]="https://gh.llkk.cc/https://"
PROXY_URL["gh_felicity_ac_cn"]="https://gh.felicity.ac.cn/https://"
PROXY_URL["ghfast_top"]="https://ghfast.top/"
PROXY_URL["ghproxy_net"]="https://ghproxy.net/"
PROXY_URL["source"]="https://"
SOURCE_LIST_KEY_SORT_TMP=$(echo ${!PROXY_URL[@]} | tr ' ' '\n' | sort -n)
SOURCE_LIST_KEY=(${SOURCE_LIST_KEY_SORT_TMP//'\n'/})
SOURCE_LIST_LEN=${#PROXY_URL[*]}
fi
function AutoSizeStr(){
NAME_STR=$1
NAME_NUM=$2
NAME_STR_LEN=`echo "$NAME_STR" | wc -L`
NAME_NUM_LEN=`echo "$NAME_NUM" | wc -L`
fix_len=35
remaining_len=`expr $fix_len - $NAME_STR_LEN - $NAME_NUM_LEN`
FIX_SPACE=' '
for ((ass_i=1;ass_i<=$remaining_len;ass_i++))
do
FIX_SPACE="$FIX_SPACE "
done
echo -e "${1}${FIX_SPACE}${2})"
}
function ChooseProxyURL(){
clear
echo -e '+---------------------------------------------------+'
echo -e '| |'
echo -e '| ============================================= |'
echo -e '| |'
echo -e '| 欢迎使用 Linux 一键安装mdserver-web面板源码 |'
echo -e '| |'
echo -e '| ============================================= |'
echo -e '| |'
echo -e '+---------------------------------------------------+'
echo -e ''
echo -e '#####################################################'
echo -e ''
echo -e ' 提供以下国内代理地址可供选择: '
echo -e ''
echo -e '#####################################################'
echo -e ''
cm_i=0
for V in ${SOURCE_LIST_KEY[@]}; do
num=`expr $cm_i + 1`
AutoSizeStr "${V}" "$num"
cm_i=`expr $cm_i + 1`
done
echo -e ''
echo -e '#####################################################'
echo -e ''
echo -e " 系统时间 ${BLUE}$(date "+%Y-%m-%d %H:%M:%S")${PLAIN}"
echo -e ''
echo -e '#####################################################'
CHOICE_A=$(echo -e "\n${BOLD}└─ 请选择并输入你想使用的代理地址 [ 1-${SOURCE_LIST_LEN} ]${PLAIN}")
read -p "${CHOICE_A}" INPUT
# echo $INPUT
if [ "$INPUT" == "" ];then
INPUT=1
TMP_INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
echo -e "\n默认选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
fi
if [ "$INPUT" -lt "0" ];then
INPUT=1
TMP_INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
echo -e "\n低于边界错误!选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
sleep 2s
fi
if [ "$INPUT" -gt "${SOURCE_LIST_LEN}" ];then
INPUT=${SOURCE_LIST_LEN}
TMP_INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
echo -e "\n超出边界错误!选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
sleep 2s
fi
INPUT=`expr $INPUT - 1`
INPUT_KEY=${SOURCE_LIST_KEY[$INPUT]}
HTTP_PREFIX=${PROXY_URL[$INPUT_KEY]}
}
if [ "$LOCAL_ADDR" != "common" ];then
ChooseProxyURL
if [ "$DOMAIN" != "https://" ];then
DOMAIN=`echo $HTTP_PREFIX | sed 's|https://||g'`
DOMAIN=`echo $DOMAIN | sed 's|/||g'`
ping -c 3 $DOMAIN > /dev/null 2>&1
if [ "$?" != "0" ];then
echo "无效代理地址:${DOMAIN}"
exit
fi
fi
fi
if [ ${_os} == "Darwin" ]; then
OSNAME='macos'
elif grep -Eqi "openSUSE" /etc/*-release; then
@ -70,21 +201,6 @@ else
OSNAME='unknow'
fi
# HTTP_PREFIX="https://"
# LOCAL_ADDR=common
# ping -c 1 github.com > /dev/null 2>&1
# if [ "$?" != "0" ];then
# LOCAL_ADDR=cn
# HTTP_PREFIX="https://mirror.ghproxy.com/"
# fi
HTTP_PREFIX="https://"
LOCAL_ADDR=common
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
LOCAL_ADDR=cn
HTTP_PREFIX="https://mirror.ghproxy.com/"
fi
echo "local:${LOCAL_ADDR}"
CP_CMD=/usr/bin/cp
@ -92,29 +208,25 @@ if [ -f /bin/cp ];then
CP_CMD=/bin/cp
fi
echo "update mdserver-web code start"
if [ -f /tmp/dev.tar.gz ];then
rm -rf /tmp/dev.tar.gz
fi
if [ "$LOCAL_ADDR" != "common" ];then
wget --no-check-certificate -O /tmp/dev.zip https://code.midoks.icu/midoks/mdserver-web/archive/dev.zip
# curl --insecure -sSLo /tmp/dev.zip https://code.midoks.icu/midoks/mdserver-web/archive/dev.zip
cd /tmp && unzip /tmp/dev.zip
$CP_CMD -rf /tmp/mdserver-web/* /www/server/mdserver-web
rm -rf /tmp/master.zip
rm -rf /tmp/mdserver-web
else
curl --insecure -sSLo /tmp/dev.zip ${HTTP_PREFIX}github.com/midoks/mdserver-web/archive/refs/heads/dev.zip
cd /tmp && unzip /tmp/dev.zip
$CP_CMD -rf /tmp/mdserver-web-dev/* /www/server/mdserver-web
rm -rf /tmp/dev.zip
if [ -d /tmp/mdserver-web-dev ];then
rm -rf /tmp/mdserver-web-dev
fi
echo "update mdserver-web code end"
echo "update mdserver-web dev code start"
rm -rf /tmp/dev.zip
curl --insecure -sSLo /tmp/dev.tar.gz ${HTTP_PREFIX}github.com/midoks/mdserver-web/archive/refs/heads/dev.tar.gz
cd /tmp && tar -zxvf /tmp/dev.tar.gz
$CP_CMD -rf /tmp/mdserver-web-dev/* /www/server/mdserver-web
rm -rf /tmp/dev.tar.gz
rm -rf /tmp/mdserver-web-dev
echo "update mdserver-web dev code end"
#pip uninstall public
echo "use system version: ${OSNAME}"
cd /www/server/mdserver-web && bash scripts/update/${OSNAME}.sh