check_sw.sh 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #!/bin/bash
  2. # Author: Alpha Eva <kaneawk AT gmail.com>
  3. #
  4. # Notes: OneinStack for CentOS/RadHat 6+ 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-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 -y autoremove
  22. # Install needed packages
  23. case "${Debian_ver}" 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 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 libcurl4-openssl-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 dc expect libexpat1-dev rsync git lsof lrzsz iptables rsyslog cron logrotate ntpdate libsqlite3-dev psmisc wget sysv-rc ca-certificates"
  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 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 libcurl4-openssl-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 dc expect libexpat1-dev rsync git lsof lrzsz iptables rsyslog cron logrotate ntpdate libsqlite3-dev psmisc wget sysv-rc ca-certificates"
  29. ;;
  30. 9)
  31. pkgList="gcc g++ make cmake autoconf libjpeg62-turbo-dev libjpeg-dev libpng-dev libfreetype6 libfreetype6-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 libcurl4-openssl-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-ppl1 patch vim zip unzip tmux htop bc dc expect libexpat1-dev rsync git lsof lrzsz iptables rsyslog cron logrotate ntpdate libsqlite3-dev psmisc wget sysv-rc ca-certificates"
  32. ;;
  33. *)
  34. echo "${CFAILURE}Your system Debian ${Debian_ver} are not supported!${CEND}"
  35. kill -9 $$
  36. ;;
  37. esac
  38. for Package in ${pkgList}; do
  39. apt-get -y install ${Package}
  40. done
  41. }
  42. installDepsCentOS() {
  43. sed -i 's@^exclude@#exclude@' /etc/yum.conf
  44. yum clean all
  45. yum makecache
  46. # Uninstall the conflicting packages
  47. echo "${CMSG}Removing the conflicting packages...${CEND}"
  48. if [ "${CentOS_ver}" == '7' ]; then
  49. yum -y groupremove "Basic Web Server" "MySQL Database server" "MySQL Database client" "File and Print Server"
  50. systemctl mask firewalld.service
  51. if [ "${iptables_yn}" == 'y' ]; then
  52. yum -y install iptables-services
  53. systemctl enable iptables.service
  54. fi
  55. elif [ "${CentOS_ver}" == '6' ]; then
  56. 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"
  57. elif [ "${CentOS_ver}" == '5' ]; then
  58. 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"
  59. fi
  60. echo "${CMSG}Installing dependencies packages...${CEND}"
  61. yum check-update
  62. # Install needed packages
  63. 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 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 libxslt-devel libicu-devel libevent-devel libtool libtool-ltdl bison gd-devel vim-enhanced pcre-devel zip unzip ntpdate sqlite-devel sysstat patch bc expect expat-devel rsync rsyslog git lsof lrzsz wget"
  64. for Package in ${pkgList}; do
  65. yum -y install ${Package}
  66. done
  67. yum -y update bash openssl glibc
  68. # use gcc-4.4
  69. if [ -n "$(gcc --version | head -n1 | grep '4\.1\.')" ]; then
  70. yum -y install gcc44 gcc44-c++ libstdc++44-devel
  71. export CC="gcc44" CXX="g++44"
  72. fi
  73. }
  74. installDepsUbuntu() {
  75. # Uninstall the conflicting software
  76. echo "${CMSG}Removing the conflicting packages...${CEND}"
  77. pkgList="apache2 apache2-data apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-mpm-worker mysql-client mysql-server mysql-common libmysqlclient18 php5 php5-common php5-cgi php5-mysql php5-curl php5-gd libmysql* mysql-*"
  78. for Package in ${pkgList}; do
  79. apt-get -y remove --purge ${Package}
  80. done
  81. dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
  82. apt-get autoremove
  83. echo "${CMSG}Installing dependencies packages...${CEND}"
  84. apt-get -y update
  85. # critical security updates
  86. grep security /etc/apt/sources.list > /tmp/security.sources.list
  87. apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
  88. # Install needed packages
  89. 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 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 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 libsqlite3-dev patch vim zip unzip tmux htop bc dc expect libexpat1-dev iptables rsyslog rsync git lsof lrzsz ntpdate wget sysv-rc"
  90. for Package in ${pkgList}; do
  91. apt-get -y install ${Package} --force-yes
  92. done
  93. if [[ "${Ubuntu_ver}" =~ ^14$|^15$ ]]; then
  94. apt-get -y install libcloog-ppl1
  95. apt-get -y remove bison
  96. ln -sf /usr/include/freetype2 /usr/include/freetype2/freetype
  97. elif [ "${Ubuntu_ver}" == "13" ]; then
  98. apt-get -y install bison libcloog-ppl1
  99. elif [ "${Ubuntu_ver}" == "12" ]; then
  100. apt-get -y install bison libcloog-ppl0
  101. else
  102. apt-get -y install bison libcloog-ppl1
  103. fi
  104. }
  105. installDepsBySrc() {
  106. pushd ${oneinstack_dir}/src > /dev/null
  107. if [ "${OS}" == "Ubuntu" ]; then
  108. if [[ "${Ubuntu_ver}" =~ ^14$|^15$ ]]; then
  109. # Install bison on ubt 14.x 15.x
  110. tar xzf bison-${bison_ver}.tar.gz
  111. pushd bison-${bison_ver}
  112. ./configure
  113. make -j ${THREAD} && make install
  114. popd
  115. rm -rf bison-${bison_ver}
  116. fi
  117. elif [ "${OS}" == "CentOS" ]; then
  118. # Install tmux
  119. if [ ! -e "$(which tmux)" ]; then
  120. # Install libevent first
  121. tar xzf libevent-${libevent_ver}.tar.gz
  122. pushd libevent-${libevent_ver}
  123. ./configure
  124. make -j ${THREAD} && make install
  125. popd
  126. rm -rf libevent-${libevent_ver}
  127. tar xzf tmux-${tmux_ver}.tar.gz
  128. pushd tmux-${tmux_ver}
  129. CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" ./configure
  130. make -j ${THREAD} && make install
  131. unset LDFLAGS
  132. popd
  133. rm -rf tmux-${tmux_ver}
  134. if [ "${OS_BIT}" == "64" ]; then
  135. ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
  136. else
  137. ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
  138. fi
  139. fi
  140. # install htop
  141. if [ ! -e "$(which htop)" ]; then
  142. tar xzf htop-${htop_ver}.tar.gz
  143. pushd htop-${htop_ver}
  144. ./configure
  145. make -j ${THREAD} && make install
  146. popd
  147. rm -rf htop-${htop_ver}
  148. fi
  149. else
  150. echo "No need to install software from source packages."
  151. fi
  152. echo 'already initialize' > ~/.oneinstack
  153. popd
  154. }