aboutsummaryrefslogblamecommitdiff
path: root/databases/mongodb/files/mongod.in
blob: a06b88ff522654fc4f2271bb3505af729aa7a82c (plain) (tree)
1
2
3
4
5
6
7
8
9


                 
                           
                   



                                                               










                                                                                                                                                                                                                                             
 
 
              

             
                   
 


                       
                       
                                    
                                                                     
                          
                           
 






















                                                                                                           

                   
#!/bin/sh

# PROVIDE: mongod
# REQUIRE: NETWORK ldconfig
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# mongod_enable (bool):  Set to "NO" by default.                                                                                                                                                                                             
#                        Set it to "YES" to enable mongod.
# mongod_limits (bool):  Set to "NO" by default.
#                        Set it to yes to run `limits -e -U mongodb`
#                        just before mongod starts.
# mongod_dbpath (str):   Default to "/var/db/mongodb"
#                        Base database directory.
# mongod_pidfile (str):  Custum PID file path and name.
#                        Default to "${mongod_dbpath}/mongod.pid".
# mongod_flags (str):    Custom additional arguments to be passed to mongod.
#                        Default to "--logpath ${mongod_dbpath}/mongod.log --logappend".
#

. /etc/rc.subr

name="mongod"
rcvar=mongod_enable

load_rc_config $name

: ${mongod_enable="NO"}
: ${mongod_limits="NO"}
: ${mongod_dbpath="/var/db/mongodb"}
: ${mongod_flags="--logpath ${mongod_dbpath}/mongod.log --logappend"}
: ${mongod_user="mongodb"}
: ${mongod_group="mongodb"}

pidfile=${mongod_pidfile:-"${mongod_dbpath}/mongod.pid"}
command=%%PREFIX%%/bin/${name}
command_args="--config %%PREFIX%%/etc/mongodb.conf --dbpath $mongod_dbpath --pidfilepath ${pidfile} --fork"
start_precmd="${name}_prestart"

mongod_create_dbpath()
{
        mkdir ${mongod_dbpath} >/dev/null 2>/dev/null
        [ $? -eq 0 ] && chown -R ${mongod_user}:${mongod_group} ${mongod_dbpath}
}


mongod_prestart()
{
        if [ ! -d ${mongod_dbpath} ]; then
                mongod_create_dbpath || return 1
        fi
        if checkyesno mongod_limits; then
                eval `/usr/bin/limits -e -U ${mongod_user}` 2>/dev/null
        else
                return 0
        fi
}

run_rc_command "$1"