Browse Source

Add MongoDB

lj2007331@gmail.com 7 years ago
parent
commit
fd44fa2f77
10 changed files with 643 additions and 15 deletions
  1. 9 1
      README.md
  2. 35 1
      include/check_download.sh
  3. 76 0
      include/mongodb.sh
  4. 46 0
      include/pecl_mongodb.sh
  5. 145 0
      init.d/MongoDB-init-CentOS
  6. 272 0
      init.d/MongoDB-init-Ubuntu
  7. 33 9
      install.sh
  8. 6 1
      options.conf
  9. 15 3
      uninstall.sh
  10. 6 0
      versions.txt

+ 9 - 1
README.md

@@ -6,7 +6,7 @@ Script properties:
 - Continually updated
 - Source compiler installation, most stable source is the latest version, and download from the official site
 - Some security optimization
-- Providing a plurality of database versions (MySQL-5.7, MySQL-5.6, MySQL-5.5, MariaDB-10.1, MariaDB-10.0, MariaDB-5.5, Percona-5.7, Percona-5.6, Percona-5.5, AliSQL-5.6, PostgreSQL)
+- Providing a plurality of database versions (MySQL-5.7, MySQL-5.6, MySQL-5.5, MariaDB-10.1, MariaDB-10.0, MariaDB-5.5, Percona-5.7, Percona-5.6, Percona-5.5, AliSQL-5.6, PostgreSQL, MongoDB)
 - Providing multiple PHP versions (PHP-7.2, PHP-7.1, PHP-7.0, PHP-5.6, PHP-5.5, PHP-5.4, PHP-5.3)
 - Provide Nginx, Tengine, OpenResty
 - Providing a plurality of Tomcat version (Tomcat-8, Tomcat-7, Tomcat-6)
@@ -91,6 +91,14 @@ MySQL/MariaDB/Percona:
 ```bash
 service mysqld {start|stop|restart|reload|status}
 ```
+PostgreSQL:
+```bash
+service postgresql {start|stop|restart|status} 
+```
+MongoDB:
+```bash
+service mongod {start|stop|status|restart|reload} 
+```
 PHP:
 ```bash
 service php-fpm {start|stop|restart|reload|status}

+ 35 - 1
include/check_download.sh

@@ -548,6 +548,30 @@ checkDownload() {
           echo "[${CMSG}${FILE_NAME}${CEND}] found."
         fi
         ;;
+      13) 
+        # MongoDB
+        echo "Download MongoDB binary package..."
+        FILE_NAME=mongodb-linux-${SYS_BIT_b}-${mongodb_version}.tgz
+        if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+          DOWN_ADDR_MongoDB=${mirrorLink}
+        else
+          DOWN_ADDR_MongoDB=https://fastdl.mongodb.org/linux
+        fi
+        MongoDB_TAR_MD5=$(curl -s ${DOWN_ADDR_MongoDB}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}')
+
+        tryDlCount=0
+        while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MongoDB_TAR_MD5}" ]; do
+          wget -c --no-check-certificate ${DOWN_ADDR_MongoDB}/${FILE_NAME};sleep 1
+          let "tryDlCount++"
+          [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MongoDB_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
+        done
+        if [ "${tryDlCount}" == '6' ]; then
+          echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
+          kill -9 $$
+        else
+          echo "[${CMSG}${FILE_NAME}${CEND}] found."
+        fi
+        ;;
     esac
   fi
   # PHP
@@ -595,7 +619,7 @@ checkDownload() {
   # PHP OPCache
   case "${PHP_cache}" in
     1)
-      if [[ "$PHP_version" =~ ^[1,2]$ ]]; then
+      if [[ "$PHP_version" =~ ^[1-2]$ ]]; then
         # php 5.3 5.4
         echo "Download Zend OPCache..."
         src_url=https://pecl.php.net/get/zendopcache-${zendopcache_version}.tgz && Download_src
@@ -679,6 +703,16 @@ checkDownload() {
     esac
   fi
 
+  if [ "${DB_version}" == '13' ]; then
+    if [[ "$PHP_version" =~ ^[1-2]$ ]]; then
+      echo "Download pecl mongo for php..."
+      src_url=https://pecl.php.net/get/mongo-${mongo_pecl_version}.tgz && Download_src
+    else
+      echo "Download pecl mongodb for php..."
+      src_url=http://pecl.php.net/get/mongodb-${mongodb_pecl_version}.tgz && Download_src
+    fi
+  fi
+
   if [ "${ionCube_yn}" == 'y' ]; then
     echo "Download ioncube..."
     if [ "${OS_BIT}" == '64' ]; then

+ 76 - 0
include/mongodb.sh

@@ -0,0 +1,76 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       https://oneinstack.com
+#       https://github.com/lj2007331/oneinstack
+
+Install_MongoDB() {
+  pushd ${oneinstack_dir}/src
+  id -u mongod >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -s /sbin/nologin mongod
+  mkdir -p ${mongo_data_dir};chown mongod.mongod -R ${mongo_data_dir}
+  tar xzf mongodb-linux-${SYS_BIT_b}-${mongodb_version}.tgz
+  /bin/mv mongodb-linux-${SYS_BIT_b}-${mongodb_version} ${mongo_install_dir}
+  [ "${OS}" == "CentOS" ] && { /bin/cp ../init.d/MongoDB-init-CentOS /etc/init.d/mongod; sed -i "s@/usr/local/mongodb@${mongo_install_dir}@g" /etc/init.d/mongod; chkconfig --add mongod; chkconfig mongod on; }
+  [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/MongoDB-init-Ubuntu /etc/init.d/mongod; sed -i "s@/usr/local/mongodb@${mongo_install_dir}@g" /etc/init.d/mongod; update-rc.d mongod defaults; }
+  cat > /etc/mongod.conf << EOF
+# mongod.conf
+
+# for documentation of all options, see:
+#   http://docs.mongodb.org/manual/reference/configuration-options/
+
+# where to write logging data.
+systemLog:
+  destination: file
+  logAppend: true
+  path: ${mongo_data_dir}/mongod.log
+
+# Where and how to store data.
+storage:
+  dbPath: ${mongo_data_dir} 
+  journal:
+    enabled: true
+#  engine:
+#  mmapv1:
+#  wiredTiger:
+
+# how the process runs
+processManagement:
+  fork: true  # fork and run in background
+  pidFilePath: /var/run/mongodb/mongod.pid
+
+# network interfaces
+net:
+  port: 27017
+  bindIp: 0.0.0.0 
+  unixDomainSocket:
+    enabled: false 
+
+#security:
+#  authorization: enabled
+
+#operationProfiling:
+#replication:
+#sharding:
+EOF
+  service mongod start
+  echo ${mongo_install_dir}/bin/mongo 127.0.0.1/admin --eval \"db.createUser\(\{user:\'root\',pwd:\'$dbmongopwd\',roles:[\'userAdminAnyDatabase\']\}\)\" | bash
+  sed -i 's@^#security:@security:@' /etc/mongod.conf 
+  sed -i 's@^#  authorization:@  authorization:@' /etc/mongod.conf 
+  if [ -e "${mongo_install_dir}/bin/mongo" ]; then
+    echo "${CSUCCESS}MongoDB installed successfully! ${CEND}"
+    rm -rf mongodb-linux-${SYS_BIT_b}-${mongodb_version} 
+  else
+    rm -rf ${mongo_install_dir} ${mongo_data_dir} mongodb-linux-${SYS_BIT_b}-${mongodb_version} 
+    echo "${CFAILURE}MongoDB install failed, Please contact the author! ${CEND}"
+    kill -9 $$
+  fi
+  popd
+  [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mongo_install_dir}/bin:\$PATH" >> /etc/profile
+  [ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${mongo_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${mongo_install_dir}/bin:\1@" /etc/profile
+  . /etc/profile
+}

+ 46 - 0
include/pecl_mongodb.sh

@@ -0,0 +1,46 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       https://oneinstack.com
+#       https://github.com/lj2007331/oneinstack
+
+Install_pecl-mongodb() {
+  pushd ${oneinstack_dir}/src
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
+    if [[ "$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1$2}')" =~ ^5[3-4]$ ]]; then
+      tar xzf mongo-${mongo_pecl_version}.tgz 
+      pushd mongo-${mongo_pecl_version} 
+      ${php_install_dir}/bin/phpize
+      ./configure --with-php-config=${php_install_dir}/bin/php-config
+      make -j ${THREAD} && make install
+      popd
+      if [ -f "${phpExtensionDir}/mongo.so" ]; then
+        echo 'extension=mongo.so' > ${php_install_dir}/etc/php.d/ext-mongo.ini
+        rm -rf mongo-${mongo_pecl_version}
+        echo "${CSUCCESS}PHP mongo module installed successfully! ${CEND}"
+      else
+        echo "${CFAILURE}PHP mongo module install failed, Please contact the author! ${CEND}"
+      fi
+    else
+      tar xzf mongodb-${mongodb_pecl_version}.tgz 
+      pushd mongodb-${mongodb_pecl_version} 
+      ${php_install_dir}/bin/phpize
+      ./configure --with-php-config=${php_install_dir}/bin/php-config
+      make -j ${THREAD} && make install
+      popd
+      if [ -f "${phpExtensionDir}/mongodb.so" ]; then
+        echo 'extension=mongodb.so' > ${php_install_dir}/etc/php.d/ext-mongodb.ini
+        rm -rf mongodb-${mongodb_pecl_version}
+        echo "${CSUCCESS}PHP mongodb module installed successfully! ${CEND}"
+      else
+        echo "${CFAILURE}PHP mongodb module install failed, Please contact the author! ${CEND}"
+      fi
+    fi
+  fi
+  popd
+}

+ 145 - 0
init.d/MongoDB-init-CentOS

@@ -0,0 +1,145 @@
+#!/bin/bash
+
+# mongod - Startup script for mongod
+
+# chkconfig: 35 85 15
+# description: Mongo is a scalable, document-oriented database.
+# processname: mongod
+# config: /etc/mongod.conf
+
+. /etc/rc.d/init.d/functions
+
+# NOTE: if you change any OPTIONS here, you get what you pay for:
+# this script assumes all options are in the config file.
+CONFIGFILE="/etc/mongod.conf"
+OPTIONS=" -f $CONFIGFILE"
+
+mongod=${MONGOD-/usr/local/mongodb/bin/mongod}
+
+MONGO_USER=mongod
+MONGO_GROUP=mongod
+
+# All variables set before this point can be overridden by users, by
+# setting them directly in the SYSCONFIG file. Use this to explicitly
+# override these values, at your own risk.
+SYSCONFIG="/etc/sysconfig/mongod"
+if [ -f "$SYSCONFIG" ]; then
+    . "$SYSCONFIG"
+fi
+
+# Handle NUMA access to CPUs (SERVER-3574)
+# This verifies the existence of numactl as well as testing that the command works
+NUMACTL_ARGS="--interleave=all"
+if which numactl >/dev/null 2>/dev/null && numactl $NUMACTL_ARGS ls / >/dev/null 2>/dev/null
+then
+    NUMACTL="numactl $NUMACTL_ARGS"
+else
+    NUMACTL=""
+fi
+
+# things from mongod.conf get there by mongod reading it
+PIDFILEPATH="`awk -F'[:=]' -v IGNORECASE=1 '/^[[:blank:]]*(processManagement\.)?pidfilepath[[:blank:]]*[:=][[:blank:]]*/{print $2}' \"$CONFIGFILE\" | tr -d \"[:blank:]\\"'\" | awk -F'#' '{print $1}'`"
+PIDDIR=`dirname $PIDFILEPATH`
+
+start()
+{
+  # Make sure the default pidfile directory exists
+  if [ ! -d $PIDDIR ]; then
+    install -d -m 0755 -o $MONGO_USER -g $MONGO_GROUP $PIDDIR
+  fi
+
+  # Make sure the pidfile does not exist
+  if [ -f "$PIDFILEPATH" ]; then
+      echo "Error starting mongod. $PIDFILEPATH exists."
+      RETVAL=1
+      return
+  fi
+
+  # Recommended ulimit values for mongod or mongos
+  # See http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
+  #
+  ulimit -f unlimited
+  ulimit -t unlimited
+  ulimit -v unlimited
+  ulimit -n 64000
+  ulimit -m unlimited
+  ulimit -u 64000
+  ulimit -l unlimited
+
+  echo -n $"Starting mongod: "
+  daemon --user "$MONGO_USER" --check $mongod "$NUMACTL $mongod $OPTIONS >/dev/null 2>&1"
+  RETVAL=$?
+  echo
+  [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod
+}
+
+stop()
+{
+  echo -n $"Stopping mongod: "
+  mongo_killproc "$PIDFILEPATH" $mongod
+  RETVAL=$?
+  echo
+  [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongod
+}
+
+restart () {
+        stop
+        start
+}
+
+# Send TERM signal to process and wait up to 300 seconds for process to go away.
+# If process is still alive after 300 seconds, send KILL signal.
+# Built-in killproc() (found in /etc/init.d/functions) is on certain versions of Linux
+# where it sleeps for the full $delay seconds if process does not respond fast enough to
+# the initial TERM signal.
+mongo_killproc()
+{
+  local pid_file=$1
+  local procname=$2
+  local -i delay=300
+  local -i duration=10
+  local pid=`pidofproc -p "${pid_file}" ${procname}`
+
+  kill -TERM $pid >/dev/null 2>&1
+  usleep 100000
+  local -i x=0
+  while [ $x -le $delay ] && checkpid $pid; do
+    sleep $duration
+    x=$(( $x + $duration))
+  done
+
+  kill -KILL $pid >/dev/null 2>&1
+  usleep 100000
+
+  checkpid $pid # returns 0 only if the process exists
+  local RC=$?
+  [ "$RC" -eq 0 ] && failure "${procname} shutdown" || rm -f "${pid_file}"; success "${procname} shutdown"
+  RC=$((! $RC)) # invert return code so we return 0 when process is dead.
+  return $RC
+}
+
+RETVAL=0
+
+case "$1" in
+  start)
+    start
+    ;;
+  stop)
+    stop
+    ;;
+  restart|reload|force-reload)
+    restart
+    ;;
+  condrestart)
+    [ -f /var/lock/subsys/mongod ] && restart || :
+    ;;
+  status)
+    status $mongod
+    RETVAL=$?
+    ;;
+  *)
+    echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
+    RETVAL=1
+esac
+
+exit $RETVAL

+ 272 - 0
init.d/MongoDB-init-Ubuntu

@@ -0,0 +1,272 @@
+#!/bin/sh
+#
+# init.d script with LSB support.
+#
+# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
+#
+# This is free software; you may redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2,
+# or (at your option) any later version.
+#
+# This is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License with
+# the Debian operating system, in /usr/share/common-licenses/GPL;  if
+# not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+#
+### BEGIN INIT INFO
+# Provides:          mongod
+# Required-Start:    $network $local_fs $remote_fs
+# Required-Stop:     $network $local_fs $remote_fs
+# Should-Start:      $named
+# Should-Stop:
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: An object/document-oriented database
+# Description:       MongoDB is a high-performance, open source, schema-free
+#                    document-oriented data store that's easy to deploy, manage
+#                    and use. It's network accessible, written in C++ and offers
+#                    the following features:
+#
+#                       * Collection oriented storage - easy storage of object-
+#                         style data
+#                       * Full index support, including on inner objects
+#                       * Query profiling
+#                       * Replication and fail-over support
+#                       * Efficient storage of binary data including large
+#                         objects (e.g. videos)
+#                       * Automatic partitioning for cloud-level scalability
+#
+#                    High performance, scalability, and reasonable depth of
+#                    functionality are the goals for the project.
+### END INIT INFO
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/local/mongodb/bin/mongod
+DESC=database
+
+NAME=mongod
+# Defaults.  Can be overridden by the /etc/default/$NAME
+# Other configuration options are located in $CONF file. See here for more:
+# http://dochub.mongodb.org/core/configurationoptions
+CONF=/etc/mongod.conf
+PIDFILE=/var/run/$NAME.pid
+ENABLE_MONGOD=yes
+
+# Include mongodb defaults if available.
+# All variables set before this point can be overridden by users, by
+# setting them directly in the defaults file. Use this to explicitly
+# override these values, at your own risk.
+if [ -f /etc/default/$NAME ] ; then
+        . /etc/default/$NAME
+fi
+
+# Handle NUMA access to CPUs (SERVER-3574)
+# This verifies the existence of numactl as well as testing that the command works
+NUMACTL_ARGS="--interleave=all"
+if which numactl >/dev/null 2>/dev/null && numactl $NUMACTL_ARGS ls / >/dev/null 2>/dev/null
+then
+    NUMACTL="`which numactl` -- $NUMACTL_ARGS"
+    DAEMON_OPTS=${DAEMON_OPTS:-"--config $CONF"}
+else
+    NUMACTL=""
+    DAEMON_OPTS="-- "${DAEMON_OPTS:-"--config $CONF"}
+fi
+
+
+if test ! -x $DAEMON; then
+    echo "Could not find $DAEMON"
+    exit 0
+fi
+
+if test "x$ENABLE_MONGOD" != "xyes"; then
+    exit 0
+fi
+
+. /lib/lsb/init-functions
+
+STARTTIME=1
+DIETIME=10                  # Time to wait for the server to die, in seconds
+                            # If this value is set too low you might not
+                            # let some servers to die gracefully and
+                            # 'restart' will not work
+
+DAEMONUSER=${DAEMONUSER:-mongod}
+DAEMONGROUP=${DAEMONGROUP:-mongod}
+
+set -e
+
+running_pid() {
+# Check if a given process pid's cmdline matches a given name
+    pid=$1
+    name=$2
+    [ -z "$pid" ] && return 1
+    [ ! -d /proc/$pid ] &&  return 1
+    cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
+    # Is this the expected server
+    [ "$cmd" != "$name" ] &&  return 1
+    return 0
+}
+
+running() {
+# Check if the process is running looking at /proc
+# (works for all users)
+
+    # No pidfile, probably no daemon present
+    [ ! -f "$PIDFILE" ] && return 1
+    pid=`cat $PIDFILE`
+    running_pid $pid $DAEMON || return 1
+    return 0
+}
+
+start_server() {
+            # Recommended ulimit values for mongod or mongos
+            # See http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
+            #
+            ulimit -f unlimited
+            ulimit -t unlimited
+            ulimit -v unlimited
+            ulimit -n 64000
+            ulimit -m unlimited
+            ulimit -l unlimited
+
+            # In dash, ulimit takes -p for maximum user processes
+            # In bash, it's -u
+            if readlink /proc/$$/exe | grep -q dash
+            then
+                    ulimit -p 64000
+            else
+                    ulimit -u 64000
+            fi
+
+            # Start the process using the wrapper
+            start-stop-daemon --background --start --quiet --pidfile $PIDFILE \
+                        --make-pidfile --chuid $DAEMONUSER:$DAEMONGROUP \
+                        --exec $NUMACTL $DAEMON $DAEMON_OPTS
+            errcode=$?
+        return $errcode
+}
+
+stop_server() {
+# Stop the process using the wrapper
+            start-stop-daemon --stop --quiet --pidfile $PIDFILE \
+                        --retry 300 \
+                        --user $DAEMONUSER \
+                        --exec $DAEMON
+            errcode=$?
+        return $errcode
+}
+
+force_stop() {
+# Force the process to die killing it manually
+        [ ! -e "$PIDFILE" ] && return
+        if running ; then
+                kill -15 $pid
+        # Is it really dead?
+                sleep "$DIETIME"s
+                if running ; then
+                        kill -9 $pid
+                        sleep "$DIETIME"s
+                        if running ; then
+                                echo "Cannot kill $NAME (pid=$pid)!"
+                                exit 1
+                        fi
+                fi
+        fi
+        rm -f $PIDFILE
+}
+
+
+case "$1" in
+  start)
+        log_daemon_msg "Starting $DESC" "$NAME"
+        # Check if it's running first
+        if running ;  then
+            log_progress_msg "apparently already running"
+            log_end_msg 0
+            exit 0
+        fi
+        if start_server ; then
+            # NOTE: Some servers might die some time after they start,
+            # this code will detect this issue if STARTTIME is set
+            # to a reasonable value
+            [ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time
+            if  running ;  then
+                # It's ok, the server started and is running
+                log_end_msg 0
+            else
+                # It is not running after we did start
+                log_end_msg 1
+            fi
+        else
+            # Either we could not start it
+            log_end_msg 1
+        fi
+        ;;
+  stop)
+        log_daemon_msg "Stopping $DESC" "$NAME"
+        if running ; then
+            # Only stop the server if we see it running
+                        errcode=0
+            stop_server || errcode=$?
+            log_end_msg $errcode
+        else
+            # If it's not running don't do anything
+            log_progress_msg "apparently not running"
+            log_end_msg 0
+            exit 0
+        fi
+        ;;
+  force-stop)
+        # First try to stop gracefully the program
+        $0 stop
+        if running; then
+            # If it's still running try to kill it more forcefully
+            log_daemon_msg "Stopping (force) $DESC" "$NAME"
+                        errcode=0
+            force_stop || errcode=$?
+            log_end_msg $errcode
+        fi
+        ;;
+  restart|force-reload)
+        log_daemon_msg "Restarting $DESC" "$NAME"
+                errcode=0
+        stop_server || errcode=$?
+        # Wait some sensible amount, some server need this
+        [ -n "$DIETIME" ] && sleep $DIETIME
+        start_server || errcode=$?
+        [ -n "$STARTTIME" ] && sleep $STARTTIME
+        running || errcode=$?
+        log_end_msg $errcode
+        ;;
+  status)
+
+        log_daemon_msg "Checking status of $DESC" "$NAME"
+        if running ;  then
+            log_progress_msg "running"
+            log_end_msg 0
+        else
+            log_progress_msg "apparently not running"
+            log_end_msg 1
+            exit 1
+        fi
+        ;;
+  # MongoDB can't reload its configuration.
+  reload)
+        log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
+        log_warning_msg "cannot re-read the config file (use restart)."
+        ;;
+
+  *)
+        N=/etc/init.d/$NAME
+        echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2
+        exit 1
+        ;;
+esac
+
+exit 0

+ 33 - 9
install.sh

@@ -188,9 +188,11 @@ while :; do echo
         echo -e "\t${CMSG}10${CEND}. Install Percona-5.5"
         echo -e "\t${CMSG}11${CEND}. Install AliSQL-5.6"
         echo -e "\t${CMSG}12${CEND}. Install PostgreSQL"
+        echo -e "\t${CMSG}13${CEND}. Install MongoDB"
         read -p "Please input a number:(Default 2 press Enter) " DB_version
         [ -z "$DB_version" ] && DB_version=2
-        if [[ "${DB_version}" =~ ^[1-9]$|^1[0-2]$ ]]; then 
+        [ "$DB_version" == '13' -a "$OS_BIT" == '32' ] && { echo "${CWARNING}By not supporting 32-bit! ${CEND}"; continue; }
+        if [[ "${DB_version}" =~ ^[1-9]$|^1[0-3]$ ]]; then
           while :; do
             if [ "$DB_version" == '12' ]; then
               read -p "Please input the postgres password of database: " dbrootpwd
@@ -199,7 +201,15 @@ while :; do echo
             fi
             [ -n "`echo $dbrootpwd | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; }
             if (( ${#dbrootpwd} >= 5 )); then
-              [ "$DB_version" == '12' ] && { sed -i "s+^dbpostgrespwd.*+dbpostgrespwd='$dbrootpwd'+" ./options.conf; dbpostgrespwd="$dbrootpwd"; } || sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ./options.conf
+              if [ "$DB_version" == '12' ]; then
+                sed -i "s+^dbpostgrespwd.*+dbpostgrespwd='$dbrootpwd'+" ./options.conf
+                dbpostgrespwd="$dbrootpwd"
+              elif [ "$DB_version" == '13' ]; then
+                sed -i "s+^dbmongopwd.*+dbmongopwd='$dbrootpwd'+" ./options.conf
+                dbmongopwd="$dbrootpwd"
+              else
+                sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ./options.conf
+              fi
               break
             else
               echo "${CWARNING}password least 5 characters! ${CEND}"
@@ -223,7 +233,7 @@ while :; do echo
           fi
           break
         else
-          echo "${CWARNING}input error! Please only input number 1~12${CEND}"
+          echo "${CWARNING}input error! Please only input number 1~13${CEND}"
         fi
       done
     fi
@@ -593,6 +603,10 @@ case "${DB_version}" in
     . include/postgresql.sh
     Install_PostgreSQL 2>&1 | tee -a $oneinstack_dir/install.log
     ;;
+  13)
+    . include/mongodb.sh
+    Install_MongoDB 2>&1 | tee -a $oneinstack_dir/install.log
+    ;;
 esac
 
 # Apache
@@ -636,6 +650,18 @@ case "${PHP_version}" in
     ;;
 esac
 
+# pecl_pgsql
+if [ "${DB_version}" == '12' -a -e "${php_install_dir}/bin/phpize" ]; then
+  . include/pecl_pgsql.sh
+  Install_pecl-pgsql 2>&1 | tee -a $oneinstack_dir/install.log
+fi
+
+# pecl_mongodb
+if [ "${DB_version}" == '13' -a -e "${php_install_dir}/bin/phpize" ]; then
+  . include/pecl_mongodb.sh
+  Install_pecl-mongodb 2>&1 | tee -a $oneinstack_dir/install.log
+fi
+
 # ImageMagick or GraphicsMagick
 if [ "$Magick" == '1' ]; then
   . include/ImageMagick.sh
@@ -683,12 +709,6 @@ if [ "$ZendGuardLoader_yn" == 'y' ]; then
   Install_ZendGuardLoader 2>&1 | tee -a $oneinstack_dir/install.log
 fi
 
-# pecl_pgsql
-if [ "$DB_version" == '12' ] && [ -e "${php_install_dir}/bin/phpize" ]; then
-  . include/pecl_pgsql.sh
-  Install_pecl-pgsql 2>&1 | tee -a $oneinstack_dir/install.log
-fi
-
 # Web server
 case "${Nginx_version}" in
   1)
@@ -797,6 +817,10 @@ echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes"
 [ "${DB_version}" == '12' ] && echo "$(printf "%-32s" "PostgreSQL data dir:")${CMSG}${pgsql_data_dir}${CEND}"
 [ "${DB_version}" == '12' ] && echo "$(printf "%-32s" "PostgreSQL user:")${CMSG}postgres${CEND}"
 [ "${DB_version}" == '12' ] && echo "$(printf "%-32s" "postgres password:")${CMSG}${dbpostgrespwd}${CEND}"
+[ "${DB_version}" == '13' ] && echo -e "\n$(printf "%-32s" "MongoDB install dir:")${CMSG}${mongo_install_dir}${CEND}"
+[ "${DB_version}" == '13' ] && echo "$(printf "%-32s" "MongoDB data dir:")${CMSG}${mongo_data_dir}${CEND}"
+[ "${DB_version}" == '13' ] && echo "$(printf "%-32s" "MongoDB user:")${CMSG}root${CEND}"
+[ "${DB_version}" == '13' ] && echo "$(printf "%-32s" "MongoDB password:")${CMSG}${dbmongopwd}${CEND}"
 [ "${PHP_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}"
 [ "${PHP_cache}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel URL:")${CMSG}http://${IPADDR}/ocp.php${CEND}"
 [ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache Control Panel URL:")${CMSG}http://${IPADDR}/xcache${CEND}"

+ 6 - 1
options.conf

@@ -16,6 +16,7 @@ mariadb_install_dir=/usr/local/mariadb
 percona_install_dir=/usr/local/percona
 alisql_install_dir=/usr/local/alisql
 pgsql_install_dir=/usr/local/pgsql
+mongo_install_dir=/usr/local/mongodb
 
 php_install_dir=/usr/local/php
 
@@ -40,6 +41,7 @@ mariadb_data_dir=/data/mariadb
 percona_data_dir=/data/percona
 alisql_data_dir=/data/alisql
 pgsql_data_dir=/data/pgsql
+mongo_data_dir=/data/mongodb
 
 # web directory, you can customize
 wwwroot_dir=/data/wwwroot
@@ -48,12 +50,15 @@ wwwroot_dir=/data/wwwroot
 wwwlogs_dir=/data/wwwlogs
 
 #########################################################################
-# [MySQL/MariaDB/Percona] automatically generated, You can't change
+# [MySQL/MariaDB/Percona/AliSQL] automatically generated, You can't change
 dbrootpwd=
 
 # [PostgreSQL] automatically generated, You can't change
 dbpostgrespwd=
 
+# [MongoDB] automatically generated, You can't change
+dbmongopwd=
+
 #########################################################################
 # Backup Dest directory, change this if you have someother location
 backup_dir=/data/backup

+ 15 - 3
uninstall.sh

@@ -32,7 +32,7 @@ Usage(){
 Usage: $0 [  ${CMSG}all${CEND} | ${CMSG}web${CEND} | ${CMSG}db${CEND} | ${CMSG}php${CEND} | ${CMSG}hhvm${CEND} | ${CMSG}pureftpd${CEND} | ${CMSG}redis${CEND} | ${CMSG}memcached${CEND} ]
 ${CMSG}all${CEND}            --->Uninstall All
 ${CMSG}web${CEND}            --->Uninstall Nginx/Tengine/Apache/Tomcat
-${CMSG}db${CEND}             --->Uninstall MySQL/MariaDB/Percona/AliSQL/PostgreSQL
+${CMSG}db${CEND}             --->Uninstall MySQL/MariaDB/Percona/AliSQL/PostgreSQL/MongoDB
 ${CMSG}php${CEND}            --->Uninstall PHP
 ${CMSG}hhvm${CEND}           --->Uninstall HHVM
 ${CMSG}pureftpd${CEND}       --->Uninstall PureFtpd
@@ -97,6 +97,8 @@ Print_DB() {
   [ -e "/etc/my.cnf" ] && echo "/etc/my.cnf"
   [ -e "${pgsql_install_dir}" ] && echo "${pgsql_install_dir}"
   [ -e "/etc/init.d/postgresql" ] && echo "/etc/init.d/postgresql"
+  [ -e "${mongo_install_dir}" ] && echo "${mongo_install_dir}"
+  [ -e "/etc/init.d/mongod" ] && echo "/etc/init.d/mongod"
 }
 
 Uninstall_DB() {
@@ -112,13 +114,23 @@ Uninstall_DB() {
   # uninstall postgresql
   if [ -e "${pgsql_install_dir}/bin/psql" ]; then
     service postgresql stop > /dev/null 2>&1
-    rm -rf ${pgsql_install_dir} /etc/init.d/postgresql
+    rm -rf ${pgsql_install_dir} /etc/init.d/postgresql ${php_install_dir}/etc/php.d/ext-pgsql.ini
     id -u postgres >/dev/null 2>&1 ; [ $? -eq 0 ] && userdel postgres 
     [ -e "${pgsql_data_dir}" ] && /bin/mv ${pgsql_data_dir}{,$(date +%Y%m%d%H)}
     sed -i 's@^dbpostgrespwd=.*@dbpostgrespwd=@' ./options.conf
     sed -i "s@${pgsql_install_dir}/bin:@@" /etc/profile
     echo "${CMSG}PostgreSQL uninstall completed${CEND}"
   fi
+  # uninstall mongodb 
+  if [ -e "${mongo_install_dir}/bin/mongo" ]; then
+    service mongod stop > /dev/null 2>&1
+    rm -rf ${mongo_install_dir} /etc/mongod.conf /etc/init.d/mongod /var/log/mongodb /tmp/mongo*.sock
+    id -u mongod > /dev/null 2>&1 ; [ $? -eq 0 ] && userdel mongod 
+    [ -e "${mongo_data_dir}" ] && /bin/mv ${mongo_data_dir}{,$(date +%Y%m%d%H)}
+    sed -i 's@^dbmongopwd=.*@dbmongopwd=@' ./options.conf
+    sed -i "s@${mongo_install_dir}/bin:@@" /etc/profile
+    echo "${CMSG}MongoDB uninstall completed${CEND}"
+  fi
 }
 
 Print_PHP() {
@@ -201,7 +213,7 @@ while :; do
 What Are You Doing?
 \t${CMSG}0${CEND}. Uninstall All
 \t${CMSG}1${CEND}. Uninstall Nginx/Tengine/Apache/Tomcat
-\t${CMSG}2${CEND}. Uninstall MySQL/MariaDB/Percona/AliSQL/PostgreSQL
+\t${CMSG}2${CEND}. Uninstall MySQL/MariaDB/Percona/AliSQL/PostgreSQL/MongoDB
 \t${CMSG}3${CEND}. Uninstall PHP
 \t${CMSG}4${CEND}. Uninstall HHVM
 \t${CMSG}5${CEND}. Uninstall PureFtpd

+ 6 - 0
versions.txt

@@ -34,6 +34,8 @@ alisql56_version=5.6.32-7
 
 pgsql_version=10.1
 
+mongodb_version=3.6.0
+
 # JDK
 jdk18_version=1.8.0_152
 jdk17_version=1.7.0_80
@@ -80,6 +82,10 @@ memcached_pecl_version=2.2.0
 memcached_pecl_php7_version=3.0.4
 memcache_pecl_version=3.0.8
 
+# MongoDB
+mongodb_pecl_version=1.3.4
+mongo_pecl_version=1.6.16
+
 # phpMyadmin
 phpMyAdmin_version=4.4.15.10