diff --git a/scripts/install.sh b/scripts/install.sh index 4e34b67e6..67a803229 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -20,37 +20,42 @@ if [ "$EUID" -ne 0 ] exit fi +# macOS if [ ${_os} == "Darwin" ]; then OSNAME='macos' +# SUSE Linux elif grep -Eq "openSUSE" /etc/*-release; then OSNAME='opensuse' zypper refresh zypper install cron wget curl zip unzip +# FreeBSD elif grep -Eq "FreeBSD" /etc/*-release; then OSNAME='freebsd' -elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/redhat-release; then - OSNAME='rhel' - yum install -y wget curl zip unzip tar crontabs -elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then - OSNAME='fedora' - yum install -y wget curl zip unzip tar crontabs -elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/redhat-release; then - OSNAME='rhel' - yum install -y wget curl zip unzip tar crontabs -elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/redhat-release; then +# Arch Linux +elif [ -f /etc/arch-release ]; then + OSNAME='arch' + pacman -Syu --noconfirm + pacman -S --noconfirm curl cronie +# Enterprise Linux +elif [ -f /etc/redhat-release ]; then + if grep -Eq "AlmaLinux" /etc/redhat-release ; then OSNAME='alma'; + elif grep -Eq "CentOS" /etc/redhat-release ; then OSNAME='centos'; + elif grep -Eq "Rocky" /etc/redhat-release ; then OSNAME='rocky'; + elif grep -Eq "Red Hat" /etc/redhat-release ; then OSNAME='rhel'; + fi OSNAME='rhel' + if grep -Eq "Amazon Linux" /etc/redhat-release ; then OSNAME='amazon'; fi + if grep -Eq "Fedora" /etc/redhat-release ; then OSNAME='fedora'; fi yum install -y wget curl zip unzip tar crontabs -elif grep -Eqi "Amazon Linux" /etc/issue || grep -Eq "Amazon Linux" /etc/*-release; then - OSNAME='amazon' - yum install -y wget curl zip unzip tar crontabs -elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/os-release; then +# Debian / Ubuntu +elif [ -f /etc/lsb-release ]; then OSNAME='debian' + if grep -Eq "Ubuntu" /etc/os-release; then OSNAME='ubuntu'; + elif grep -Eq "Debian" /etc/os-release; then OSNAME='debian'; + fi apt update -y apt install -y wget curl zip unzip tar cron -elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/os-release; then - OSNAME='ubuntu' - apt update -y - apt install -y wget curl zip unzip tar cron +# Others else OSNAME='unknow' fi diff --git a/scripts/install_dev.sh b/scripts/install_dev.sh index 67a8fb20f..3184d8b9f 100755 --- a/scripts/install_dev.sh +++ b/scripts/install_dev.sh @@ -25,36 +25,42 @@ if [ "$EUID" -ne 0 ] fi +# macOS if [ ${_os} == "Darwin" ]; then OSNAME='macos' +# SUSE Linux elif grep -Eq "openSUSE" /etc/*-release; then OSNAME='opensuse' zypper refresh + zypper install cron wget curl zip unzip +# FreeBSD 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 -elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then - OSNAME='fedora' - yum install -y wget zip unzip -elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then - OSNAME='rhel' - yum install -y wget zip unzip -elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then +# Arch Linux +elif [ -f /etc/arch-release ]; then + OSNAME='arch' + pacman -Syu --noconfirm + pacman -S --noconfirm curl cronie +# Enterprise Linux +elif [ -f /etc/redhat-release ]; then + if grep -Eq "AlmaLinux" /etc/redhat-release ; then OSNAME='alma'; + elif grep -Eq "CentOS" /etc/redhat-release ; then OSNAME='centos'; + elif grep -Eq "Rocky" /etc/redhat-release ; then OSNAME='rocky'; + elif grep -Eq "Red Hat" /etc/redhat-release ; then OSNAME='rhel'; + fi OSNAME='rhel' - yum install -y wget zip unzip -elif grep -Eqi "Amazon Linux" /etc/issue || grep -Eq "Amazon Linux" /etc/*-release; then - OSNAME='amazon' - yum install -y wget zip unzip -elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then + if grep -Eq "Amazon Linux" /etc/redhat-release ; then OSNAME='amazon'; fi + if grep -Eq "Fedora" /etc/redhat-release ; then OSNAME='fedora'; fi + yum install -y wget curl zip unzip tar crontabs +# Debian / Ubuntu +elif [ -f /etc/lsb-release ]; then OSNAME='debian' + if grep -Eq "Ubuntu" /etc/os-release; then OSNAME='ubuntu'; + elif grep -Eq "Debian" /etc/os-release; then OSNAME='debian'; + fi apt update -y - apt install -y devscripts - apt install -y wget zip unzip -elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then - OSNAME='ubuntu' - apt install -y wget zip unzip + apt install -y wget curl zip unzip tar cron +# Others else OSNAME='unknow' fi diff --git a/scripts/update.sh b/scripts/update.sh index c41ee6f49..f15e610ff 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -14,37 +14,42 @@ if [ "$EUID" -ne 0 ] exit fi - +# macOS if [ ${_os} == "Darwin" ]; then OSNAME='macos' +# SUSE Linux elif grep -Eq "openSUSE" /etc/*-release; then OSNAME='opensuse' zypper refresh + zypper install cron wget curl zip unzip +# FreeBSD elif grep -Eq "FreeBSD" /etc/*-release; then OSNAME='freebsd' -elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then - OSNAME='centos' - yum install -y wget zip unzip -elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then - OSNAME='fedora' - yum install -y wget zip unzip -elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then - OSNAME='rocky' - yum install -y wget zip unzip -elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then - OSNAME='alma' - yum install -y wget zip unzip -elif grep -Eqi "Amazon Linux" /etc/issue || grep -Eq "Amazon Linux" /etc/*-release; then - OSNAME='amazon' - yum install -y wget zip unzip -elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then +# Arch Linux +elif [ -f /etc/arch-release ]; then + OSNAME='arch' + pacman -Syu --noconfirm + pacman -S --noconfirm curl cronie +# Enterprise Linux +elif [ -f /etc/redhat-release ]; then + if grep -Eq "AlmaLinux" /etc/redhat-release ; then OSNAME='alma'; + elif grep -Eq "CentOS" /etc/redhat-release ; then OSNAME='centos'; + elif grep -Eq "Rocky" /etc/redhat-release ; then OSNAME='rocky'; + elif grep -Eq "Red Hat" /etc/redhat-release ; then OSNAME='rhel'; + fi + OSNAME='rhel' + if grep -Eq "Amazon Linux" /etc/redhat-release ; then OSNAME='amazon'; fi + if grep -Eq "Fedora" /etc/redhat-release ; then OSNAME='fedora'; fi + yum install -y wget curl zip unzip tar crontabs +# Debian / Ubuntu +elif [ -f /etc/lsb-release ]; then OSNAME='debian' - apt install -y wget zip unzip -elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then - OSNAME='ubuntu' - apt install -y wget zip unzip -elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then - OSNAME='raspbian' + if grep -Eq "Ubuntu" /etc/os-release; then OSNAME='ubuntu'; + elif grep -Eq "Debian" /etc/os-release; then OSNAME='debian'; + fi + apt update -y + apt install -y wget curl zip unzip tar cron +# Others else OSNAME='unknow' fi diff --git a/scripts/update/rhel.sh b/scripts/update/rhel.sh new file mode 100644 index 000000000..22f494e2a --- /dev/null +++ b/scripts/update/rhel.sh @@ -0,0 +1,54 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH +export LANG=en_US.UTF-8 + +sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config + +VERSION_ID=`grep -o -i 'release *[[:digit:]]\+\.*' /etc/redhat-release | grep -o '[[:digit:]]\+' ` + +if [ $VERSION_ID == '7' ]; then + yum install -y curl-devel libmcrypt libmcrypt-devel python3-devel +elif [ $VERSION_ID == '8' ]; then + dnf install -y curl-devel libmcrypt libmcrypt-devel python36-devel +fi + +cd /www/server/mdserver-web/scripts && bash lib.sh +chmod 755 /www/server/mdserver-web/data + +echo -e "stop mw" +isStart=`ps -ef|grep 'gunicorn -c setting.py app:app' |grep -v grep|awk '{print $2}'` + +port=7200 +if [ -f /www/server/mdserver-web/data/port.pl ]; then + port=$(cat /www/server/mdserver-web/data/port.pl) +fi + +n=0 +while [[ "$isStart" != "" ]]; +do + echo -e ".\c" + sleep 0.5 + isStart=$(lsof -n -P -i:$port|grep LISTEN|grep -v grep|awk '{print $2}'|xargs) + let n+=1 + if [ $n -gt 15 ];then + break; + fi +done + + +echo -e "start mw" +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 +while [[ ! -f /etc/rc.d/init.d/mw ]]; +do + echo -e ".\c" + sleep 1 + let n+=1 + if [ $n -gt 20 ];then + echo -e "start mw fail" + exit 1 + fi +done +echo -e "start mw success" \ No newline at end of file diff --git a/scripts/update_dev.sh b/scripts/update_dev.sh index 0fa062b31..7464f6503 100755 --- a/scripts/update_dev.sh +++ b/scripts/update_dev.sh @@ -14,41 +14,47 @@ if [ "$EUID" -ne 0 ] exit fi - +# macOS if [ ${_os} == "Darwin" ]; then OSNAME='macos' +# SUSE Linux elif grep -Eq "openSUSE" /etc/*-release; then OSNAME='opensuse' zypper refresh + zypper install cron wget curl zip unzip +# FreeBSD elif grep -Eq "FreeBSD" /etc/*-release; then OSNAME='freebsd' -elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then - OSNAME='centos' - yum install -y wget zip unzip -elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then - OSNAME='fedora' - yum install -y wget zip unzip -elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then - OSNAME='rocky' - yum install -y wget zip unzip -elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then - OSNAME='alma' - yum install -y wget zip unzip -elif grep -Eqi "Amazon Linux" /etc/issue || grep -Eq "Amazon Linux" /etc/*-release; then - OSNAME='amazon' - yum install -y wget zip unzip -elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then +# Arch Linux +elif [ -f /etc/arch-release ]; then + OSNAME='arch' + pacman -Syu --noconfirm + pacman -S --noconfirm curl cronie +# Enterprise Linux +elif [ -f /etc/redhat-release ]; then + if grep -Eq "AlmaLinux" /etc/redhat-release ; then OSNAME='alma'; + elif grep -Eq "CentOS" /etc/redhat-release ; then OSNAME='centos'; + elif grep -Eq "Rocky" /etc/redhat-release ; then OSNAME='rocky'; + elif grep -Eq "Red Hat" /etc/redhat-release ; then OSNAME='rhel'; + fi + OSNAME='rhel' + if grep -Eq "Amazon Linux" /etc/redhat-release ; then OSNAME='amazon'; fi + if grep -Eq "Fedora" /etc/redhat-release ; then OSNAME='fedora'; fi + yum install -y wget curl zip unzip tar crontabs +# Debian / Ubuntu +elif [ -f /etc/lsb-release ]; then OSNAME='debian' - apt install -y wget zip unzip -elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then - OSNAME='ubuntu' - apt install -y wget zip unzip -elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then - OSNAME='raspbian' + if grep -Eq "Ubuntu" /etc/os-release; then OSNAME='ubuntu'; + elif grep -Eq "Debian" /etc/os-release; then OSNAME='debian'; + fi + apt update -y + apt install -y wget curl zip unzip tar cron +# Others else OSNAME='unknow' fi + cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") if [ ! -z "$cn" ];then curl -sSLo /tmp/dev.zip https://gitee.com/midoks/mdserver-web/repository/archive/dev.zip