check_sw.sh 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. #!/bin/bash
  2. # Author: Alpha Eva <kaneawk AT gmail.com>
  3. #
  4. # Notes: OneinStack for CentOS/RedHat 7+ Debian 8+ 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. 8)
  37. pkgList="debian-keyring debian-archive-keyring build-essential gcc g++ make cmake autoconf libjpeg8 libjpeg62-turbo-dev libjpeg-dev libpng12-0 libpng12-dev libpng3 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-gnutls-dev 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 libxslt-dev libicu-dev locales libcloog-ppl0 patch vim zip unzip tmux htop bc dc expect libexpat1-dev libonig-dev libtirpc-dev nss rsync git lsof lrzsz iptables rsyslog cron logrotate ntpdate libsqlite3-dev psmisc wget sysv-rc ca-certificates"
  38. ;;
  39. 9|10)
  40. 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-gnutls-dev 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 libcloog-ppl1 patch vim zip unzip tmux htop bc dc expect libexpat1-dev libonig-dev libtirpc-dev nss rsync git lsof lrzsz iptables rsyslog cron logrotate ntpdate libsqlite3-dev psmisc wget sysv-rc ca-certificates"
  41. ;;
  42. *)
  43. echo "${CFAILURE}Your system Debian ${Debian_ver} are not supported!${CEND}"
  44. kill -9 $$
  45. ;;
  46. esac
  47. for Package in ${pkgList}; do
  48. apt-get --no-install-recommends -y install ${Package}
  49. done
  50. }
  51. installDepsCentOS() {
  52. [ -e '/etc/yum.conf' ] && sed -i 's@^exclude@#exclude@' /etc/yum.conf
  53. # Uninstall the conflicting packages
  54. echo "${CMSG}Removing the conflicting packages...${CEND}"
  55. [ -z "`grep -w epel /etc/yum.repos.d/*.repo`" ] && yum -y install epel-release
  56. if [ "${CentOS_ver}" == '8' ]; then
  57. if grep -qw "^\[PowerTools\]" /etc/yum.repos.d/*.repo; then
  58. dnf -y --enablerepo=PowerTools install chrony oniguruma-devel rpcgen
  59. else
  60. dnf -y --enablerepo=powertools install chrony oniguruma-devel rpcgen
  61. fi
  62. systemctl enable chronyd
  63. systemctl stop firewalld && systemctl mask firewalld.service
  64. elif [ "${CentOS_ver}" == '7' ]; then
  65. yum -y groupremove "Basic Web Server" "MySQL Database server" "MySQL Database client"
  66. systemctl stop firewalld && systemctl mask firewalld.service
  67. elif [ "${CentOS_ver}" == '6' ]; then
  68. yum -y groupremove "FTP Server" "PostgreSQL Database client" "PostgreSQL Database server" "MySQL Database server" "MySQL Database client" "Web Server"
  69. fi
  70. if [ ${CentOS_ver} -ge 7 >/dev/null 2>&1 ] && [ "${iptables_flag}" == 'y' ]; then
  71. yum -y install iptables-services
  72. systemctl enable iptables.service
  73. systemctl enable ip6tables.service
  74. fi
  75. echo "${CMSG}Installing dependencies packages...${CEND}"
  76. # Install needed packages
  77. pkgList="deltarpm 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 ntpdate sqlite-devel sysstat patch bc expect expat-devel oniguruma oniguruma-devel libtirpc-devel nss rsync rsyslog git lsof lrzsz psmisc wget which libatomic tmux"
  78. for Package in ${pkgList}; do
  79. yum -y install ${Package}
  80. done
  81. [ ${CentOS_ver} -lt 8 >/dev/null 2>&1 ] && yum -y install cmake3
  82. yum -y update bash openssl glibc
  83. }
  84. installDepsUbuntu() {
  85. # Uninstall the conflicting software
  86. echo "${CMSG}Removing the conflicting packages...${CEND}"
  87. if [ "${apache_flag}" == 'y' ]; then
  88. killall apache2
  89. 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"
  90. for Package in ${pkgList};do
  91. apt-get -y purge ${Package}
  92. done
  93. dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
  94. fi
  95. if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then
  96. pkgList="mysql-client mysql-server mysql-common mysql-server-core-5.5 mysql-client-5.5 mariadb-client mariadb-server mariadb-common"
  97. for Package in ${pkgList};do
  98. apt-get -y purge ${Package}
  99. done
  100. dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
  101. fi
  102. echo "${CMSG}Installing dependencies packages...${CEND}"
  103. apt-get -y update
  104. apt-get -y autoremove
  105. apt-get -yf install
  106. export DEBIAN_FRONTEND=noninteractive
  107. # critical security updates
  108. grep security /etc/apt/sources.list > /tmp/security.sources.list
  109. apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
  110. # Install needed packages
  111. 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 iptables rsyslog libonig-dev libtirpc-dev libnss3 rsync git lsof lrzsz ntpdate psmisc wget sysv-rc"
  112. export DEBIAN_FRONTEND=noninteractive
  113. for Package in ${pkgList}; do
  114. apt-get --no-install-recommends -y install ${Package}
  115. done
  116. if [[ "${Ubuntu_ver}" =~ ^14$|^15$ ]]; then
  117. apt-get -y remove bison
  118. fi
  119. }
  120. installDepsBySrc() {
  121. pushd ${oneinstack_dir}/src > /dev/null
  122. if [ "${OS}" == 'Ubuntu' ]; then
  123. if [[ "${Ubuntu_ver}" =~ ^14$|^15$ ]]; then
  124. # Install bison on ubt 14.x 15.x
  125. tar xzf bison-${bison_ver}.tar.gz
  126. pushd bison-${bison_ver} > /dev/null
  127. ./configure
  128. make -j ${THREAD} && make install
  129. popd > /dev/null
  130. rm -rf bison-${bison_ver}
  131. fi
  132. elif [ "${OS}" == 'CentOS' ]; then
  133. # install htop
  134. if ! command -v htop >/dev/null 2>&1; then
  135. tar xzf htop-${htop_ver}.tar.gz
  136. pushd htop-${htop_ver} > /dev/null
  137. ./configure
  138. make -j ${THREAD} && make install
  139. popd > /dev/null
  140. rm -rf htop-${htop_ver}
  141. fi
  142. # upgrade autoconf for CentOS6
  143. [ "${CentOS_ver}" == '6' ] && rpm -Uvh autoconf-2.69-12.2.noarch.rpm
  144. else
  145. echo "No need to install software from source packages."
  146. fi
  147. if ! command -v icu-config > /dev/null 2>&1 || icu-config --version | grep '^3.' || [ "${Ubuntu_ver}" == "20" ]; then
  148. tar xzf icu4c-${icu4c_ver}-src.tgz
  149. pushd icu/source > /dev/null
  150. ./configure --prefix=/usr/local
  151. make -j ${THREAD} && make install
  152. popd > /dev/null
  153. rm -rf icu
  154. fi
  155. if command -v lsof >/dev/null 2>&1; then
  156. echo 'already initialize' > ~/.oneinstack
  157. else
  158. echo "${CFAILURE}${PM} config error parsing file failed${CEND}"
  159. kill -9 $$
  160. fi
  161. popd > /dev/null
  162. }