|
|
|
@ -33,93 +33,6 @@ LOG_FILE=/var/log/mw-install.log |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if [ -f /etc/motd ];then |
|
|
|
|
echo "welcome to mdserver-web panel" > /etc/motd |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
startTime=`date +%s` |
|
|
|
|
|
|
|
|
|
_os=`uname` |
|
|
|
|
echo "use system: ${_os}" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ ${_os} == "Darwin" ]; then |
|
|
|
|
OSNAME='macos' |
|
|
|
|
elif grep -Eq "openSUSE" /etc/*-release; then |
|
|
|
|
OSNAME='opensuse' |
|
|
|
|
zypper refresh |
|
|
|
|
zypper install -y wget curl zip unzip unrar rar |
|
|
|
|
elif grep -Eq "FreeBSD" /etc/*-release; then |
|
|
|
|
OSNAME='freebsd' |
|
|
|
|
pkg install -y wget curl zip unzip unrar rar |
|
|
|
|
elif grep -Eqi "EulerOS" /etc/*-release || grep -Eqi "openEuler" /etc/*-release; then |
|
|
|
|
OSNAME='euler' |
|
|
|
|
yum install -y wget curl zip unzip tar crontabs |
|
|
|
|
elif grep -Eqi "CentOS" /etc/issue || grep -Eqi "CentOS" /etc/*-release; then |
|
|
|
|
OSNAME='rhel' |
|
|
|
|
yum install -y wget zip unzip tar |
|
|
|
|
elif grep -Eqi "Fedora" /etc/issue || grep -Eqi "Fedora" /etc/*-release; then |
|
|
|
|
OSNAME='rhel' |
|
|
|
|
yum install -y wget zip unzip tar |
|
|
|
|
elif grep -Eqi "Rocky" /etc/issue || grep -Eqi "Rocky" /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 "AlmaLinux" /etc/issue || grep -Eqi "AlmaLinux" /etc/*-release; then |
|
|
|
|
OSNAME='rhel' |
|
|
|
|
yum install -y wget zip unzip tar |
|
|
|
|
elif grep -Eqi "Amazon Linux" /etc/issue || grep -Eqi "Amazon Linux" /etc/*-release; then |
|
|
|
|
OSNAME='amazon' |
|
|
|
|
yum install -y wget zip unzip tar |
|
|
|
|
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eqi "Ubuntu" /etc/*-release; then |
|
|
|
|
OSNAME='ubuntu' |
|
|
|
|
apt install -y wget zip unzip tar |
|
|
|
|
elif grep -Eqi "Debian" /etc/issue || grep -Eqi "Debian" /etc/*-release; then |
|
|
|
|
OSNAME='debian' |
|
|
|
|
apt update -y |
|
|
|
|
apt install -y devscripts |
|
|
|
|
apt install -y wget zip unzip tar |
|
|
|
|
elif grep -Eqi "Alpine" /etc/issue || grep -Eqi "Alpine" /etc/*-release; then |
|
|
|
|
OSNAME='alpine' |
|
|
|
|
apk update |
|
|
|
|
apk add devscripts -force-broken-world |
|
|
|
|
apk add curl wget zip unzip tar -force-broken-world |
|
|
|
|
else |
|
|
|
|
OSNAME='unknow' |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
if [ "$EUID" -ne 0 ] && [ "$OSNAME" != "macos" ];then |
|
|
|
|
echo "Please run as root!" |
|
|
|
|
exit |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
ARCH=$(uname -m) |
|
|
|
|
|
|
|
|
|
SYSTEM_NAME=$(cat $LinuxRelease | grep -E "^NAME=" | awk -F '=' '{print$2}' | sed "s/[\'\"]//g") |
|
|
|
|
SYSTEM_VERSION_NUMBER=$(cat /etc/os-release | grep -E "VERSION_ID=" | awk -F '=' '{print$2}' | sed "s/[\'\"]//g") |
|
|
|
|
SOURCE_BRANCH=${SYSTEM_JUDGMENT,,} |
|
|
|
|
|
|
|
|
|
# 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 "OSNAME:${OSNAME}" |
|
|
|
|
|
|
|
|
|
declare -A PROXY_URL |
|
|
|
|
PROXY_URL["gh-proxy\.com"]="https://gh-proxy.com" |
|
|
|
|
|
|
|
|
@ -210,6 +123,93 @@ function ChooseProxyURL(){ |
|
|
|
|
|
|
|
|
|
ChooseProxyURL |
|
|
|
|
|
|
|
|
|
if [ -f /etc/motd ];then |
|
|
|
|
echo "welcome to mdserver-web panel" > /etc/motd |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
startTime=`date +%s` |
|
|
|
|
|
|
|
|
|
_os=`uname` |
|
|
|
|
echo "use system: ${_os}" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ ${_os} == "Darwin" ]; then |
|
|
|
|
OSNAME='macos' |
|
|
|
|
elif grep -Eq "openSUSE" /etc/*-release; then |
|
|
|
|
OSNAME='opensuse' |
|
|
|
|
zypper refresh |
|
|
|
|
zypper install -y wget curl zip unzip unrar rar |
|
|
|
|
elif grep -Eq "FreeBSD" /etc/*-release; then |
|
|
|
|
OSNAME='freebsd' |
|
|
|
|
pkg install -y wget curl zip unzip unrar rar |
|
|
|
|
elif grep -Eqi "EulerOS" /etc/*-release || grep -Eqi "openEuler" /etc/*-release; then |
|
|
|
|
OSNAME='euler' |
|
|
|
|
yum install -y wget curl zip unzip tar crontabs |
|
|
|
|
elif grep -Eqi "CentOS" /etc/issue || grep -Eqi "CentOS" /etc/*-release; then |
|
|
|
|
OSNAME='rhel' |
|
|
|
|
yum install -y wget zip unzip tar |
|
|
|
|
elif grep -Eqi "Fedora" /etc/issue || grep -Eqi "Fedora" /etc/*-release; then |
|
|
|
|
OSNAME='rhel' |
|
|
|
|
yum install -y wget zip unzip tar |
|
|
|
|
elif grep -Eqi "Rocky" /etc/issue || grep -Eqi "Rocky" /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 "AlmaLinux" /etc/issue || grep -Eqi "AlmaLinux" /etc/*-release; then |
|
|
|
|
OSNAME='rhel' |
|
|
|
|
yum install -y wget zip unzip tar |
|
|
|
|
elif grep -Eqi "Amazon Linux" /etc/issue || grep -Eqi "Amazon Linux" /etc/*-release; then |
|
|
|
|
OSNAME='amazon' |
|
|
|
|
yum install -y wget zip unzip tar |
|
|
|
|
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eqi "Ubuntu" /etc/*-release; then |
|
|
|
|
OSNAME='ubuntu' |
|
|
|
|
apt install -y wget zip unzip tar |
|
|
|
|
elif grep -Eqi "Debian" /etc/issue || grep -Eqi "Debian" /etc/*-release; then |
|
|
|
|
OSNAME='debian' |
|
|
|
|
apt update -y |
|
|
|
|
apt install -y devscripts |
|
|
|
|
apt install -y wget zip unzip tar |
|
|
|
|
elif grep -Eqi "Alpine" /etc/issue || grep -Eqi "Alpine" /etc/*-release; then |
|
|
|
|
OSNAME='alpine' |
|
|
|
|
apk update |
|
|
|
|
apk add devscripts -force-broken-world |
|
|
|
|
apk add curl wget zip unzip tar -force-broken-world |
|
|
|
|
else |
|
|
|
|
OSNAME='unknow' |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
if [ "$EUID" -ne 0 ] && [ "$OSNAME" != "macos" ];then |
|
|
|
|
echo "Please run as root!" |
|
|
|
|
exit |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
ARCH=$(uname -m) |
|
|
|
|
|
|
|
|
|
SYSTEM_NAME=$(cat $LinuxRelease | grep -E "^NAME=" | awk -F '=' '{print$2}' | sed "s/[\'\"]//g") |
|
|
|
|
SYSTEM_VERSION_NUMBER=$(cat /etc/os-release | grep -E "VERSION_ID=" | awk -F '=' '{print$2}' | sed "s/[\'\"]//g") |
|
|
|
|
SOURCE_BRANCH=${SYSTEM_JUDGMENT,,} |
|
|
|
|
|
|
|
|
|
# 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 "OSNAME:${OSNAME}" |
|
|
|
|
|
|
|
|
|
if [ $OSNAME != "macos" ];then |
|
|
|
|
|
|
|
|
|
if id www &> /dev/null ;then |
|
|
|
|