check_sw.sh 8.6 KB

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