Browse Source

Merge pull request #395 from kaneawk/deprecate-openssl102

Deprecate the openssl 1.0.2 now
yeho 3 years ago
parent
commit
a668866304
3 changed files with 42 additions and 12 deletions
  1. 11 9
      include/check_download.sh
  2. 25 1
      include/openssl.sh
  3. 6 2
      install.sh

+ 11 - 9
include/check_download.sh

@@ -17,9 +17,17 @@ checkDownload() {
   fi
 
   # General system utils
-  if [[ ${tomcat_option} =~ ^[1-4]$ ]] || [ "${apache_flag}" == 'y' ] || [[ ${php_option} =~ ^[1-9]$|^10$ ]]; then
-    echo "Download openSSL..."
-    src_url=https://www.openssl.org/source/old/1.0.2/openssl-${openssl_ver}.tar.gz && Download_src
+
+  # openssl
+  if [[ "${tomcat_option}" =~ ^[1-4]$ ]] || [ "${apache_flag}" == 'y' ] || [[ "${php_flag}" == 'y' ]] || "${mphp_flag}" == 'y' || [[ "${nginx_option}" =~ ^[1-3]$ ]]; then
+    # Only the deprecated PHP5 requires openssl 1.0.2
+    if [[ "${php_option}" =~ ^[1-4]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$ ]]; then
+      echo "Download openSSL 1.0.2..."
+      src_url=https://www.openssl.org/source/old/1.0.2/openssl-${openssl_ver}.tar.gz && Download_src
+    else
+      echo "Download openSSL 1.1..."
+      src_url=https://www.openssl.org/source/openssl-${openssl11_ver}.tar.gz && Download_src
+    fi
     echo "Download cacert.pem..."
     src_url=https://curl.se/ca/cacert.pem && Download_src
   fi
@@ -30,12 +38,6 @@ checkDownload() {
     src_url=${mirrorLink}/jemalloc-${jemalloc_ver}.tar.bz2 && Download_src
   fi
 
-  # openssl1.1
-  if [[ ${nginx_option} =~ ^[1-3]$ ]]; then
-      echo "Download openSSL1.1..."
-      src_url=https://www.openssl.org/source/openssl-${openssl11_ver}.tar.gz && Download_src
-  fi
-
   # nginx/tengine/openresty
   case "${nginx_option}" in
     1)

+ 25 - 1
include/openssl.sh

@@ -8,7 +8,7 @@
 #       https://oneinstack.com
 #       https://github.com/oneinstack/oneinstack
 
-Install_openSSL() {
+Install_openSSL102() {
   if [ -e "${openssl_install_dir}/lib/libssl.a" ]; then
     echo "${CWARNING}openSSL already installed! ${CEND}"
   else
@@ -31,3 +31,27 @@ Install_openSSL() {
     popd > /dev/null
   fi
 }
+
+Install_openSSL() {
+  if [ -e "${openssl_install_dir}/lib/libssl.a" ]; then
+    echo "${CWARNING}openSSL already installed! ${CEND}"
+  else
+    pushd ${oneinstack_dir}/src > /dev/null
+    tar xzf openssl-${openssl11_ver}.tar.gz
+    pushd openssl-${openssl11_ver} > /dev/null
+    make clean
+    ./config -Wl,-rpath=${openssl_install_dir}/lib -fPIC --prefix=${openssl_install_dir} --openssldir=${openssl_install_dir}
+    make depend
+    make -j ${THREAD} && make install
+    popd > /dev/null
+    if [ -f "${openssl_install_dir}/lib/libcrypto.a" ]; then
+      echo "${CSUCCESS}openssl installed successfully! ${CEND}"
+      /bin/cp cacert.pem ${openssl_install_dir}/cert.pem
+      rm -rf openssl-${openssl11_ver}
+    else
+      echo "${CFAILURE}openSSL install failed, Please contact the author! ${CEND}" && lsb_release -a
+      kill -9 $$
+    fi
+    popd > /dev/null
+  fi
+}

+ 6 - 2
install.sh

@@ -770,9 +770,13 @@ if [[ ${nginx_option} =~ ^[1-3]$ ]] || [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]];
 fi
 
 # openSSL
-if [[ ${tomcat_option} =~ ^[1-4]$ ]] || [ "${apache_flag}" == 'y' ] || [[ ${php_option} =~ ^[1-9]$|^10$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$|^7[0-4]$|^80$ ]]; then
+if [[ "${tomcat_option}" =~ ^[1-4]$ ]] || [ "${apache_flag}" == 'y' ] || [[ "${php_option}" =~ ^[1-9]$|^10$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$|^7[0-4]$|^80$ ]]; then
   . include/openssl.sh
-  Install_openSSL | tee -a ${oneinstack_dir}/install.log
+  if [[ "${php_option}" =~ ^[1-4]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$ ]]; then
+    Install_openSSL102 | tee -a ${oneinstack_dir}/install.log
+  else
+    Install_openSSL | tee -a ${oneinstack_dir}/install.log
+  fi
 fi
 
 # Database