Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdserver-web/scripts/install/rhel.sh

197 lines
7.4 KiB

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
2 years ago
export LANG=en_US.UTF-8
2 years ago
SYS_ARCH=`arch`
2 years ago
if [ ! -f /usr/bin/applydeltarpm ];then
yum -y provides '*/applydeltarpm'
yum -y install deltarpm
fi
setenforce 0
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
VERSION_ID=`grep -o -i 'release *[[:digit:]]\+\.*' /etc/redhat-release | grep -o '[[:digit:]]\+' `
isStream=$(grep -o -i 'stream' /etc/redhat-release)
cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
# CentOS Stream
if [ ! -z "$stream" ];then
yum install -y dnf dnf-plugins-core
dnf upgrade -y libmodulemd
fi
2 years ago
PKGMGR='yum'
if [ $VERSION_ID -ge 8 ];then
PKGMGR='dnf'
fi
2 years ago
echo "install remi source"
2 years ago
if [ "$VERSION_ID" == "9" ];then
2 years ago
echo "install remi start"
2 years ago
if [ ! -f /etc/yum.repos.d/remi.repo ];then
2 years ago
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-9.rpm
rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
fi
2 years ago
echo "install remi end"
2 years ago
fi
2 years ago
#https need
if [ ! -d /root/.acme.sh ];then
curl https://get.acme.sh | sh
fi
2 years ago
SSH_PORT=`netstat -ntpl|grep sshd|grep -v grep | sed -n "1,1p" | awk '{print $4}' | awk -F : '{print $2}'`
echo "SSH PORT:${SSH_PORT}"
2 years ago
# redhat , iptables no default
# echo "iptables wrap start"
# if [ -f /usr/sbin/iptables ];then
# $PKGMGR install -y iptables-services
2 years ago
2 years ago
# # iptables -nL --line-number
2 years ago
2 years ago
# echo "iptables start"
# iptables_status=`systemctl status iptables | grep 'inactive'`
# if [ "${iptables_status}" != '' ];then
# service iptables restart
2 years ago
# # iptables -P FORWARD DROP
# iptables -P INPUT DROP
# iptables -P OUTPUT ACCEPT
# iptables -A INPUT -p tcp -s 127.0.0.1 -j ACCEPT
2 years ago
# if [ "$SSH_PORT" != "" ];then
# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ${SSH_PORT} -j ACCEPT
# else
# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
# fi
# 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 443 -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 3306 -j ACCEPT
# # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 30000:40000 -j ACCEPT
# service iptables save
# fi
2 years ago
2 years ago
# # 安装时不开启
# # stop之后清空了所有规则,所以安装是不能stop.
# # 要在代码修复这个问题,开启时,重新执行一下放行端口。
# #service iptables stop
2 years ago
2 years ago
# echo "iptables end"
# fi
# echo "iptables wrap start"
2 years ago
2 years ago
2 years ago
if [ ! -f /usr/sbin/firewalld ];then
2 years ago
$PKGMGR install firewalld -y
systemctl enable firewalld
#取消服务锁定
systemctl unmask firewalld
systemctl start firewalld
2 years ago
sed -i 's#AllowZoneDrifting=yes#AllowZoneDrifting=no#g' /etc/firewalld/firewalld.conf
firewall-cmd --reload
#安装就开启
systemctl restart firewalld
fi
if [ -f /usr/sbin/firewalld ];then
2 years ago
# look
# firewall-cmd --list-all
# systemctl status firewalld
2 years ago
echo "firewall open common port start"
2 years ago
if [ "$SSH_PORT" != "" ];then
firewall-cmd --permanent --zone=public --add-port=${SSH_PORT}/tcp
else
firewall-cmd --permanent --zone=public --add-port=22/tcp
fi
2 years ago
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=443/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=3306/tcp
# firewall-cmd --permanent --zone=public --add-port=30000-40000/tcp
2 years ago
firewall-cmd --reload
echo "firewall open common port end"
2 years ago
fi
$PKGMGR install -y epel-release
if [ ! -z "$cn" ];then
sed -e 's|^metalink=|#metalink=|g' \
-e 's|^#baseurl=|baseurl=|g' \
-e 's|//download\.fedoraproject\.org/pub|//mirrors.tuna.tsinghua.edu.cn|g' \
-e 's|//download\.example/pub|//mirrors.tuna.tsinghua.edu.cn|g' \
-i.bak /etc/yum.repos.d/epel*.repo
fi
$PKGMGR makecache
$PKGMGR groupinstall -y "Development Tools"
if [ $VERSION_ID -ge 8 ];then
# EL8 及以上
2 years ago
# find repo
REPO_LIST=(remi appstream baseos epel extras crb powertools)
REPOS='--enablerepo='
for REPO_VAR in ${REPO_LIST[@]}
do
if [ -f /etc/yum.repos.d/${REPO_VAR}.repo ];then
2 years ago
REPOS="${REPOS},${REPO_VAR}"
2 years ago
fi
done
2 years ago
REPOS=${REPOS//=,/=}
2 years ago
echo "REPOS:${REPOS}"
# if [ $VERSION_ID -ge 9 ];then
# REPOS='--enablerepo=remi,appstream,baseos,epel,extras,crb'
# else
# REPOS='--enablerepo=remi,appstream,baseos,epel,extras,powertools'
# fi
2 years ago
for rpms in gcc gcc-c++ lsof autoconf bzip2 bzip2-devel c-ares-devel \
ca-certificates cairo-devel cmake crontabs curl curl-devel diffutils e2fsprogs e2fsprogs-devel \
2 years ago
expat-devel expect file flex gd gd-devel gettext gettext-devel glib2 glib2-devel glibc.i686 \
gmp-devel kernel-devel libXpm-devel libaio-devel libcap libcurl libcurl-devel libevent libevent-devel \
libicu-devel libidn libidn-devel libmcrypt libmcrypt-devel libmemcached libmemcached-devel \
libpng libpng-devel libstdc++.so.6 libtirpc libtirpc-devel libtool libtool-libs libwebp libwebp-devel \
2 years ago
libxml2 libxml2-devel libxslt libxslt-devel libarchive make mysql-devel ncurses ncurses-devel net-tools \
2 years ago
oniguruma oniguruma-devel patch pcre pcre-devel perl perl-Data-Dumper perl-devel procps psmisc python3-devel \
2 years ago
openssl openssl-devel \
readline-devel rpcgen sqlite-devel tar unzip vim-minimal wget zip zlib zlib-devel ;
do
2 years ago
# dnf --enablerepo=remi,appstream,baseos,epel,extras,powertools install -y oniguruma5php-devel
dnf $REPOS install -y $rpms;
2 years ago
if [ "$?" != "0" ];then
dnf install -y $rpms;
fi
done
else
# CentOS 7
2 years ago
for rpms in gcc gcc-c++ lsof autoconf bison bzip2 bzip2-devel c-ares-devel ca-certificates cairo-devel \
cmake cmake3 crontabs curl curl-devel diffutils e2fsprogs e2fsprogs-devel expat-devel expect file \
2 years ago
flex freetype freetype-devel gd gd-devel gettext gettext-devel git-core glib2 glib2-devel \
glibc.i686 gmp-devel graphviz icu kernel-devel libXpm-devel libaio-devel libcap libcurl libcurl-devel \
libevent libevent-devel libicu-devel libidn libidn-devel libjpeg-devel libmcrypt libmcrypt-devel \
libmemcached libmemcached-devel libpng-devel libstdc++.so.6 libtirpc libtirpc-devel libtool libtool-libs \
2 years ago
libwebp libwebp-devel libxml2 libxml2-devel libxslt libxslt-devel libzip libzip-devel libzstd-devel \
make mysql-devel ncurses ncurses-devel net-tools oniguruma oniguruma-devel openldap openldap-devel \
openssl openssl-devel patch pcre pcre-devel perl perl-Data-Dumper perl-devel psmisc python-devel \
python3-devel python3-pip re2c readline-devel rpcgen sqlite-devel tar unzip vim-minimal vixie-cron \
wget zip zlib zlib-devel ImageMagick ImageMagick-devel ;
do
yum install -y $rpms;
done
fi
cd /www/server/mdserver-web/scripts && bash lib.sh
chmod 755 /www/server/mdserver-web/data