1
0

check_sw.sh 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #!/bin/bash
  2. # Author: Alpha Eva <kaneawk AT gmail.com>
  3. #
  4. # Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
  5. #
  6. # Project home page:
  7. # https://oneinstack.com
  8. # https://github.com/lj2007331/oneinstack
  9. installDepsDebian() {
  10. echo "${CMSG}Removing the conflicting packages...${CEND}"
  11. pkgList="apache2 apache2-data apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-client mysql-server mysql-common libmysqlclient18 php5 php5-common php5-cgi php5-mysql php5-curl php5-gd libmysql* mysql-*"
  12. for Package in ${pkgList};do
  13. apt-get -y remove --purge ${Package}
  14. done
  15. dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
  16. apt-get -y update
  17. echo "${CMSG}Installing dependencies packages...${CEND}"
  18. # critical security updates
  19. grep security /etc/apt/sources.list > /tmp/security.sources.list
  20. apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
  21. apt-get autoremove
  22. # Install needed packages
  23. case "${Debian_version}" in
  24. [6,7])
  25. pkgList="gcc g++ make cmake autoconf libjpeg8 libjpeg8-dev libjpeg-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev numactl libreadline-dev curl libcurl3 libcurl4-openssl-dev libcurl4-gnutls-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libssl-dev libtool libevent-dev bison re2c libsasl2-dev libxslt1-dev libicu-dev locales libcloog-ppl0 patch vim zip unzip tmux htop bc expect rsync git lsof lrzsz cron logrotate ntpdate psmisc wget"
  26. ;;
  27. 8)
  28. pkgList="gcc g++ make cmake autoconf libjpeg8 libjpeg62-turbo-dev libjpeg-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev numactl libreadline-dev curl libcurl3 libcurl4-openssl-dev libcurl4-gnutls-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libssl-dev libtool libevent-dev bison re2c libsasl2-dev libxslt1-dev libicu-dev locales libcloog-ppl0 patch vim zip unzip tmux htop bc expect rsync git lsof lrzsz cron logrotate ntpdate psmisc wget"
  29. ;;
  30. *)
  31. echo "${CFAILURE}Your system Debian ${Debian_version} are not supported!${CEND}"
  32. kill -9 $$
  33. ;;
  34. esac
  35. for Package in ${pkgList}; do
  36. apt-get -y install ${Package}
  37. done
  38. }
  39. installDepsCentOS() {
  40. sed -i 's@^exclude@#exclude@' /etc/yum.conf
  41. yum clean all
  42. yum makecache
  43. # Uninstall the conflicting packages
  44. echo "${CMSG}Removing the conflicting packages...${CEND}"
  45. if [ "${CentOS_RHEL_version}" == '7' ]; then
  46. yum -y groupremove "Basic Web Server" "MySQL Database server" "MySQL Database client" "File and Print Server"
  47. yum -y install iptables-services
  48. systemctl mask firewalld.service
  49. systemctl enable iptables.service
  50. elif [ "${CentOS_RHEL_version}" == '6' ]; then
  51. yum -y groupremove "FTP Server" "PostgreSQL Database client" "PostgreSQL Database server" "MySQL Database server" "MySQL Database client" "Web Server" "Office Suite and Productivity" "E-mail server" "Ruby Support" "Printing client"
  52. elif [ "${CentOS_RHEL_version}" == '5' ]; then
  53. yum -y groupremove "FTP Server" "Windows File Server" "PostgreSQL Database" "News Server" "MySQL Database" "DNS Name Server" "Web Server" "Dialup Networking Support" "Mail Server" "Ruby" "Office/Productivity" "Sound and Video" "Printing Support" "OpenFabrics Enterprise Distribution"
  54. fi
  55. echo "${CMSG}Installing dependencies packages...${CEND}"
  56. yum check-update
  57. # Install needed packages
  58. pkgList="deltarpm gcc gcc-c++ make cmake autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel libaio numactl-libs readline-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel libxslt-devel libicu-devel libevent-devel libtool libtool-ltdl bison gd-devel vim-enhanced pcre-devel zip unzip ntpdate sysstat patch bc expect rsync git lsof lrzsz wget"
  59. for Package in ${pkgList}; do
  60. yum -y install ${Package}
  61. done
  62. yum -y update bash openssl glibc
  63. # use gcc-4.4
  64. if [ -n "$(gcc --version | head -n1 | grep '4\.1\.')" ]; then
  65. yum -y install gcc44 gcc44-c++ libstdc++44-devel
  66. export CC="gcc44" CXX="g++44"
  67. fi
  68. }
  69. installDepsUbuntu() {
  70. # Uninstall the conflicting software
  71. echo "${CMSG}Removing the conflicting packages...${CEND}"
  72. pkgList="apache2 apache2-data apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-client mysql-server mysql-common libmysqlclient18 php5 php5-common php5-cgi php5-mysql php5-curl php5-gd libmysql* mysql-*"
  73. for Package in ${pkgList}; do
  74. apt-get -y remove --purge ${Package}
  75. done
  76. dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
  77. apt-get autoremove
  78. echo "${CMSG}Installing dependencies packages...${CEND}"
  79. apt-get -y update
  80. # critical security updates
  81. grep security /etc/apt/sources.list > /tmp/security.sources.list
  82. apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
  83. # Install needed packages
  84. pkgList="gcc g++ make cmake autoconf libjpeg8 libjpeg8-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev numactl libreadline-dev curl libcurl3 libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libssl-dev libtool libevent-dev re2c libsasl2-dev libxslt1-dev libicu-dev patch vim zip unzip tmux htop bc expect rsync git lsof lrzsz ntpdate wget"
  85. for Package in ${pkgList}; do
  86. apt-get -y install ${Package} --force-yes
  87. done
  88. if [[ "${Ubuntu_version}" =~ ^14$|^15$ ]]; then
  89. apt-get -y install libcloog-ppl1
  90. apt-get -y remove bison
  91. ln -sf /usr/include/freetype2 /usr/include/freetype2/freetype
  92. elif [ "${Ubuntu_version}" == "13" ]; then
  93. apt-get -y install bison libcloog-ppl1
  94. elif [ "${Ubuntu_version}" == "12" ]; then
  95. apt-get -y install bison libcloog-ppl0
  96. else
  97. apt-get -y install bison libcloog-ppl1
  98. fi
  99. }
  100. installDepsBySrc() {
  101. pushd ${oneinstack_dir}/src
  102. if [ "${OS}" == "Ubuntu" ]; then
  103. if [[ "${Ubuntu_version}" =~ ^14$|^15$ ]]; then
  104. # Install bison on ubt 14.x 15.x
  105. tar xzf bison-${bison_version}.tar.gz
  106. pushd bison-${bison_version}
  107. ./configure
  108. make -j ${THREAD} && make install
  109. popd
  110. rm -rf bison-${bison_version}
  111. fi
  112. elif [ "${OS}" == "CentOS" ]; then
  113. # Install tmux
  114. if [ ! -e "$(which tmux)" ]; then
  115. # Install libevent first
  116. tar xzf libevent-${libevent_version}.tar.gz
  117. pushd libevent-${libevent_version}
  118. ./configure
  119. make -j ${THREAD} && make install
  120. popd
  121. rm -rf libevent-${libevent_version}
  122. tar xzf tmux-${tmux_version}.tar.gz
  123. pushd tmux-${tmux_version}
  124. CFLAGS="-I/usr/local/include" LDFLAGS="-L//usr/local/lib" ./configure
  125. make -j ${THREAD} && make install
  126. popd
  127. rm -rf tmux-${tmux_version}
  128. if [ "${OS_BIT}" == "64" ]; then
  129. ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
  130. else
  131. ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
  132. fi
  133. fi
  134. # install htop
  135. if [ ! -e "$(which htop)" ]; then
  136. tar xzf htop-${htop_version}.tar.gz
  137. pushd htop-${htop_version}
  138. ./configure
  139. make -j ${THREAD} && make install
  140. popd
  141. rm -rf htop-${htop_version}
  142. fi
  143. else
  144. echo "No need to install software from source packages."
  145. fi
  146. popd
  147. }