check_sw.sh 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #!/bin/bash
  2. # Author: Alpha Eva <kaneawk AT gmail.com>
  3. #
  4. # Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
  5. #
  6. # Project home page:
  7. # https://oneinstack.com
  8. # https://github.com/oneinstack/oneinstack
  9. installDepsDebian() {
  10. echo "${CMSG}Removing the conflicting packages...${CEND}"
  11. if [ "${apache_flag}" == 'y' ]; then
  12. killall apache2
  13. pkgList="apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker php5 php5-common php5-cgi php5-cli php5-mysql php5-curl php5-gd"
  14. for Package in ${pkgList};do
  15. apt-get -y purge ${Package}
  16. done
  17. dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
  18. fi
  19. if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then
  20. pkgList="mysql-client mysql-server mysql-common mysql-server-core-5.5 mysql-client-5.5 mariadb-client mariadb-server mariadb-common"
  21. for Package in ${pkgList};do
  22. apt-get -y purge ${Package}
  23. done
  24. dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
  25. fi
  26. echo "${CMSG}Installing dependencies packages...${CEND}"
  27. apt-get -y update
  28. apt-get -y autoremove
  29. apt-get -yf install
  30. export DEBIAN_FRONTEND=noninteractive
  31. # critical security updates
  32. grep security /etc/apt/sources.list > /tmp/security.sources.list
  33. apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
  34. # Install needed packages
  35. case "${Debian_ver}" in
  36. 9|10|11|12)
  37. pkgList="debian-keyring debian-archive-keyring build-essential gcc g++ make cmake autoconf libjpeg62-turbo-dev libjpeg-dev libpng-dev libgd-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libc-client2007e-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev numactl libreadline-dev curl libcurl3-gnutls libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl net-tools libssl-dev libtool libevent-dev bison re2c libsasl2-dev libxslt1-dev libicu-dev locales patch vim zip unzip tmux htop bc dc expect libexpat1-dev libonig-dev libtirpc-dev rsync git lsof lrzsz rsyslog cron logrotate chrony libsqlite3-dev psmisc wget sysv-rc apt-transport-https ca-certificates software-properties-common gnupg ufw"
  38. ;;
  39. *)
  40. echo "${CFAILURE}Your system Debian ${Debian_ver} are not supported!${CEND}"
  41. kill -9 $$; exit 1;
  42. ;;
  43. esac
  44. for Package in ${pkgList}; do
  45. apt-get --no-install-recommends -y install ${Package}
  46. done
  47. }
  48. installDepsRHEL() {
  49. [ -e '/etc/yum.conf' ] && sed -i 's@^exclude@#exclude@' /etc/yum.conf
  50. if [ "${RHEL_ver}" == '9' ]; then
  51. if [[ "${Platform}" =~ "rhel" ]]; then
  52. subscription-manager repos --enable codeready-builder-for-rhel-9-${ARCH}-rpms
  53. dnf -y install chrony oniguruma-devel rpcgen
  54. elif [[ "${Platform}" =~ "ol" ]]; then
  55. dnf config-manager --set-enabled ol9_codeready_builder
  56. dnf -y install chrony oniguruma-devel rpcgen
  57. else
  58. dnf -y --enablerepo=crb install chrony oniguruma-devel rpcgen
  59. fi
  60. systemctl enable chronyd
  61. elif [ "${RHEL_ver}" == '8' ]; then
  62. if [[ "${Platform}" =~ "rhel" ]]; then
  63. subscription-manager repos --enable codeready-builder-for-rhel-8-${ARCH}-rpms
  64. dnf -y install chrony oniguruma-devel rpcgen
  65. elif [[ "${Platform}" =~ "ol" ]]; then
  66. dnf config-manager --set-enabled ol8_codeready_builder
  67. dnf -y install chrony oniguruma-devel rpcgen
  68. else
  69. [ -z "`grep -w epel /etc/yum.repos.d/*.repo`" ] && yum -y install epel-release
  70. if grep -qw "^\[PowerTools\]" /etc/yum.repos.d/*.repo; then
  71. dnf -y --enablerepo=PowerTools install chrony oniguruma-devel rpcgen
  72. elif grep -qw "^\[powertools\]" /etc/yum.repos.d/*.repo; then
  73. dnf -y --enablerepo=powertools install chrony oniguruma-devel rpcgen
  74. fi
  75. fi
  76. systemctl enable chronyd
  77. elif [ "${RHEL_ver}" == '7' ]; then
  78. [ -z "`grep -w epel /etc/yum.repos.d/*.repo`" ] && yum -y install epel-release
  79. yum -y groupremove "Basic Web Server" "MySQL Database server" "MySQL Database client"
  80. fi
  81. if [ "${RHEL_ver}" == '9' ]; then
  82. [ ! -e "/usr/lib64/libtinfo.so.5" ] && ln -s /usr/lib64/libtinfo.so.6 /usr/lib64/libtinfo.so.5
  83. [ ! -e "/usr/lib64/libncurses.so.5" ] && ln -s /usr/lib64/libncurses.so.6 /usr/lib64/libncurses.so.5
  84. fi
  85. echo "${CMSG}Installing dependencies packages...${CEND}"
  86. # Install needed packages
  87. pkgList="perl-FindBin deltarpm drpm gcc gcc-c++ make cmake autoconf libjpeg libjpeg-devel libjpeg-turbo libjpeg-turbo-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel libzip libzip-devel glibc glibc-devel krb5-devel libc-client libc-client-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel ncurses-compat-libs libaio numactl numactl-libs readline-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel net-tools libxslt-devel libicu-devel libevent-devel libtool libtool-ltdl bison gd-devel vim-enhanced pcre-devel libmcrypt libmcrypt-devel mhash mhash-devel mcrypt zip unzip chrony oniguruma-devel rpcgen sqlite-devel sysstat patch bc expect expat-devel perl-devel oniguruma oniguruma-devel libtirpc-devel nss libnsl rsync rsyslog git lsof lrzsz psmisc wget which libatomic tmux chkconfig firewalld"
  88. for Package in ${pkgList}; do
  89. yum -y install ${Package}
  90. done
  91. [ ${RHEL_ver} -lt 8 >/dev/null 2>&1 ] && yum -y install cmake3
  92. yum -y update bash openssl glibc
  93. }
  94. installDepsUbuntu() {
  95. # Uninstall the conflicting software
  96. echo "${CMSG}Removing the conflicting packages...${CEND}"
  97. if [ "${apache_flag}" == 'y' ]; then
  98. killall apache2
  99. pkgList="apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker php5 php5-common php5-cgi php5-cli php5-mysql php5-curl php5-gd"
  100. for Package in ${pkgList};do
  101. apt-get -y purge ${Package}
  102. done
  103. dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
  104. fi
  105. if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then
  106. pkgList="mysql-client mysql-server mysql-common mysql-server-core-5.5 mysql-client-5.5 mariadb-client mariadb-server mariadb-common"
  107. for Package in ${pkgList};do
  108. apt-get -y purge ${Package}
  109. done
  110. dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
  111. fi
  112. echo "${CMSG}Installing dependencies packages...${CEND}"
  113. apt-get -y update
  114. apt-get -y autoremove
  115. apt-get -yf install
  116. export DEBIAN_FRONTEND=noninteractive
  117. [[ "${Ubuntu_ver}" =~ ^22$ ]] && apt-get -y --allow-downgrades install libicu70=70.1-2 libglib2.0-0=2.72.1-1 libxml2-dev
  118. # critical security updates
  119. grep security /etc/apt/sources.list > /tmp/security.sources.list
  120. apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
  121. # Install needed packages
  122. pkgList="libperl-dev debian-keyring debian-archive-keyring build-essential gcc g++ make cmake autoconf libjpeg8 libjpeg8-dev libpng-dev libpng12-0 libpng12-dev libpng3 libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libc-client2007e-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev numactl libreadline-dev curl libcurl3-gnutls libcurl4-gnutls-dev libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl net-tools libssl-dev libtool libevent-dev re2c libsasl2-dev libxslt1-dev libicu-dev libsqlite3-dev libcloog-ppl1 bison patch vim zip unzip tmux htop bc dc expect libexpat1-dev rsyslog libonig-dev libtirpc-dev libnss3 rsync git lsof lrzsz chrony psmisc wget sysv-rc apt-transport-https ca-certificates software-properties-common gnupg ufw"
  123. export DEBIAN_FRONTEND=noninteractive
  124. for Package in ${pkgList}; do
  125. apt-get --no-install-recommends -y install ${Package}
  126. done
  127. }
  128. installDepsBySrc() {
  129. pushd ${oneinstack_dir}/src > /dev/null
  130. if ! command -v icu-config > /dev/null 2>&1 || icu-config --version | grep '^3.' || [ "${Ubuntu_ver}" == "20" ]; then
  131. tar xzf icu4c-${icu4c_ver}-src.tgz
  132. pushd icu/source > /dev/null
  133. ./configure --prefix=/usr/local
  134. make -j ${THREAD} && make install
  135. popd > /dev/null
  136. rm -rf icu
  137. fi
  138. if command -v lsof >/dev/null 2>&1; then
  139. echo 'already initialize' > ~/.oneinstack
  140. else
  141. echo "${CFAILURE}${PM} config error parsing file failed${CEND}"
  142. kill -9 $$; exit 1;
  143. fi
  144. popd > /dev/null
  145. }