mdserver-web/scripts/install/rhel.sh

240 lines
8.6 KiB
Bash
Raw Permalink Normal View History

2022-12-09 12:21:38 -05:00
#!/bin/bash
2023-11-08 12:32:59 -05:00
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
2022-12-09 12:21:38 -05:00
export PATH
2022-12-28 08:47:54 -05:00
export LANG=en_US.UTF-8
2023-05-05 11:21:57 -04:00
SYS_ARCH=`arch`
2022-12-09 12:21:38 -05:00
2022-12-28 08:54:29 -05:00
if [ ! -f /usr/bin/applydeltarpm ];then
yum -y provides '*/applydeltarpm'
yum -y install deltarpm
fi
2022-12-09 12:21:38 -05:00
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:]]\+' `
2024-06-09 15:59:47 -04:00
2022-12-09 12:21:38 -05:00
isStream=$(grep -o -i 'stream' /etc/redhat-release)
cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
2023-10-19 13:56:20 -04:00
yum -y update
2022-12-09 12:21:38 -05:00
# CentOS Stream
if [ ! -z "$stream" ];then
yum install -y dnf dnf-plugins-core
dnf upgrade -y libmodulemd
fi
PKGMGR='yum'
if [ $VERSION_ID -ge 8 ];then
PKGMGR='dnf'
2022-12-10 01:02:05 -05:00
fi
2024-10-01 05:46:49 -04:00
# systemctl status chronyd -l
$PKGMGR install -y chrony
2024-06-10 00:54:38 -04:00
$PKGMGR install -y curl-devel libmcrypt libmcrypt-devel python3-devel
2024-06-10 00:55:08 -04:00
$PKGMGR install -y net-tools
2024-06-11 04:27:48 -04:00
$PKGMGR install -y unixODBC-devel
$PKGMGR install -y p7zip
$PKGMGR install -y p7zip-plugins
2025-09-12 02:09:13 -04:00
$PKGMGR install -y mmap-devel
2024-06-10 00:55:08 -04:00
2024-06-10 00:54:38 -04:00
$PKGMGR install -y libncurses*
2026-01-31 04:41:18 -05:00
$PKGMGR install -y sshpass
2026-04-03 01:13:59 -04:00
$PKGMGR install -y libzstd-devel
2026-04-10 04:34:32 -04:00
$PKGMGR install -y postgresql-devel
2026-04-15 05:02:25 -04:00
$PKGMGR install -y brotli-devel
2026-06-01 07:06:13 -04:00
$PKGMGR install -y vim-common
2024-06-10 00:54:38 -04:00
2023-05-06 01:24:47 -04:00
echo "install remi source"
2023-05-06 00:27:54 -04:00
if [ "$VERSION_ID" == "9" ];then
2023-07-22 00:53:07 -04:00
# dnf upgrade --refresh -y
dnf config-manager --set-enabled crb
2023-05-06 01:22:49 -04:00
echo "install remi start"
2023-05-06 00:30:51 -04:00
if [ ! -f /etc/yum.repos.d/remi.repo ];then
2023-05-05 11:32:07 -04:00
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-9.rpm
rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
fi
2023-05-06 01:22:49 -04:00
echo "install remi end"
2023-05-05 11:21:57 -04:00
fi
2022-12-20 00:02:45 -05:00
#https need
if [ ! -d /root/.acme.sh ];then
curl https://get.acme.sh | sh
fi
2024-06-10 00:55:08 -04:00
2024-06-09 15:37:12 -04:00
2023-02-01 00:25:01 -05:00
SSH_PORT=`netstat -ntpl|grep sshd|grep -v grep | sed -n "1,1p" | awk '{print $4}' | awk -F : '{print $2}'`
2023-08-05 01:36:13 -04:00
if [ "$SSH_PORT" == "" ];then
SSH_PORT_LINE=`cat /etc/ssh/sshd_config | grep "Port \d*" | tail -1`
SSH_PORT=${SSH_PORT_LINE/"Port "/""}
fi
2023-02-01 00:25:01 -05:00
echo "SSH PORT:${SSH_PORT}"
2023-02-11 13:02:27 -05:00
# redhat , iptables no default
# echo "iptables wrap start"
# if [ -f /usr/sbin/iptables ];then
# $PKGMGR install -y iptables-services
2022-12-20 00:40:56 -05:00
2023-02-11 13:02:27 -05:00
# # iptables -nL --line-number
2022-12-20 00:40:56 -05:00
2023-02-11 13:02:27 -05:00
# echo "iptables start"
# iptables_status=`systemctl status iptables | grep 'inactive'`
# if [ "${iptables_status}" != '' ];then
# service iptables restart
2023-01-17 12:38:06 -05:00
2023-02-11 13:02:27 -05:00
# # iptables -P FORWARD DROP
# iptables -P INPUT DROP
# iptables -P OUTPUT ACCEPT
# iptables -A INPUT -p tcp -s 127.0.0.1 -j ACCEPT
2023-01-18 04:27:33 -05:00
2023-02-11 13:02:27 -05:00
# 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
2022-12-28 10:21:07 -05:00
2023-02-11 13:02:27 -05:00
# # 安装时不开启
# # stop之后清空了所有规则,所以安装是不能stop.
# # 要在代码修复这个问题,开启时,重新执行一下放行端口。
# #service iptables stop
2022-12-28 04:26:56 -05:00
2023-02-11 13:02:27 -05:00
# echo "iptables end"
# fi
# echo "iptables wrap start"
2022-12-20 00:02:45 -05:00
2023-07-15 03:38:14 -04:00
2023-07-15 03:51:03 -04:00
echo "firewall open common port start"
2023-02-11 13:02:27 -05:00
if [ ! -f /usr/sbin/firewalld ];then
2022-12-20 00:02:45 -05:00
$PKGMGR install firewalld -y
systemctl enable firewalld
#取消服务锁定
systemctl unmask firewalld
systemctl start firewalld
2023-07-15 03:38:14 -04:00
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
2022-12-20 00:14:35 -05:00
# look
# firewall-cmd --list-all
# systemctl status firewalld
2023-07-15 08:34:46 -04:00
# firewall-cmd --zone=public --remove-port=80/tcp --permanent
2023-07-15 03:50:35 -04:00
2023-02-01 00:25:01 -05:00
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
2022-12-20 00:02:45 -05:00
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=443/tcp
2024-04-16 11:41:06 -04:00
firewall-cmd --permanent --zone=public --add-port=443/udp
2023-09-26 06:00:47 -04:00
# firewall-cmd --permanent --zone=public --add-port=888/tcp
2022-12-20 00:02:45 -05:00
# 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
2023-07-15 03:49:28 -04:00
firewall-cmd --reload
2023-07-15 03:50:35 -04:00
2022-12-20 00:02:45 -05:00
fi
2023-07-15 03:50:35 -04:00
echo "firewall open common port end"
2022-12-20 00:02:45 -05:00
2022-12-10 01:02:05 -05:00
$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"
2023-07-20 03:55:11 -04:00
if [ "$VERSION_ID" -ge "8" ];then
2022-12-10 01:02:05 -05:00
# EL8 及以上
2023-05-06 01:52:55 -04:00
# 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
2023-05-06 01:59:02 -04:00
REPOS="${REPOS},${REPO_VAR}"
2023-05-06 01:52:55 -04:00
fi
done
2023-07-22 00:26:56 -04:00
if [ "$REPOS" == "--enablerepo=" ];then
# if not find, reset emtpy
REPOS=''
fi
2023-05-06 01:59:02 -04:00
REPOS=${REPOS//=,/=}
2023-05-06 01:52:55 -04:00
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
2023-03-22 10:26:32 -04:00
for rpms in gcc gcc-c++ lsof autoconf bzip2 bzip2-devel c-ares-devel \
2022-12-09 12:21:38 -05:00
ca-certificates cairo-devel cmake crontabs curl curl-devel diffutils e2fsprogs e2fsprogs-devel \
2023-03-22 10:26:32 -04:00
expat-devel expect file flex gd gd-devel gettext gettext-devel glib2 glib2-devel glibc.i686 \
2022-12-09 13:24:03 -05:00
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 \
2022-12-09 12:21:38 -05:00
libpng libpng-devel libstdc++.so.6 libtirpc libtirpc-devel libtool libtool-libs libwebp libwebp-devel \
2023-03-22 10:26:32 -04:00
libxml2 libxml2-devel libxslt libxslt-devel libarchive make mysql-devel ncurses ncurses-devel net-tools \
2023-05-06 02:37:25 -04:00
oniguruma oniguruma-devel patch pcre pcre-devel perl perl-Data-Dumper perl-devel procps psmisc python3-devel \
2024-12-17 09:46:00 -05:00
openssl openssl-devel patchelf libargon2-devel \
2023-11-03 07:21:50 -04:00
ImageMagick ImageMagick-devel libyaml-devel \
2024-12-20 11:50:29 -05:00
pv bc bind-utils \
2024-12-17 11:18:18 -05:00
ncurses-compat-libs numactl \
2023-09-14 02:21:31 -04:00
readline-devel rpcgen sqlite-devel rar unrar tar unzip vim-minimal wget zip zlib zlib-devel;
2022-12-13 00:42:42 -05:00
do
2023-05-06 01:52:55 -04:00
# dnf --enablerepo=remi,appstream,baseos,epel,extras,powertools install -y oniguruma5php-devel
2022-12-13 00:42:42 -05:00
dnf $REPOS install -y $rpms;
2023-02-18 01:09:02 -05:00
if [ "$?" != "0" ];then
dnf install -y $rpms;
fi
2022-12-13 00:42:42 -05:00
done
2022-12-09 12:21:38 -05:00
else
# CentOS 7
2023-03-22 10:26:32 -04:00
for rpms in gcc gcc-c++ lsof autoconf bison bzip2 bzip2-devel c-ares-devel ca-certificates cairo-devel \
2022-12-09 13:59:04 -05:00
cmake cmake3 crontabs curl curl-devel diffutils e2fsprogs e2fsprogs-devel expat-devel expect file \
2023-03-22 10:26:32 -04:00
flex freetype freetype-devel gd gd-devel gettext gettext-devel git-core glib2 glib2-devel \
2022-12-09 13:59:04 -05:00
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 \
2023-03-22 10:26:32 -04:00
libwebp libwebp-devel libxml2 libxml2-devel libxslt libxslt-devel libzip libzip-devel libzstd-devel \
2022-12-09 13:59:04 -05:00
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 \
2024-12-20 11:50:29 -05:00
pv bc bind-utils \
2024-12-17 11:18:18 -05:00
ncurses-compat-libs numactl \
2023-09-14 02:21:31 -04:00
python3-devel python3-pip re2c readline-devel rpcgen sqlite-devel tar unzip rar unrar vim-minimal vixie-cron \
2023-11-03 07:21:50 -04:00
wget zip zlib zlib-devel ImageMagick ImageMagick-devel libyaml-devel patchelf libargon2-devel;
2022-12-13 00:42:42 -05:00
do
yum install -y $rpms;
done
2022-12-09 12:21:38 -05:00
fi
cd /www/server/mdserver-web/scripts && bash lib.sh
chmod 755 /www/server/mdserver-web/data