Browse Source

Add php sourceguardian and phalcon

lj2007331@gmail.com 6 years ago
parent
commit
b0255ce5a5
6 changed files with 99 additions and 25 deletions
  1. 46 18
      addons.sh
  2. 11 2
      include/check_download.sh
  3. 1 1
      include/ioncube.sh
  4. 3 3
      include/ngx_lua_waf.sh
  5. 36 0
      include/sourceguardian.sh
  6. 2 1
      versions.txt

+ 46 - 18
addons.sh

@@ -43,6 +43,7 @@ IPADDR_COUNTRY=$(./include/get_ipaddr_state.py $PUBLIC_IPADDR)
 
 . ./include/ZendGuardLoader.sh
 . ./include/ioncube.sh
+. ./include/sourceguardian.sh
 
 . ./include/ImageMagick.sh
 . ./include/GraphicsMagick.sh
@@ -169,16 +170,16 @@ while :;do
   printf "
 What Are You Doing?
 \t${CMSG} 1${CEND}. Install/Uninstall PHP opcode cache
-\t${CMSG} 2${CEND}. Install/Uninstall ZendGuardLoader/ionCube PHP Extension
+\t${CMSG} 2${CEND}. Install/Uninstall ZendGuardLoader/ionCube/SourceGuardian PHP Extension
 \t${CMSG} 3${CEND}. Install/Uninstall ImageMagick/GraphicsMagick PHP Extension
-\t${CMSG} 4${CEND}. Install/Uninstall fileinfo/imap PHP Extension
+\t${CMSG} 4${CEND}. Install/Uninstall fileinfo/imap/phalcon PHP Extension
 \t${CMSG} 5${CEND}. Install/Uninstall memcached/memcache
 \t${CMSG} 6${CEND}. Install/Uninstall Redis
 \t${CMSG} 7${CEND}. Install/Uninstall swoole PHP Extension
 \t${CMSG} 8${CEND}. Install/Uninstall xdebug PHP Extension
 \t${CMSG} 9${CEND}. Install/Uninstall PHP Composer
 \t${CMSG}10${CEND}. Install/Uninstall fail2ban
-\t${CMSG}11${CEND}. Install/Uninstall ngx_lua_waf 
+\t${CMSG}11${CEND}. Install/Uninstall ngx_lua_waf
 \t${CMSG} q${CEND}. Exit
 "
   read -e -p "Please input the correct option: " Number
@@ -270,16 +271,18 @@ What Are You Doing?
       2)
         ACTION_FUN
         while :; do echo
-          echo "Please select ZendGuardLoader/ionCube:"
+          echo "Please select ZendGuardLoader/ionCube/SourceGuardian:"
           echo -e "\t${CMSG}1${CEND}. ZendGuardLoader"
           echo -e "\t${CMSG}2${CEND}. ionCube Loader"
+          echo -e "\t${CMSG}3${CEND}. SourceGuardian"
           read -e -p "Please input a number:(Default 1 press Enter) " Loader
           [ -z "${Loader}" ] && Loader=1
-          if [[ ! "${Loader}" =~ ^[1,2]$ ]]; then
-            echo "${CWARNING}input error! Please only input number 1~2${CEND}"
+          if [[ ! "${Loader}" =~ ^[1-3]$ ]]; then
+            echo "${CWARNING}input error! Please only input number 1~3${CEND}"
           else
             [ "${Loader}" = '1' ] && PHP_extension=ZendGuardLoader
             [ "${Loader}" = '2' ] && PHP_extension=ioncube
+            [ "${Loader}" = '3' ] && PHP_extension=sourceguardian
             break
           fi
         done
@@ -301,6 +304,14 @@ What Are You Doing?
             else
               echo; echo "${CWARNING}Your php ${PHP_detail_ver} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${CEND}";
             fi
+          elif [ "${Loader}" = '3' ]; then
+            if [[ "${PHP_main_ver}" =~ ^5.[3-6]$|^7.[0-2]$ ]] || [ "${TARGET_ARCH}" != "armv8" ]; then
+              sourceguardian_yn='y' && checkDownload
+              Install_SourceGuardian
+              Restart_PHP; echo "${CSUCCESS}PHP SourceGuardian module installed successfully! ${CEND}";
+            else
+              echo; echo "${CWARNING}Your php ${PHP_detail_ver} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${CEND}";
+            fi
           fi
         else
           Uninstall_succ
@@ -343,13 +354,14 @@ What Are You Doing?
       4)
         ACTION_FUN
         while :; do echo
-          echo "Please select fileinfo/imap:"
+          echo "Please select fileinfo/imap/phalcon:"
           echo -e "\t${CMSG}1${CEND}. fileinfo"
           echo -e "\t${CMSG}2${CEND}. imap"
+          echo -e "\t${CMSG}3${CEND}. phalcon"
           read -e -p "Please input a number:(Default 1 press Enter) " phpext_option
           [ -z "${phpext_option}" ] && phpext_option=1
-          if [[ ! "${phpext_option}" =~ ^[1,2]$ ]]; then
-            echo "${CWARNING}input error! Please only input number 1~2${CEND}"
+          if [[ ! "${phpext_option}" =~ ^[1-3]$ ]]; then
+            echo "${CWARNING}input error! Please only input number 1~3${CEND}"
           else
             if [ "${phpext_option}" = '1' ]; then
               PHP_extension=fileinfo
@@ -362,6 +374,8 @@ What Are You Doing?
               else
                 apt-get -y install libc-client2007e-dev
               fi
+            elif [ "${phpext_option}" = '3' ]; then
+              PHP_extension=phalcon
             fi
             break
           fi
@@ -370,15 +384,29 @@ What Are You Doing?
         if [ "${ACTION}" = '1' ]; then
           Check_PHP_Extension
           pushd ${oneinstack_dir}/src > /dev/null
-          src_url=http://www.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
-          tar xzf php-${PHP_detail_ver}.tar.gz
-          pushd php-${PHP_detail_ver}/ext/${PHP_extension}
-          ${php_install_dir}/bin/phpize
-          ./configure --with-php-config=${php_install_dir}/bin/php-config ${IMAP_ARGS}
-          make -j ${THREAD} && make install
-          popd;popd
-          rm -rf php-${PHP_detail_ver}
-          echo "extension=${PHP_extension}.so" > ${php_install_dir}/etc/php.d/04-${PHP_extension}.ini
+          if [[ "${phpext_option}" =~ ^[1-2]$ ]]; then
+            src_url=http://www.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
+            tar xzf php-${PHP_detail_ver}.tar.gz
+            pushd php-${PHP_detail_ver}/ext/${PHP_extension}
+            ${php_install_dir}/bin/phpize
+            ./configure --with-php-config=${php_install_dir}/bin/php-config ${IMAP_ARGS}
+            make -j ${THREAD} && make install
+            popd
+            rm -rf php-${PHP_detail_ver}
+          elif [ "${phpext_option}" = '3' ]; then
+            if [[ "${PHP_main_ver}" =~ ^5.[5-6]$|^7.[0-2]$ ]]; then
+              src_url=http://mirrors.linuxeye.com/oneinstack/src/cphalcon-${phalcon_ver}.tar.gz && Download_src
+              tar xzf cphalcon-${phalcon_ver}.tar.gz
+              pushd cphalcon-${phalcon_ver}/build
+              ./install --phpize ${php_install_dir}/bin/phpize --php-config ${php_install_dir}/bin/php-config --arch ${OS_BIT}bits
+              popd
+              rm -rf cphalcon-${phalcon_ver}
+            else
+              echo; echo "${CWARNING}Your php ${PHP_detail_ver} does not support ${PHP_extension}! ${CEND}";
+            fi
+          fi
+          popd
+          [ -f "${phpExtensionDir}/${PHP_extension}.so" ] && echo "extension=${PHP_extension}.so" > ${php_install_dir}/etc/php.d/04-${PHP_extension}.ini
           Check_succ
         else
           Uninstall_succ

+ 11 - 2
include/check_download.sh

@@ -107,7 +107,7 @@ checkDownload() {
 
   if [ "${db_yn}" == 'y' ]; then
     if [[ "${db_option}" =~ ^[1,2,5,6,9]$ ]] && [ "${dbinstallmethod}" == "2" ]; then
-      [[ "${db_option}" =~ ^[2,5,6,9]$ ]] && boost_ver=${boost_oldver} 
+      [[ "${db_option}" =~ ^[2,5,6,9]$ ]] && boost_ver=${boost_oldver}
       echo "Download boost..."
       [ "${IPADDR_COUNTRY}"x == "CN"x ] && DOWN_ADDR_BOOST=${mirrorLink} || DOWN_ADDR_BOOST=http://downloads.sourceforge.net/project/boost/boost/${boost_ver}
       boostVersion2=$(echo ${boost_ver} | awk -F. '{print $1"_"$2"_"$3}')
@@ -116,7 +116,7 @@ checkDownload() {
 
     case "${db_option}" in
       1)
-        # MySQL 8.0 
+        # MySQL 8.0
         if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
           DOWN_ADDR_MYSQL=http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-8.0
           DOWN_ADDR_MYSQL_BK=http://mirrors.huaweicloud.com/repository/toolkit/mysql/Downloads/MySQL-8.0
@@ -728,6 +728,15 @@ checkDownload() {
     fi
   fi
 
+  if [ "${sourceguardian_yn}" == 'y' ]; then
+    echo "Download SourceGuardian..."
+    if [ "${TARGET_ARCH}" == "armv8" ]; then
+      src_url=https://www.sourceguardian.com/loaders/download/loaders.linux-aarch64.tar.gz && Download_src
+    else
+      src_url=${mirrorLink}/loaders.linux-${SYS_BIT_c}.tar.gz && Download_src
+    fi
+  fi
+
   if [ "${magick_yn}" == 'y' ]; then
     if [ "${magick_option}" == '1' ]; then
       echo "Download ImageMagick..."

+ 1 - 1
include/ioncube.sh

@@ -92,5 +92,5 @@ Install_ionCube() {
 
   echo "zend_extension=${zend_extension}" > ${php_install_dir}/etc/php.d/00-ioncube.ini
   rm -rf ioncube
-  popd
+  popd > /dev/null
 }

+ 3 - 3
include/ngx_lua_waf.sh

@@ -32,15 +32,15 @@ Nginx_lua_waf() {
   ${nginx_install_dir}/sbin/nginx -V &> $$
   nginx_configure_args_tmp=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'`
   rm -rf $$
-  nginx_configure_args=`echo ${nginx_configure_args_tmp} | sed "s@--with-openssl=../openssl-...... @--with-openssl=../openssl-${openssl_ver} @" | sed "s@--with-pcre=../pcre-.... @--with-pcre=../pcre-${pcre_ver} @"`
+  nginx_configure_args=`echo ${nginx_configure_args_tmp} | sed "s@--with-openssl=../openssl-...... @--with-openssl=../openssl-${openssl11_ver} @" | sed "s@--with-pcre=../pcre-.... @--with-pcre=../pcre-${pcre_ver} @"`
   if [ -z "`echo ${nginx_configure_args} | grep lua-nginx-module`" ]; then
     src_url=http://nginx.org/download/nginx-${nginx_ver}.tar.gz && Download_src
-    src_url=https://www.openssl.org/source/openssl-${openssl_ver}.tar.gz && Download_src
+    src_url=https://www.openssl.org/source/openssl-${openssl11_ver}.tar.gz && Download_src
     src_url=http://mirrors.linuxeye.com/oneinstack/src/pcre-${pcre_ver}.tar.gz && Download_src
     src_url=http://mirrors.linuxeye.com/oneinstack/src/ngx_devel_kit.tar.gz && Download_src
     src_url=http://mirrors.linuxeye.com/oneinstack/src/lua-nginx-module.tar.gz && Download_src
     tar xzf nginx-${nginx_ver}.tar.gz
-    tar xzf openssl-${openssl_ver}.tar.gz
+    tar xzf openssl-${openssl11_ver}.tar.gz
     tar xzf pcre-${pcre_ver}.tar.gz
     tar xzf ngx_devel_kit.tar.gz
     tar xzf lua-nginx-module.tar.gz

+ 36 - 0
include/sourceguardian.sh

@@ -0,0 +1,36 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.cn
+#
+# Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+
+#
+# Project home page:
+#       https://oneinstack.com
+#       https://github.com/lj2007331/oneinstack
+
+Install_SourceGuardian() {
+  pushd ${oneinstack_dir}/src > /dev/null
+  PHP_detail_ver=`${php_install_dir}/bin/php -r 'echo PHP_VERSION;'`
+  PHP_main_ver=${PHP_detail_ver%.*}
+  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  [ ! -e sourceguardian ] && mkdir sourceguardian
+  if  [ "${TARGET_ARCH}" == "armv8" ]; then
+    tar xzf loaders.linux-aarch64.tar.gz -C sourceguardian
+  else
+    tar xzf loaders.linux-${SYS_BIT_c}.tar.gz -C sourceguardian
+  fi
+  [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
+  if [ -z "`echo ${phpExtensionDir} | grep 'non-zts'`" ]; then
+    /bin/cp sourceguardian/ixed.${PHP_main_ver}ts.lin ${phpExtensionDir}
+    extension="ixed.${PHP_main_ver}ts.lin"
+  else
+    /bin/cp sourceguardian/ixed.${PHP_main_ver}.lin ${phpExtensionDir}
+    extension="ixed.${PHP_main_ver}.lin"
+  fi
+
+  if [ -f "${phpExtensionDir}/ixed.${PHP_main_ver}.lin" ]; then
+    echo "extension=${extension}" > ${php_install_dir}/etc/php.d/02-sourceguardian.ini
+    rm -rf sourceguardian
+  fi
+  popd > /dev/null
+}

+ 2 - 1
versions.txt

@@ -25,7 +25,7 @@ mysql56_ver=5.6.42
 mysql55_ver=5.5.62
 
 mariadb103_ver=10.3.10
-mariadb102_ver=10.2.18
+mariadb102_ver=10.2.19
 mariadb101_ver=10.1.37
 mariadb100_ver=10.0.37
 mariadb55_ver=5.5.62
@@ -72,6 +72,7 @@ xcache_ver=3.2.0
 apcu_ver=4.0.11
 apcu_for_php7_ver=5.1.12
 eaccelerator_ver=0.9.6.1
+phalcon_ver=3.4.1
 swoole_ver=4.2.6
 xdebug_ver=2.6.1