diff --git a/README.md b/README.md index b759664be..ae6f83e80 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,11 @@ ### 自动安装 ``` curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh | sh -``` \ No newline at end of file +``` + +### 更新 + +``` +curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh | sh +``` + diff --git a/scripts/install_centos.sh b/scripts/install_centos.sh index 9e23bde96..e6fddec58 100755 --- a/scripts/install_centos.sh +++ b/scripts/install_centos.sh @@ -9,83 +9,20 @@ mkdir -p /www/wwwlogs mkdir -p /www/backup/database mkdir -p /www/backup/site +wget -O /tmp/master.zip https://codeload.github.com/midoks/mdserver-web/zip/master +cd /tmp && unzip /tmp/master.zip +# mv /tmp/mdserver-web-master /www/server/mdserver-web +# rm -rf /tmp/master.zip +# rm -rf /tmp/mdserver-web-master -if [ ! -f /usr/bin/applydeltarpm ];then - yum -y provides '*/applydeltarpm' - yum -y install deltarpm -fi -if [ -f "/etc/init.d/iptables" ];then - - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 888 -j ACCEPT - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 30000:40000 -j ACCEPT - service iptables save - - iptables_status=`service iptables status | grep 'not running'` - if [ "${iptables_status}" == '' ];then - service iptables restart - fi -fi - -if [ "${isVersion}" == '' ];then - if [ ! -f "/etc/init.d/iptables" ];then - yum install firewalld -y - systemctl enable firewalld - systemctl start firewalld - - firewall-cmd --permanent --zone=public --add-port=22/tcp - firewall-cmd --permanent --zone=public --add-port=80/tcp - firewall-cmd --permanent --zone=public --add-port=888/tcp - firewall-cmd --permanent --zone=public --add-port=7200/tcp - firewall-cmd --permanent --zone=public --add-port=30000-40000/tcp - firewall-cmd --reload - fi -fi - - -yum install -y wget curl unzip zip - -# if [ ! -d '/www/server/mdserver-web' ];then - wget -O /tmp/master.zip https://codeload.github.com/midoks/mdserver-web/zip/master - cd /tmp && unzip /tmp/master.zip - mv /tmp/mdserver-web-master /www/server/mdserver-web - rm -rf /tmp/master.zip - rm -rf /tmp/mdserver-web-master -# fi - -yum groupinstall -y "Development Tools" -paces="wget python-devel python-imaging libicu-devel zip unzip openssl openssl-devel gcc libxml2 libxml2-dev libxslt* zlib zlib-devel libjpeg-devel libpng-devel libwebp libwebp-devel freetype freetype-devel lsof pcre pcre-devel vixie-cron crontabs" -yum -y install $paces -yum -y lsof net-tools.x86_64 -yum -y install ncurses-devel mysql-dev locate cmake -yum -y install epel-release - -if [ ! -f '/usr/bin/pip' ];then - wget https://bootstrap.pypa.io/get-pip.py - python get-pip.py - pip install --upgrade pip -fi - - -if [ ! -d /www/server/lib ]; then - cd /www/server/mdserver-web/scripts && ./lib.sh -fi pip install -r /www/server/mdserver-web/requirements.txt cd /www/server/mdserver-web && ./cli.sh start cd /www/server/mdserver-web && ./cli.sh stop - sleep 5 - cd /www/server/mdserver-web && ./scripts/init.d/mw default cd /www/server/mdserver-web && ./cli.sh start - - - - diff --git a/scripts/update.sh b/scripts/update.sh new file mode 100755 index 000000000..918847516 --- /dev/null +++ b/scripts/update.sh @@ -0,0 +1,44 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH +LANG=en_US.UTF-8 +is64bit=`getconf LONG_BIT` + +startTime=`date +%s` + +_os=`uname` +if [ "$_os" == "Darwin" ] ; then + OSNAME='MAC' +elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then + OSNAME='CentOS' +elif grep -Eqi "Red Hat Enterprise Linux Server" /etc/issue || grep -Eq "Red Hat Enterprise Linux Server" /etc/*-release; then + OSNAME='RHEL' +elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then + OSNAME='Aliyun' +elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then + OSNAME='Fedora' +elif grep -Eqi "Amazon Linux AMI" /etc/issue || grep -Eq "Amazon Linux AMI" /etc/*-release; then + OSNAME='Amazon' +elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then + OSNAME='Debian' +elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then + OSNAME='Ubuntu' +elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then + OSNAME='Raspbian' +elif grep -Eqi "Deepin" /etc/issue || grep -Eq "Deepin" /etc/*-release; then + OSNAME='Deepin' +else + OSNAME='unknow' +fi + + +if [ "$OSNAME" == 'MAC' ];then + echo 'The development environment only needs to be downloaded again!' + exit 0 +else + curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update_centos.sh | sh +fi + +endTime=`date +%s` +((outTime=($endTime-$startTime)/60)) +echo -e "Time consumed:\033[32m $outTime \033[0mMinute!" \ No newline at end of file diff --git a/scripts/update_centos.sh b/scripts/update_centos.sh new file mode 100755 index 000000000..918847516 --- /dev/null +++ b/scripts/update_centos.sh @@ -0,0 +1,44 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH +LANG=en_US.UTF-8 +is64bit=`getconf LONG_BIT` + +startTime=`date +%s` + +_os=`uname` +if [ "$_os" == "Darwin" ] ; then + OSNAME='MAC' +elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then + OSNAME='CentOS' +elif grep -Eqi "Red Hat Enterprise Linux Server" /etc/issue || grep -Eq "Red Hat Enterprise Linux Server" /etc/*-release; then + OSNAME='RHEL' +elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then + OSNAME='Aliyun' +elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then + OSNAME='Fedora' +elif grep -Eqi "Amazon Linux AMI" /etc/issue || grep -Eq "Amazon Linux AMI" /etc/*-release; then + OSNAME='Amazon' +elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then + OSNAME='Debian' +elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then + OSNAME='Ubuntu' +elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then + OSNAME='Raspbian' +elif grep -Eqi "Deepin" /etc/issue || grep -Eq "Deepin" /etc/*-release; then + OSNAME='Deepin' +else + OSNAME='unknow' +fi + + +if [ "$OSNAME" == 'MAC' ];then + echo 'The development environment only needs to be downloaded again!' + exit 0 +else + curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update_centos.sh | sh +fi + +endTime=`date +%s` +((outTime=($endTime-$startTime)/60)) +echo -e "Time consumed:\033[32m $outTime \033[0mMinute!" \ No newline at end of file