From d7337239f5efe4f1e4600d7919ccc0690ac6842a Mon Sep 17 00:00:00 2001 From: hiCasper Date: Sat, 10 Dec 2022 14:40:06 +0800 Subject: [PATCH] Optimize acme.sh install --- scripts/install.sh | 37 ++++++++++++++++++++++++++----------- scripts/install/alma.sh | 5 ----- scripts/install/amazon.sh | 7 ------- scripts/install/arch.sh | 5 ----- scripts/install/centos.sh | 6 ------ scripts/install/debian.sh | 14 ++++++++------ scripts/install/fedora.sh | 6 ------ scripts/install/freebsd.sh | 6 ------ scripts/install/opensuse.sh | 4 ---- scripts/install/rocky.sh | 5 ----- scripts/install/ubuntu.sh | 4 ---- 11 files changed, 34 insertions(+), 65 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index 146696aa8..3b484f39d 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -29,27 +29,27 @@ elif grep -Eq "FreeBSD" /etc/*-release; then OSNAME='freebsd' elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then OSNAME='rhel' - yum install -y wget zip unzip + yum install -y wget curl zip unzip tar elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then OSNAME='fedora' - yum install -y wget zip unzip + yum install -y wget curl zip unzip tar elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then OSNAME='rhel' - yum install -y wget zip unzip + yum install -y wget curl zip unzip tar elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then OSNAME='rhel' - yum install -y wget zip unzip + yum install -y wget curl zip unzip tar elif grep -Eqi "Amazon Linux" /etc/issue || grep -Eq "Amazon Linux" /etc/*-release; then OSNAME='amazon' - yum install -y wget zip unzip + yum install -y wget curl zip unzip tar elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then OSNAME='debian' apt update -y apt install -y devscripts - apt install -y wget zip unzip + apt install -y wget curl zip unzip tar elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then OSNAME='debian' - apt install -y wget zip unzip + apt install -y wget curl zip unzip tar else OSNAME='unknow' fi @@ -69,12 +69,11 @@ 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 + cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") - cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") + if [ ! -d /www/server/mdserver-web ];then if [ ! -z "$cn" ];then curl -sSLo /tmp/master.zip https://gitee.com/midoks/mdserver-web/repository/archive/master.zip else @@ -86,12 +85,28 @@ if [ $OSNAME != "macos" ];then rm -rf /tmp/master.zip rm -rf /tmp/mdserver-web-master fi + + # install acme.sh + if [ ! -d /root/.acme.sh ];then + if [ ! -z "$cn" ];then + curl -sSL -o /tmp/acme.tar.gz https://ghproxy.com/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 + cd - + fi + + if [ ! -d /root/.acme.sh ];then + curl https://get.acme.sh | sh + fi + fi fi + + echo "use system version: ${OSNAME}" cd /www/server/mdserver-web && bash scripts/install/${OSNAME}.sh - cd /www/server/mdserver-web && bash cli.sh start isStart=`ps -ef|grep 'gunicorn -c setting.py app:app' |grep -v grep|awk '{print $2}'` n=0 diff --git a/scripts/install/alma.sh b/scripts/install/alma.sh index d164588f5..6a414519e 100755 --- a/scripts/install/alma.sh +++ b/scripts/install/alma.sh @@ -14,11 +14,6 @@ dnf install -y python-devel dnf install -y crontabs dnf install -y mysql-devel -#https need - -if [ ! -d /root/.acme.sh ];then - curl https://get.acme.sh | sh -fi if [ -f /usr/sbin/iptables ];then diff --git a/scripts/install/amazon.sh b/scripts/install/amazon.sh index d6202acfd..ae6cfce3c 100755 --- a/scripts/install/amazon.sh +++ b/scripts/install/amazon.sh @@ -21,13 +21,6 @@ yum install -y curl-devel libmcrypt libmcrypt-devel yum install -y mysql-devel yum install -y expect - - -#https need -if [ ! -d /root/.acme.sh ];then - curl https://get.acme.sh | sh -fi - if [ -f /usr/sbin/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT diff --git a/scripts/install/arch.sh b/scripts/install/arch.sh index 2a4e36598..35a084a2e 100644 --- a/scripts/install/arch.sh +++ b/scripts/install/arch.sh @@ -54,11 +54,6 @@ echo y | pacman -Syu icu hwclock --systohc -#https need -if [ ! -d /root/.acme.sh ];then - curl https://get.acme.sh | sh -fi - if [ -f /usr/sbin/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT diff --git a/scripts/install/centos.sh b/scripts/install/centos.sh index 02d988895..b27276a2e 100755 --- a/scripts/install/centos.sh +++ b/scripts/install/centos.sh @@ -23,12 +23,6 @@ yum install -y mysql-devel yum install -y expect - -#https need -if [ ! -d /root/.acme.sh ];then - curl https://get.acme.sh | sh -fi - if [ -f /usr/sbin/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT diff --git a/scripts/install/debian.sh b/scripts/install/debian.sh index 5b1493cf0..dd8f77aeb 100644 --- a/scripts/install/debian.sh +++ b/scripts/install/debian.sh @@ -12,6 +12,12 @@ elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then fi VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` +cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") +NTPHOST='time.nist.gov' +if [ ! -z "$cn" ];then + NTPHOST='ntp1.aliyun.com' +fi + ln -sf /bin/bash /bin/sh __GET_BIT=`getconf LONG_BIT` @@ -23,18 +29,14 @@ fi # synchronize time first apt-get install ntpdate -y -ntpdate time.nist.gov | logger -t NTP +ntpdate $NTPHOST | logger -t NTP apt-get update -y -apt install -y wget curl lsof unzip cron expect locate +apt install -y wget curl lsof unzip tar cron expect locate apt install -y python3-pip python3-dev python3-venv locale-gen en_US.UTF-8 localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 -if [ ! -d /root/.acme.sh ];then - curl https://get.acme.sh | sh -fi - if [ -f /usr/sbin/ufw ];then ufw allow 22/tcp diff --git a/scripts/install/fedora.sh b/scripts/install/fedora.sh index a7f8d4441..d885e45d4 100644 --- a/scripts/install/fedora.sh +++ b/scripts/install/fedora.sh @@ -17,12 +17,6 @@ yum install -y wget curl lsof unzip yum install -y expect dnf install crontabs -y -#https need - -if [ ! -d /root/.acme.sh ];then - curl https://get.acme.sh | sh -fi - if [ -f /usr/sbin/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT diff --git a/scripts/install/freebsd.sh b/scripts/install/freebsd.sh index 51639b334..9e1769a52 100644 --- a/scripts/install/freebsd.sh +++ b/scripts/install/freebsd.sh @@ -37,14 +37,8 @@ pkg install -y harfbuzz # pkg install -y py38-cffi - pkg autoremove -y -#https need -if [ ! -d /root/.acme.sh ];then - curl https://get.acme.sh | sh -fi - if [ -f /usr/sbin/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT diff --git a/scripts/install/opensuse.sh b/scripts/install/opensuse.sh index d537c5a9b..c6276154b 100644 --- a/scripts/install/opensuse.sh +++ b/scripts/install/opensuse.sh @@ -51,10 +51,6 @@ zypper install -y libXpm-devel zypper install -y freetype2-devel # zypper install -y php-config -#https need -if [ ! -d /root/.acme.sh ];then - curl https://get.acme.sh | sh -fi if [ -f /usr/sbin/iptables ];then diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index 8e913e7cc..2242b2dfc 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -18,11 +18,6 @@ yum install -y python3-devel yum install -y crontabs yum install -y expect yum install -y curl curl-devel libcurl libcurl-devel -#https need - -if [ ! -d /root/.acme.sh ];then - curl https://get.acme.sh | sh -fi if [ -f /usr/sbin/iptables ];then diff --git a/scripts/install/ubuntu.sh b/scripts/install/ubuntu.sh index 00cb0d47a..e24f13b71 100644 --- a/scripts/install/ubuntu.sh +++ b/scripts/install/ubuntu.sh @@ -20,10 +20,6 @@ apt install -y expect apt install -y cron -if [ ! -d /root/.acme.sh ];then - curl https://get.acme.sh | sh -fi - apt install -y locate locale-gen en_US.UTF-8 localedef -v -c -i en_US -f UTF-8 en_US.UTF-8