check_sw.sh 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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)
  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. else
  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. echo "${CMSG}Installing dependencies packages...${CEND}"
  82. # Install needed packages
  83. 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 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 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"
  84. for Package in ${pkgList}; do
  85. yum -y install ${Package}
  86. done
  87. [ ${RHEL_ver} -lt 8 >/dev/null 2>&1 ] && yum -y install cmake3
  88. yum -y update bash openssl glibc
  89. }
  90. installDepsUbuntu() {
  91. # Uninstall the conflicting software
  92. echo "${CMSG}Removing the conflicting packages...${CEND}"
  93. if [ "${apache_flag}" == 'y' ]; then
  94. killall apache2
  95. 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"
  96. for Package in ${pkgList};do
  97. apt-get -y purge ${Package}
  98. done
  99. dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
  100. fi
  101. if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then
  102. pkgList="mysql-client mysql-server mysql-common mysql-server-core-5.5 mysql-client-5.5 mariadb-client mariadb-server mariadb-common"
  103. for Package in ${pkgList};do
  104. apt-get -y purge ${Package}
  105. done
  106. dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
  107. fi
  108. echo "${CMSG}Installing dependencies packages...${CEND}"
  109. apt-get -y update
  110. apt-get -y autoremove
  111. apt-get -yf install
  112. export DEBIAN_FRONTEND=noninteractive
  113. [[ "${Ubuntu_ver}" =~ ^22$ ]] && apt-get -y --allow-downgrades install libicu70=70.1-2 libglib2.0-0=2.72.1-1 libxml2-dev
  114. # critical security updates
  115. grep security /etc/apt/sources.list > /tmp/security.sources.list
  116. apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
  117. # Install needed packages
  118. 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"
  119. export DEBIAN_FRONTEND=noninteractive
  120. for Package in ${pkgList}; do
  121. apt-get --no-install-recommends -y install ${Package}
  122. done
  123. }
  124. installDepsBySrc() {
  125. pushd ${oneinstack_dir}/src > /dev/null
  126. if ! command -v icu-config > /dev/null 2>&1 || icu-config --version | grep '^3.' || [ "${Ubuntu_ver}" == "20" ]; then
  127. tar xzf icu4c-${icu4c_ver}-src.tgz
  128. pushd icu/source > /dev/null
  129. ./configure --prefix=/usr/local
  130. make -j ${THREAD} && make install
  131. popd > /dev/null
  132. rm -rf icu
  133. fi
  134. if command -v lsof >/dev/null 2>&1; then
  135. echo 'already initialize' > ~/.oneinstack
  136. else
  137. echo "${CFAILURE}${PM} config error parsing file failed${CEND}"
  138. kill -9 $$; exit 1;
  139. fi
  140. popd > /dev/null
  141. }