Improve OS detection

pull/302/head
hiCasper 2 years ago
parent c21c54198c
commit aa8e9f173b
  1. 41
      scripts/install.sh
  2. 46
      scripts/install_dev.sh
  3. 51
      scripts/update.sh
  4. 54
      scripts/update/rhel.sh
  5. 52
      scripts/update_dev.sh

@ -20,37 +20,42 @@ if [ "$EUID" -ne 0 ]
exit exit
fi fi
# macOS
if [ ${_os} == "Darwin" ]; then if [ ${_os} == "Darwin" ]; then
OSNAME='macos' OSNAME='macos'
# SUSE Linux
elif grep -Eq "openSUSE" /etc/*-release; then elif grep -Eq "openSUSE" /etc/*-release; then
OSNAME='opensuse' OSNAME='opensuse'
zypper refresh zypper refresh
zypper install cron wget curl zip unzip zypper install cron wget curl zip unzip
# FreeBSD
elif grep -Eq "FreeBSD" /etc/*-release; then elif grep -Eq "FreeBSD" /etc/*-release; then
OSNAME='freebsd' OSNAME='freebsd'
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/redhat-release; then # Arch Linux
OSNAME='rhel' elif [ -f /etc/arch-release ]; then
yum install -y wget curl zip unzip tar crontabs OSNAME='arch'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then pacman -Syu --noconfirm
OSNAME='fedora' pacman -S --noconfirm curl cronie
yum install -y wget curl zip unzip tar crontabs # Enterprise Linux
elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/redhat-release; then elif [ -f /etc/redhat-release ]; then
OSNAME='rhel' if grep -Eq "AlmaLinux" /etc/redhat-release ; then OSNAME='alma';
yum install -y wget curl zip unzip tar crontabs elif grep -Eq "CentOS" /etc/redhat-release ; then OSNAME='centos';
elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/redhat-release; then elif grep -Eq "Rocky" /etc/redhat-release ; then OSNAME='rocky';
elif grep -Eq "Red Hat" /etc/redhat-release ; then OSNAME='rhel';
fi
OSNAME='rhel' 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 yum install -y wget curl zip unzip tar crontabs
elif grep -Eqi "Amazon Linux" /etc/issue || grep -Eq "Amazon Linux" /etc/*-release; then # Debian / Ubuntu
OSNAME='amazon' elif [ -f /etc/lsb-release ]; then
yum install -y wget curl zip unzip tar crontabs
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/os-release; then
OSNAME='debian' 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 update -y
apt install -y wget curl zip unzip tar cron apt install -y wget curl zip unzip tar cron
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/os-release; then # Others
OSNAME='ubuntu'
apt update -y
apt install -y wget curl zip unzip tar cron
else else
OSNAME='unknow' OSNAME='unknow'
fi fi

@ -25,36 +25,42 @@ if [ "$EUID" -ne 0 ]
fi fi
# macOS
if [ ${_os} == "Darwin" ]; then if [ ${_os} == "Darwin" ]; then
OSNAME='macos' OSNAME='macos'
# SUSE Linux
elif grep -Eq "openSUSE" /etc/*-release; then elif grep -Eq "openSUSE" /etc/*-release; then
OSNAME='opensuse' OSNAME='opensuse'
zypper refresh zypper refresh
zypper install cron wget curl zip unzip
# FreeBSD
elif grep -Eq "FreeBSD" /etc/*-release; then elif grep -Eq "FreeBSD" /etc/*-release; then
OSNAME='freebsd' OSNAME='freebsd'
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then # Arch Linux
OSNAME='rhel' elif [ -f /etc/arch-release ]; then
yum install -y wget zip unzip OSNAME='arch'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then pacman -Syu --noconfirm
OSNAME='fedora' pacman -S --noconfirm curl cronie
yum install -y wget zip unzip # Enterprise Linux
elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then elif [ -f /etc/redhat-release ]; then
OSNAME='rhel' if grep -Eq "AlmaLinux" /etc/redhat-release ; then OSNAME='alma';
yum install -y wget zip unzip elif grep -Eq "CentOS" /etc/redhat-release ; then OSNAME='centos';
elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then elif grep -Eq "Rocky" /etc/redhat-release ; then OSNAME='rocky';
elif grep -Eq "Red Hat" /etc/redhat-release ; then OSNAME='rhel';
fi
OSNAME='rhel' OSNAME='rhel'
yum install -y wget zip unzip if grep -Eq "Amazon Linux" /etc/redhat-release ; then OSNAME='amazon'; fi
elif grep -Eqi "Amazon Linux" /etc/issue || grep -Eq "Amazon Linux" /etc/*-release; then if grep -Eq "Fedora" /etc/redhat-release ; then OSNAME='fedora'; fi
OSNAME='amazon' yum install -y wget curl zip unzip tar crontabs
yum install -y wget zip unzip # Debian / Ubuntu
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then elif [ -f /etc/lsb-release ]; then
OSNAME='debian' 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 update -y
apt install -y devscripts apt install -y wget curl zip unzip tar cron
apt install -y wget zip unzip # Others
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
OSNAME='ubuntu'
apt install -y wget zip unzip
else else
OSNAME='unknow' OSNAME='unknow'
fi fi

@ -14,37 +14,42 @@ if [ "$EUID" -ne 0 ]
exit exit
fi fi
# macOS
if [ ${_os} == "Darwin" ]; then if [ ${_os} == "Darwin" ]; then
OSNAME='macos' OSNAME='macos'
# SUSE Linux
elif grep -Eq "openSUSE" /etc/*-release; then elif grep -Eq "openSUSE" /etc/*-release; then
OSNAME='opensuse' OSNAME='opensuse'
zypper refresh zypper refresh
zypper install cron wget curl zip unzip
# FreeBSD
elif grep -Eq "FreeBSD" /etc/*-release; then elif grep -Eq "FreeBSD" /etc/*-release; then
OSNAME='freebsd' OSNAME='freebsd'
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then # Arch Linux
OSNAME='centos' elif [ -f /etc/arch-release ]; then
yum install -y wget zip unzip OSNAME='arch'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then pacman -Syu --noconfirm
OSNAME='fedora' pacman -S --noconfirm curl cronie
yum install -y wget zip unzip # Enterprise Linux
elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then elif [ -f /etc/redhat-release ]; then
OSNAME='rocky' if grep -Eq "AlmaLinux" /etc/redhat-release ; then OSNAME='alma';
yum install -y wget zip unzip elif grep -Eq "CentOS" /etc/redhat-release ; then OSNAME='centos';
elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then elif grep -Eq "Rocky" /etc/redhat-release ; then OSNAME='rocky';
OSNAME='alma' elif grep -Eq "Red Hat" /etc/redhat-release ; then OSNAME='rhel';
yum install -y wget zip unzip fi
elif grep -Eqi "Amazon Linux" /etc/issue || grep -Eq "Amazon Linux" /etc/*-release; then OSNAME='rhel'
OSNAME='amazon' if grep -Eq "Amazon Linux" /etc/redhat-release ; then OSNAME='amazon'; fi
yum install -y wget zip unzip if grep -Eq "Fedora" /etc/redhat-release ; then OSNAME='fedora'; fi
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then yum install -y wget curl zip unzip tar crontabs
# Debian / Ubuntu
elif [ -f /etc/lsb-release ]; then
OSNAME='debian' OSNAME='debian'
apt install -y wget zip unzip if grep -Eq "Ubuntu" /etc/os-release; then OSNAME='ubuntu';
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then elif grep -Eq "Debian" /etc/os-release; then OSNAME='debian';
OSNAME='ubuntu' fi
apt install -y wget zip unzip apt update -y
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then apt install -y wget curl zip unzip tar cron
OSNAME='raspbian' # Others
else else
OSNAME='unknow' OSNAME='unknow'
fi fi

@ -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"

@ -14,41 +14,47 @@ if [ "$EUID" -ne 0 ]
exit exit
fi fi
# macOS
if [ ${_os} == "Darwin" ]; then if [ ${_os} == "Darwin" ]; then
OSNAME='macos' OSNAME='macos'
# SUSE Linux
elif grep -Eq "openSUSE" /etc/*-release; then elif grep -Eq "openSUSE" /etc/*-release; then
OSNAME='opensuse' OSNAME='opensuse'
zypper refresh zypper refresh
zypper install cron wget curl zip unzip
# FreeBSD
elif grep -Eq "FreeBSD" /etc/*-release; then elif grep -Eq "FreeBSD" /etc/*-release; then
OSNAME='freebsd' OSNAME='freebsd'
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then # Arch Linux
OSNAME='centos' elif [ -f /etc/arch-release ]; then
yum install -y wget zip unzip OSNAME='arch'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then pacman -Syu --noconfirm
OSNAME='fedora' pacman -S --noconfirm curl cronie
yum install -y wget zip unzip # Enterprise Linux
elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then elif [ -f /etc/redhat-release ]; then
OSNAME='rocky' if grep -Eq "AlmaLinux" /etc/redhat-release ; then OSNAME='alma';
yum install -y wget zip unzip elif grep -Eq "CentOS" /etc/redhat-release ; then OSNAME='centos';
elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then elif grep -Eq "Rocky" /etc/redhat-release ; then OSNAME='rocky';
OSNAME='alma' elif grep -Eq "Red Hat" /etc/redhat-release ; then OSNAME='rhel';
yum install -y wget zip unzip fi
elif grep -Eqi "Amazon Linux" /etc/issue || grep -Eq "Amazon Linux" /etc/*-release; then OSNAME='rhel'
OSNAME='amazon' if grep -Eq "Amazon Linux" /etc/redhat-release ; then OSNAME='amazon'; fi
yum install -y wget zip unzip if grep -Eq "Fedora" /etc/redhat-release ; then OSNAME='fedora'; fi
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then yum install -y wget curl zip unzip tar crontabs
# Debian / Ubuntu
elif [ -f /etc/lsb-release ]; then
OSNAME='debian' OSNAME='debian'
apt install -y wget zip unzip if grep -Eq "Ubuntu" /etc/os-release; then OSNAME='ubuntu';
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then elif grep -Eq "Debian" /etc/os-release; then OSNAME='debian';
OSNAME='ubuntu' fi
apt install -y wget zip unzip apt update -y
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then apt install -y wget curl zip unzip tar cron
OSNAME='raspbian' # Others
else else
OSNAME='unknow' OSNAME='unknow'
fi fi
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 [ ! -z "$cn" ];then if [ ! -z "$cn" ];then
curl -sSLo /tmp/dev.zip https://gitee.com/midoks/mdserver-web/repository/archive/dev.zip curl -sSLo /tmp/dev.zip https://gitee.com/midoks/mdserver-web/repository/archive/dev.zip

Loading…
Cancel
Save