Parcourir la source

[style] Update CentOS to RHEL

lj2007331@gmail.com il y a 3 ans
Parent
commit
298ae670ab

+ 1 - 1
README.md

@@ -1,6 +1,6 @@
 [![PayPal donate button](https://img.shields.io/badge/paypal-donate-green.svg)](https://paypal.me/yeho) [![支付宝捐助按钮](https://img.shields.io/badge/%E6%94%AF%E4%BB%98%E5%AE%9D-%E5%90%91TA%E6%8D%90%E5%8A%A9-green.svg)](https://static.oneinstack.com/images/alipay.png) [![微信捐助按钮](https://img.shields.io/badge/%E5%BE%AE%E4%BF%A1-%E5%90%91TA%E6%8D%90%E5%8A%A9-green.svg)](https://static.oneinstack.com/images/weixin.png)
 
-This script is written using the shell, in order to quickly deploy `LEMP`/`LAMP`/`LNMP`/`LNMPA`/`LTMP`(Linux, Nginx/Tengine/OpenResty, MySQL in a production environment/MariaDB/Percona, PHP, JAVA), applicable to CentOS 7 ~ 8(including redhat), Debian 8 ~ 10, Ubuntu 16 ~ 20, Fedora 27+ of 32 and 64.
+This script is written using the shell, in order to quickly deploy `LEMP`/`LAMP`/`LNMP`/`LNMPA`/`LTMP`(Linux, Nginx/Tengine/OpenResty, MySQL in a production environment/MariaDB/Percona, PHP, JAVA), applicable to CentOS 7 ~ 8(including redhat), Debian 8 ~ 11, Ubuntu 16 ~ 20, Fedora 27+ of 32 and 64.
 
 Script properties:
 - Continually updated, Provide Shell Interaction and Autoinstall

+ 4 - 4
include/check_download.sh

@@ -652,7 +652,7 @@ checkDownload() {
     echo "Download redis-server..."
     src_url=http://download.redis.io/releases/redis-${redis_ver}.tar.gz && Download_src
     if [ "${PM}" == 'yum' ]; then
-      echo "Download start-stop-daemon.c for CentOS..."
+      echo "Download start-stop-daemon.c for RHEL..."
       src_url=${mirrorLink}/start-stop-daemon.c && Download_src
     fi
   fi
@@ -731,9 +731,9 @@ checkDownload() {
     fi
   fi
 
-  # autoconf for CentOS6
-  if [ "${downloadDepsSrc}" == '1' ] && [ "${CentOS_ver}" == '6' ]; then
-    echo "Download autoconf rpm for CentOS6..."
+  # autoconf for RHEL6
+  if [ "${downloadDepsSrc}" == '1' ] && [ "${RHEL_ver}" == '6' ]; then
+    echo "Download autoconf rpm for RHEL6..."
     src_url=${mirrorLink}/autoconf-2.69-12.2.noarch.rpm && Download_src
   fi
 

+ 10 - 10
include/check_os.sh

@@ -40,13 +40,13 @@ command -v lsb_release >/dev/null 2>&1 || { echo "${CFAILURE}${PM} source failed
 
 # Get OS Version
 OS=$(lsb_release -is)
-if [[ "${OS}" =~ ^CentOS$|^CentOSStream$|^RedHat$|^Rocky$|^Fedora$|^Amazon$|^AlibabaCloud\(AliyunLinux\)$|^EulerOS$|^openEuler$ ]]; then
-  LikeOS=CentOS
-  CentOS_ver=$(lsb_release -rs | awk -F. '{print $1}' | awk '{print $1}')
-  [[ "${OS}" =~ ^Fedora$ ]] && [ ${CentOS_ver} -ge 19 >/dev/null 2>&1 ] && { CentOS_ver=7; Fedora_ver=$(lsb_release -rs); }
-  [[ "${OS}" =~ ^Amazon$|^EulerOS$|^openEuler$ ]] && CentOS_ver=7
-  [[ "${OS}" =~ ^AlibabaCloud\(AliyunLinux\)$ ]] && [[ "${CentOS_ver}" =~ ^2$ ]] && CentOS_ver=7
-  [[ "${OS}" =~ ^AlibabaCloud\(AliyunLinux\)$ ]] && [[ "${CentOS_ver}" =~ ^3$ ]] && CentOS_ver=8
+if [[ "${OS}" =~ ^CentOS$|^CentOSStream$|^RedHat$|^Rocky$|^Fedora$|^Amazon$|^AlibabaCloud$|^AlibabaCloud\(AliyunLinux\)$|^EulerOS$|^openEuler$ ]]; then
+  LikeOS=RHEL
+  RHEL_ver=$(lsb_release -rs | awk -F. '{print $1}' | awk '{print $1}')
+  [[ "${OS}" =~ ^Fedora$ ]] && [ ${RHEL_ver} -ge 19 >/dev/null 2>&1 ] && { RHEL_ver=7; Fedora_ver=$(lsb_release -rs); }
+  [[ "${OS}" =~ ^Amazon$|^EulerOS$|^openEuler$ ]] && RHEL_ver=7
+  [[ "${OS}" =~ ^AlibabaCloud$|^AlibabaCloud\(AliyunLinux\)$ ]] && [[ "${RHEL_ver}" =~ ^2$ ]] && RHEL_ver=7
+  [[ "${OS}" =~ ^AlibabaCloud$|^AlibabaCloud\(AliyunLinux\)$ ]] && [[ "${RHEL_ver}" =~ ^3$ ]] && RHEL_ver=8
 elif [[ "${OS}" =~ ^Debian$|^Deepin$|^Uos$|^Kali$ ]]; then
   LikeOS=Debian
   Debian_ver=$(lsb_release -rs | awk -F. '{print $1}' | awk '{print $1}')
@@ -67,7 +67,7 @@ elif [[ "${OS}" =~ ^Ubuntu$|^LinuxMint$|^elementary$ ]]; then
 fi
 
 # Check OS Version
-if [ ${CentOS_ver} -lt 6 >/dev/null 2>&1 ] || [ ${Debian_ver} -lt 8 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -lt 16 >/dev/null 2>&1 ]; then
+if [ ${RHEL_ver} -lt 6 >/dev/null 2>&1 ] || [ ${Debian_ver} -lt 8 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -lt 16 >/dev/null 2>&1 ]; then
   echo "${CFAILURE}Does not support this OS, Please install CentOS 6+,Debian 8+,Ubuntu 16+ ${CEND}"
   kill -9 $$
 fi
@@ -119,13 +119,13 @@ THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l)
 # Percona binary: https://www.percona.com/doc/percona-server/5.7/installation.html#installing-percona-server-from-a-binary-tarball
 if [ ${Debian_ver} -lt 9 >/dev/null 2>&1 ]; then
   sslLibVer=ssl100
-elif [[ "${CentOS_ver}" =~ ^[6-7]$ ]] && [ "${OS}" != 'Fedora' ]; then
+elif [[ "${RHEL_ver}" =~ ^[6-7]$ ]] && [ "${OS}" != 'Fedora' ]; then
   sslLibVer=ssl101
 elif [ ${Debian_ver} -ge 9 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -ge 16 >/dev/null 2>&1 ]; then
   sslLibVer=ssl102
 elif [ ${Fedora_ver} -ge 27 >/dev/null 2>&1 ]; then
   sslLibVer=ssl102
-elif [ "${CentOS_ver}" == '8' ]; then
+elif [ "${RHEL_ver}" == '8' ]; then
   sslLibVer=ssl1:111
 else
   sslLibVer=unknown

+ 8 - 8
include/check_sw.sh

@@ -54,12 +54,12 @@ installDepsDebian() {
   done
 }
 
-installDepsCentOS() {
+installDepsRHEL() {
   [ -e '/etc/yum.conf' ] && sed -i 's@^exclude@#exclude@' /etc/yum.conf
   # Uninstall the conflicting packages
   echo "${CMSG}Removing the conflicting packages...${CEND}"
   [ -z "`grep -w epel /etc/yum.repos.d/*.repo`" ] && yum -y install epel-release
-  if [ "${CentOS_ver}" == '8' ]; then
+  if [ "${RHEL_ver}" == '8' ]; then
     if grep -qw "^\[PowerTools\]" /etc/yum.repos.d/*.repo; then
       dnf -y --enablerepo=PowerTools install chrony oniguruma-devel rpcgen
     else
@@ -67,14 +67,14 @@ installDepsCentOS() {
     fi
     systemctl enable chronyd
     systemctl stop firewalld && systemctl mask firewalld.service
-  elif [ "${CentOS_ver}" == '7' ]; then
+  elif [ "${RHEL_ver}" == '7' ]; then
     yum -y groupremove "Basic Web Server" "MySQL Database server" "MySQL Database client"
     systemctl stop firewalld && systemctl mask firewalld.service
-  elif [ "${CentOS_ver}" == '6' ]; then
+  elif [ "${RHEL_ver}" == '6' ]; then
     yum -y groupremove "FTP Server" "PostgreSQL Database client" "PostgreSQL Database server" "MySQL Database server" "MySQL Database client" "Web Server"
   fi
 
-  if [ ${CentOS_ver} -ge 7 >/dev/null 2>&1 ] && [ "${iptables_flag}" == 'y' ]; then
+  if [ ${RHEL_ver} -ge 7 >/dev/null 2>&1 ] && [ "${iptables_flag}" == 'y' ]; then
     yum -y install iptables-services
     systemctl enable iptables.service
     systemctl enable ip6tables.service
@@ -86,7 +86,7 @@ installDepsCentOS() {
   for Package in ${pkgList}; do
     yum -y install ${Package}
   done
-  [ ${CentOS_ver} -lt 8 >/dev/null 2>&1 ] && yum -y install cmake3
+  [ ${RHEL_ver} -lt 8 >/dev/null 2>&1 ] && yum -y install cmake3
 
   yum -y update bash openssl glibc
 }
@@ -131,8 +131,8 @@ installDepsUbuntu() {
 
 installDepsBySrc() {
   pushd ${oneinstack_dir}/src > /dev/null
-  if [ "${LikeOS}" == 'CentOS' ] && [ "${CentOS_ver}" == '6' ]; then
-    # upgrade autoconf for CentOS6
+  if [ "${LikeOS}" == 'RHEL' ] && [ "${RHEL_ver}" == '6' ]; then
+    # upgrade autoconf for RHEL6
     rpm -Uvh autoconf-2.69-12.2.noarch.rpm
   fi
 

+ 2 - 2
include/init_CentOS.sh → include/init_RHEL.sh

@@ -98,11 +98,11 @@ net.netfilter.nf_conntrack_tcp_timeout_established = 3600
 EOF
 sysctl -p
 
-if [ "${CentOS_ver}" == '6' ]; then
+if [ "${RHEL_ver}" == '6' ]; then
   sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES=/dev/tty[1-2]@' /etc/sysconfig/init
   sed -i 's@^start@#start@' /etc/init/control-alt-delete.conf
   sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/sysconfig/i18n
-elif [ ${CentOS_ver} -ge 7 >/dev/null 2>&1 ]; then
+elif [ ${RHEL_ver} -ge 7 >/dev/null 2>&1 ]; then
   sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/locale.conf
 fi
 

+ 1 - 1
include/jemalloc.sh

@@ -17,7 +17,7 @@ Install_Jemalloc() {
     make -j ${THREAD} && make install
     popd > /dev/null
     if [ -f "/usr/local/lib/libjemalloc.so" ]; then
-      if [ "${OS_BIT}" == '64' -a "${LikeOS}" == 'CentOS' ]; then
+      if [ "${OS_BIT}" == '64' -a "${LikeOS}" == 'RHEL' ]; then
         ln -s /usr/local/lib/libjemalloc.so.2 /usr/lib64/libjemalloc.so.1
       else
         ln -s /usr/local/lib/libjemalloc.so.2 /usr/lib/libjemalloc.so.1

+ 1 - 1
include/memcached.sh

@@ -24,7 +24,7 @@ Install_memcached_server() {
     echo "${CSUCCESS}memcached installed successfully! ${CEND}"
     rm -rf memcached-${memcached_ver}
     ln -s ${memcached_install_dir}/bin/memcached /usr/bin/memcached
-    [ "${PM}" == 'yum' ] && { /bin/cp ../init.d/Memcached-init-CentOS /etc/init.d/memcached; chkconfig --add memcached; chkconfig memcached on; }
+    [ "${PM}" == 'yum' ] && { /bin/cp ../init.d/Memcached-init-RHEL /etc/init.d/memcached; chkconfig --add memcached; chkconfig memcached on; }
     [ "${PM}" == 'apt-get' ] && { /bin/cp ../init.d/Memcached-init-Ubuntu /etc/init.d/memcached; update-rc.d memcached defaults; }
     sed -i "s@/usr/local/memcached@${memcached_install_dir}@g" /etc/init.d/memcached
     let memcachedCache="${Mem}/8"

+ 1 - 1
include/mongodb.sh

@@ -20,7 +20,7 @@ Install_MongoDB() {
     sed -i "s@=/usr/local/mongodb@=${mongo_install_dir}@g" /lib/systemd/system/mongod.service
     systemctl enable mongod 
   else
-    [ "${PM}" == 'yum' ] && { /bin/cp ../init.d/MongoDB-init-CentOS /etc/init.d/mongod; sed -i "s@/usr/local/mongodb@${mongo_install_dir}@g" /etc/init.d/mongod; chkconfig --add mongod; chkconfig mongod on; }
+    [ "${PM}" == 'yum' ] && { /bin/cp ../init.d/MongoDB-init-RHEL /etc/init.d/mongod; sed -i "s@/usr/local/mongodb@${mongo_install_dir}@g" /etc/init.d/mongod; chkconfig --add mongod; chkconfig mongod on; }
     [ "${PM}" == 'apt-get' ] && { /bin/cp ../init.d/MongoDB-init-Ubuntu /etc/init.d/mongod; sed -i "s@/usr/local/mongodb@${mongo_install_dir}@g" /etc/init.d/mongod; update-rc.d mongod defaults; }
   fi
 

+ 1 - 1
include/nginx.sh

@@ -49,7 +49,7 @@ Install_Nginx() {
     sed -i "s@/usr/local/nginx@${nginx_install_dir}@g" /lib/systemd/system/nginx.service
     systemctl enable nginx
   else
-    [ "${PM}" == 'yum' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; sed -i "s@/usr/local/nginx@${nginx_install_dir}@g" /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
+    [ "${PM}" == 'yum' ] && { /bin/cp ../init.d/Nginx-init-RHEL /etc/init.d/nginx; sed -i "s@/usr/local/nginx@${nginx_install_dir}@g" /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
     [ "${PM}" == 'apt-get' ] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; sed -i "s@/usr/local/nginx@${nginx_install_dir}@g" /etc/init.d/nginx; update-rc.d nginx defaults; }
   fi
 

+ 1 - 1
include/openresty.sh

@@ -45,7 +45,7 @@ Install_OpenResty() {
     sed -i "s@/usr/local/nginx@${openresty_install_dir}/nginx@g" /lib/systemd/system/nginx.service
     systemctl enable nginx
   else
-    [ "${PM}" == 'yum' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; sed -i "s@/usr/local/nginx@${openresty_install_dir}/nginx@g" /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
+    [ "${PM}" == 'yum' ] && { /bin/cp ../init.d/Nginx-init-RHEL /etc/init.d/nginx; sed -i "s@/usr/local/nginx@${openresty_install_dir}/nginx@g" /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
     [ "${PM}" == 'apt-get' ] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; sed -i "s@/usr/local/nginx@${openresty_install_dir}/nginx@g" /etc/init.d/nginx; update-rc.d nginx defaults; }
   fi
 

+ 1 - 1
include/tengine.sh

@@ -44,7 +44,7 @@ Install_Tengine() {
     sed -i "s@/usr/local/nginx@${tengine_install_dir}@g" /lib/systemd/system/nginx.service
     systemctl enable nginx
   else
-    [ "${PM}" == 'yum' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; sed -i "s@/usr/local/nginx@${tengine_install_dir}@g" /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
+    [ "${PM}" == 'yum' ] && { /bin/cp ../init.d/Nginx-init-RHEL /etc/init.d/nginx; sed -i "s@/usr/local/nginx@${tengine_install_dir}@g" /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
     [ "${PM}" == 'apt-get' ] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; sed -i "s@/usr/local/nginx@${tengine_install_dir}@g" /etc/init.d/nginx; update-rc.d nginx defaults; }
   fi
 

+ 0 - 0
init.d/Memcached-init-CentOS → init.d/Memcached-init-RHEL


+ 0 - 0
init.d/MongoDB-init-CentOS → init.d/MongoDB-init-RHEL


+ 0 - 0
init.d/Nginx-init-CentOS → init.d/Nginx-init-RHEL


+ 7 - 7
install.sh

@@ -718,7 +718,7 @@ if [ ! -e ~/.oneinstack ]; then
   [ "${PM}" == 'apt-get' ] && apt-get -y update > /dev/null
   [ "${PM}" == 'yum' ] && yum clean all
   ${PM} -y install wget gcc curl python
-  [ "${CentOS_ver}" == '8' ] && { yum -y install python36; sudo alternatives --set python /usr/bin/python3; }
+  [ "${RHEL_ver}" == '8' ] && { yum -y install python36; sudo alternatives --set python /usr/bin/python3; }
   clear
 fi
 
@@ -743,9 +743,9 @@ if [ ! -e ~/.oneinstack ]; then
   # Check binary dependencies packages
   . ./include/check_sw.sh
   case "${LikeOS}" in
-    "CentOS")
-      installDepsCentOS 2>&1 | tee ${oneinstack_dir}/install.log
-      . include/init_CentOS.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
+    "RHEL")
+      installDepsRHEL 2>&1 | tee ${oneinstack_dir}/install.log
+      . include/init_RHEL.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
       ;;
     "Debian")
       installDepsDebian 2>&1 | tee ${oneinstack_dir}/install.log
@@ -778,7 +778,7 @@ fi
 # Database
 case "${db_option}" in
   1)
-    [ "${LikeOS}" == 'CentOS' ] && [ ${CentOS_ver} -le 6 >/dev/null 2>&1 ] && dbinstallmethod=1 && checkDownload
+    [ "${LikeOS}" == 'RHEL' ] && [ ${RHEL_ver} -le 6 >/dev/null 2>&1 ] && dbinstallmethod=1 && checkDownload
     . include/mysql-8.0.sh
     Install_MySQL80 2>&1 | tee -a ${oneinstack_dir}/install.log
     ;;
@@ -811,8 +811,8 @@ case "${db_option}" in
     Install_MariaDB55 2>&1 | tee -a ${oneinstack_dir}/install.log
     ;;
   9)
-    [ "${LikeOS}" == 'CentOS' ] && [ ${CentOS_ver} -le 6 >/dev/null 2>&1 ] && dbinstallmethod=1 && checkDownload
-    [ "${LikeOS}" == 'CentOS' ] && [ "${CentOS_ver}" == '8' ] && dbinstallmethod=2 && checkDownload
+    [ "${LikeOS}" == 'RHEL' ] && [ ${RHEL_ver} -le 6 >/dev/null 2>&1 ] && dbinstallmethod=1 && checkDownload
+    [ "${LikeOS}" == 'RHEL' ] && [ "${RHEL_ver}" == '8' ] && dbinstallmethod=2 && checkDownload
     . include/percona-8.0.sh
     Install_Percona80 2>&1 | tee -a ${oneinstack_dir}/install.log
     ;;