Explorar el Código

[feat] Add Nodejs

lj2007331@gmail.com hace 3 años
padre
commit
3964ca836a
Se han modificado 10 ficheros con 108 adiciones y 19 borrados
  1. 7 0
      include/check_download.sh
  2. 5 3
      include/check_os.sh
  3. 1 3
      include/init_CentOS.sh
  4. 35 0
      include/node.sh
  5. 1 1
      include/upgrade_db.sh
  6. 1 1
      include/upgrade_web.sh
  7. 23 1
      install.sh
  8. 2 0
      options.conf
  9. 23 3
      uninstall.sh
  10. 10 7
      versions.txt

+ 7 - 0
include/check_download.sh

@@ -704,6 +704,13 @@ checkDownload() {
     src_url=https://pecl.php.net/get/mongodb-${pecl_mongodb_ver}.tgz && Download_src
   fi
 
+  # nodejs
+  if [ "${node_flag}" == 'y' ]; then
+    echo "Download Nodejs..."
+    [ "${IPADDR_COUNTRY}"x == "CN"x ] && DOWN_ADDR_NODE=https://nodejs.org/dist || DOWN_ADDR_NODE=https://mirrors.tuna.tsinghua.edu.cn/nodejs-release
+    src_url=${DOWN_ADDR_NODE}/v${node_ver}/node-v${node_ver}-linux-${SYS_BIT_n}.tar.gz && Download_src
+  fi
+
   # pureftpd
   if [ "${pureftpd_flag}" == 'y' ]; then
     echo "Download pureftpd..."

+ 5 - 3
include/check_os.sh

@@ -40,7 +40,7 @@ command -v lsb_release >/dev/null 2>&1 || { echo "${CFAILURE}${PM} source failed
 
 # Get OS Version
 OS=$(lsb_release -is)
-if [[ "${OS}" =~ ^CentOS$|^RedHat$|^Rocky$|^Fedora$|^Amazon$|^Alibaba$|^Aliyun$|^EulerOS$|^openEuler$ ]]; then
+if [[ "${OS}" =~ ^CentOS$|^CentOSStream$|^RedHat$|^Rocky$|^Fedora$|^Amazon$|^Alibaba$|^Aliyun$|^EulerOS$|^openEuler$ ]]; then
   LikeOS=CentOS
   CentOS_ver=$(lsb_release -rs | awk -F. '{print $1}' | awk '{print $1}')
   [[ "${OS}" =~ ^Fedora$ ]] && [ ${CentOS_ver} -ge 19 >/dev/null 2>&1 ] && { CentOS_ver=7; Fedora_ver=$(lsb_release -rs); }
@@ -99,7 +99,8 @@ if [ "$(getconf WORD_BIT)" == "32" ] && [ "$(getconf LONG_BIT)" == "64" ]; then
   SYS_BIT_b=x86_64 #mariadb
   SYS_BIT_c=x86_64 #ZendGuardLoader
   SYS_BIT_d=x86-64 #ioncube
-  [ "${TARGET_ARCH}" == 'aarch64' ] && { SYS_BIT_j=aarch64; SYS_BIT_c=aarch64; SYS_BIT_d=aarch64; }
+  SYS_BIT_n=x64 #node
+  [ "${TARGET_ARCH}" == 'aarch64' ] && { SYS_BIT_j=aarch64; SYS_BIT_c=aarch64; SYS_BIT_d=aarch64; SYS_BIT_n=arm64; }
 else
   OS_BIT=32
   SYS_BIT_j=i586
@@ -107,7 +108,8 @@ else
   SYS_BIT_b=i686
   SYS_BIT_c=i386
   SYS_BIT_d=x86
-  [ "${TARGET_ARCH}" == 'armv7' ] && { SYS_BIT_j=arm32-vfp-hflt; SYS_BIT_c=armhf; SYS_BIT_d=armv7l; }
+  SYS_BIT_n=x86
+  [ "${TARGET_ARCH}" == 'armv7' ] && { SYS_BIT_j=arm32-vfp-hflt; SYS_BIT_c=armhf; SYS_BIT_d=armv7l; SYS_BIT_n=armv7l; }
 fi
 
 THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l)

+ 1 - 3
include/init_CentOS.sh

@@ -102,12 +102,10 @@ if [ "${CentOS_ver}" == '6' ]; then
   sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES=/dev/tty[1-2]@' /etc/sysconfig/init
   sed -i 's@^start@#start@' /etc/init/control-alt-delete.conf
   sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/sysconfig/i18n
-elif [ ${CentOS_ver} -ge 7 >/dev/null 2>&1 ]; then 
+elif [ ${CentOS_ver} -ge 7 >/dev/null 2>&1 ]; then
   sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/locale.conf
 fi
 
-[ "${CentOS_ver}" == '8' ] && dnf --enablerepo=PowerTools install -y rpcgen
-
 # Update time
 if [ -e "$(which ntpdate)" ]; then
   ntpdate -u pool.ntp.org

+ 35 - 0
include/node.sh

@@ -0,0 +1,35 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://linuxeye.com
+#
+# Notes: OneinStack for CentOS/RedHat 7+ Debian 8+ and Ubuntu 16+
+#
+# Project home page:
+#       https://oneinstack.com
+#       https://github.com/oneinstack/oneinstack
+
+Install_Node() {
+  pushd ${oneinstack_dir}/src > /dev/null
+  tar xzf node-v${node_ver}-linux-${SYS_BIT_n}.tar.gz
+  /bin/mv node-v${node_ver}-linux-${SYS_BIT_n} ${node_install_dir}
+  if [ -e "${node_install_dir}/bin/node" ]; then
+    cat > /etc/profile.d/node.sh << EOF
+export NODE_HOME=${node_install_dir}
+export PATH=\$NODE_HOME/bin:\$PATH
+EOF
+    . /etc/profile
+    echo "${CSUCCESS}Nodejs installed successfully! ${CEND}"
+  else
+    echo "${CFAILURE}Nodejs install failed, Please contact the author! ${CEND}" && lsb_release -a
+    kill -9 $$
+  fi
+  popd > /dev/null
+}
+
+Uninstall_Node() {
+  if [ -e "${node_install_dir}" ]; then
+    rm -rf ${node_install_dir} /etc/profile.d/node.sh
+    echo "${CMSG}Node uninstall completed! ${CEND}"
+  fi
+}
+

+ 1 - 1
include/upgrade_db.sh

@@ -42,7 +42,7 @@ Upgrade_DB() {
   else
     [ "${IPADDR_COUNTRY}"x == "CN"x ] && DOWN_ADDR=http://mirrors.ustc.edu.cn/mysql-ftp/Downloads || DOWN_ADDR=http://cdn.mysql.com/Downloads
     DB=MySQL
-    OLD_db_ver=${OLD_db_ver_tmp}
+    OLD_db_ver=${OLD_db_ver_tmp%%-log}
   fi
 
   #backup

+ 1 - 1
include/upgrade_web.sh

@@ -13,7 +13,7 @@ Upgrade_Nginx() {
   [ ! -e "${nginx_install_dir}/sbin/nginx" ] && echo "${CWARNING}Nginx is not installed on your system! ${CEND}" && exit 1
   OLD_nginx_ver_tmp=`${nginx_install_dir}/sbin/nginx -v 2>&1`
   OLD_nginx_ver=${OLD_nginx_ver_tmp##*/}
-  Latest_nginx_ver=`curl --connect-timeout 2 -m 3 -s http://nginx.org/en/CHANGES-1.14 | awk '/Changes with nginx/{print$0}' | awk '{print $4}' | head -1`
+  Latest_nginx_ver=`curl --connect-timeout 2 -m 3 -s http://nginx.org/en/CHANGES-1.20 | awk '/Changes with nginx/{print$0}' | awk '{print $4}' | head -1`
   [ -z "${Latest_nginx_ver}" ] && Latest_nginx_ver=`curl --connect-timeout 2 -m 3 -s http://nginx.org/en/CHANGES | awk '/Changes with nginx/{print$0}' | awk '{print $4}' | head -1`
   echo
   echo "Current Nginx Version: ${CMSG}${OLD_nginx_ver}${CEND}"

+ 23 - 1
install.sh

@@ -56,6 +56,7 @@ Show_Help() {
   --php_extensions [ext name] Install PHP extensions, include zendguardloader,ioncube,
                               sourceguardian,imagick,gmagick,fileinfo,imap,ldap,calendar,phalcon,
                               yaf,yar,redis,memcached,memcache,mongodb,swoole,xdebug
+  --node                      Install Nodejs
   --tomcat_option [1-4]       Install Tomcat version
   --jdk_option [1-4]          Install JDK version
   --db_option [1-14]          Install DB version
@@ -72,7 +73,7 @@ Show_Help() {
   "
 }
 ARG_NUM=$#
-TEMP=`getopt -o hvV --long help,version,nginx_option:,apache,apache_mode_option:,apache_mpm_option:,php_option:,mphp_ver:,mphp_addons,phpcache_option:,php_extensions:,tomcat_option:,jdk_option:,db_option:,dbrootpwd:,dbinstallmethod:,pureftpd,redis,memcached,phpmyadmin,python,ssh_port:,iptables,reboot -- "$@" 2>/dev/null`
+TEMP=`getopt -o hvV --long help,version,nginx_option:,apache,apache_mode_option:,apache_mpm_option:,php_option:,mphp_ver:,mphp_addons,phpcache_option:,php_extensions:,node,tomcat_option:,jdk_option:,db_option:,dbrootpwd:,dbinstallmethod:,pureftpd,redis,memcached,phpmyadmin,python,ssh_port:,iptables,reboot -- "$@" 2>/dev/null`
 [ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1
 eval set -- "${TEMP}"
 while :; do
@@ -139,6 +140,10 @@ while :; do
       [ -n "`echo ${php_extensions} | grep -w swoole`" ] && pecl_swoole=1
       [ -n "`echo ${php_extensions} | grep -w xdebug`" ] && pecl_xdebug=1
       ;;
+    --node)
+      node_flag=y; shift 1
+      [ -e "${node_install_dir}/bin/node" ] && { echo "${CWARNING}Nodejs already installed! ${CEND}"; unset node_flag; }
+      ;;
     --tomcat_option)
       tomcat_option=$2; shift 2
       [[ ! ${tomcat_option} =~ ^[1-4]$ ]] && { echo "${CWARNING}tomcat_option input error! Please only input number 1~4${CEND}"; exit 1; }
@@ -643,6 +648,17 @@ if [ ${ARG_NUM} == 0 ]; then
     done
   fi
 
+  # check Nodejs
+  while :; do echo
+    read -e -p "Do you want to install Nodejs? [y/n]: " node_flag
+    if [[ ! ${node_flag} =~ ^[y,n]$ ]]; then
+      echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+    else
+      [ "${node_flag}" == 'y' -a -e "${node_install_dir}/bin/node" ] && { echo "${CWARNING}Nodejs already installed! ${CEND}"; unset node_flag; }
+      break
+    fi
+  done
+
   # check Pureftpd
   while :; do echo
     read -e -p "Do you want to install Pure-FTPd? [y/n]: " pureftpd_flag
@@ -1076,6 +1092,12 @@ case "${tomcat_option}" in
     ;;
 esac
 
+# Nodejs
+if [ "${node_flag}" == 'y' ]; then
+  . include/node.sh
+  Install_Node 2>&1 | tee -a ${oneinstack_dir}/install.log
+fi
+
 # Pure-FTPd
 if [ "${pureftpd_flag}" == 'y' ]; then
   . include/pureftpd.sh

+ 2 - 0
options.conf

@@ -21,6 +21,8 @@ mongo_install_dir=/usr/local/mongodb
 
 php_install_dir=/usr/local/php
 
+node_install_dir=/usr/local/node
+
 pureftpd_install_dir=/usr/local/pureftpd
 
 memcached_install_dir=/usr/local/memcached

+ 23 - 3
uninstall.sh

@@ -49,11 +49,12 @@ Show_Help() {
   --memcached                   Uninstall Memcached-server
   --phpmyadmin                  Uninstall phpMyAdmin
   --python                      Uninstall Python (PATH: ${python_install_dir})
+  --node                        Uninstall Nodejs (PATH: ${node_install_dir})
   "
 }
 
 ARG_NUM=$#
-TEMP=`getopt -o hvVq --long help,version,quiet,all,web,mysql,postgresql,mongodb,php,mphp_ver:,allphp,phpcache,php_extensions:,pureftpd,redis,memcached,phpmyadmin,python -- "$@" 2>/dev/null`
+TEMP=`getopt -o hvVq --long help,version,quiet,all,web,mysql,postgresql,mongodb,php,mphp_ver:,allphp,phpcache,php_extensions:,pureftpd,redis,memcached,phpmyadmin,python,node -- "$@" 2>/dev/null`
 [ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1
 eval set -- "${TEMP}"
 while :; do
@@ -74,6 +75,7 @@ while :; do
       postgresql_flag=y
       mongodb_flag=y
       allphp_flag=y
+      node_flag=y
       pureftpd_flag=y
       redis_flag=y
       memcached_flag=y
@@ -127,6 +129,9 @@ while :; do
       [ -n "`echo ${php_extensions} | grep -w swoole`" ] && pecl_swoole=1
       [ -n "`echo ${php_extensions} | grep -w xdebug`" ] && pecl_xdebug=1
       ;;
+    --node)
+      node_flag=y; shift 1
+      ;;
     --pureftpd)
       pureftpd_flag=y; shift 1
       ;;
@@ -564,6 +569,11 @@ Print_Python() {
   [ -d "${python_install_dir}" ] && echo ${python_install_dir}
 }
 
+Print_Node() {
+  [ -e "${node_install_dir}" ] && echo ${node_install_dir}
+  [ -e "/etc/profile.d/node.sh" ] && echo /etc/profile.d/node.sh
+}
+
 Menu() {
 while :; do
   printf "
@@ -581,12 +591,13 @@ What Are You Doing?
 \t${CMSG}10${CEND}. Uninstall Memcached
 \t${CMSG}11${CEND}. Uninstall phpMyAdmin
 \t${CMSG}12${CEND}. Uninstall Python (PATH: ${python_install_dir})
+\t${CMSG}13${CEND}. Uninstall Nodejs (PATH: ${node_install_dir})
 \t${CMSG} q${CEND}. Exit
 "
   echo
   read -e -p "Please input the correct option: " Number
-  if [[ ! "${Number}" =~ ^[0-9,q]$|^1[0-2]$ ]]; then
-    echo "${CWARNING}input error! Please only input 0~12 and q${CEND}"
+  if [[ ! "${Number}" =~ ^[0-9,q]$|^1[0-3]$ ]]; then
+    echo "${CWARNING}input error! Please only input 0~13 and q${CEND}"
   else
     case "$Number" in
     0)
@@ -602,6 +613,7 @@ What Are You Doing?
       Print_openssl
       Print_phpMyAdmin
       Print_Python
+      Print_Node
       Uninstall_status
       if [ "${uninstall_flag}" == 'y' ]; then
         Uninstall_Web
@@ -615,6 +627,7 @@ What Are You Doing?
         Uninstall_openssl
         Uninstall_phpMyAdmin
         . include/python.sh; Uninstall_Python
+        . include/node.sh; Uninstall_Node
       else
         exit
       fi
@@ -682,6 +695,11 @@ What Are You Doing?
       Uninstall_status
       [ "${uninstall_flag}" == 'y' ] && { . include/python.sh; Uninstall_Python; } || exit
       ;;
+    13)
+      Print_Node
+      Uninstall_status
+      [ "${uninstall_flag}" == 'y' ] && { . include/node.sh; Uninstall_Node; } || exit
+      ;;
     q)
       exit
       ;;
@@ -708,6 +726,7 @@ else
   [ "${memcached_flag}" == 'y' ] && Print_Memcached_server
   [ "${phpmyadmin_flag}" == 'y' ] && Print_phpMyAdmin
   [ "${python_flag}" == 'y' ] && Print_Python
+  [ "${node_flag}" == 'y' ] && Print_Node
   [ "${all_flag}" == 'y' ] && Print_openssl
   Uninstall_status
   if [ "${uninstall_flag}" == 'y' ]; then
@@ -730,6 +749,7 @@ else
     [ "${memcached_flag}" == 'y' ] && Uninstall_Memcached_server
     [ "${phpmyadmin_flag}" == 'y' ] && Uninstall_phpMyAdmin
     [ "${python_flag}" == 'y' ] && { . include/python.sh; Uninstall_Python; }
+    [ "${node_flag}" == 'y' ] && { . include/node.sh; Uninstall_Node; }
     [ "${all_flag}" == 'y' ] && Uninstall_openssl
   fi
 fi

+ 10 - 7
versions.txt

@@ -2,7 +2,7 @@
 # Web
 nginx_ver=1.20.1
 tengine_ver=2.3.3
-openresty_ver=1.19.3.1
+openresty_ver=1.19.3.2
 openssl11_ver=1.1.1k
 openssl_ver=1.0.2u
 
@@ -11,7 +11,7 @@ tomcat9_ver=9.0.46
 tomcat8_ver=8.5.66
 tomcat7_ver=7.0.109
 
-apache_ver=2.4.46
+apache_ver=2.4.48
 pcre_ver=8.44
 apr_ver=1.7.0
 apr_util_ver=1.6.1
@@ -52,11 +52,14 @@ php70_ver=7.0.33
 php71_ver=7.1.33
 php72_ver=7.2.34
 php73_ver=7.3.28
-php74_ver=7.4.19
-php80_ver=8.0.6
+php74_ver=7.4.20
+php80_ver=8.0.7
+
+# Nodejs
+node_ver=14.17.0
 
 libiconv_ver=1.16
-curl_ver=7.76.1
+curl_ver=7.77.0
 libmcrypt_ver=2.5.8
 mcrypt_ver=2.6.8
 mhash_ver=0.9.9.9
@@ -88,7 +91,7 @@ xdebug_oldver=2.5.5
 pureftpd_ver=1.0.49
 
 # Redis
-redis_ver=6.2.3
+redis_ver=6.2.4
 redis_oldver=5.0.9
 pecl_redis_ver=5.3.4
 pecl_redis_oldver=4.3.0
@@ -106,7 +109,7 @@ pecl_mongodb_ver=1.9.1
 pecl_mongo_ver=1.6.16
 
 # phpMyadmin
-phpmyadmin_ver=5.1.0
+phpmyadmin_ver=5.1.1
 phpmyadmin_oldver=4.4.15.10
 
 # jemalloc