1#!/bin/sh 2 3# PROVIDE: mongod 4# REQUIRE: NETWORK ldconfig 5# KEYWORD: shutdown 6# 7# Add the following lines to /etc/rc.conf.local or /etc/rc.conf 8# to enable this service: 9# 10# mongod_enable (bool): Set to "NO" by default. 11# Set it to "YES" to enable mongod. 12# mongod_dbpath (str): Default to "/var/db/mongodb" 13# Base database directory. 14# mongod_flags (str): Custom additional arguments to be passed to mongod. 15# Default to "--logpath ${mongod_dbpath}/mongod.log --logappend". 16# mongod_config (str): Default to "%%PREFIX%%/etc/mongodb.conf" 17# Path to config file 18# 19 20. /etc/rc.subr 21 22name="mongod" 23rcvar=mongod_enable 24 25load_rc_config $name 26 27: ${mongod_enable="NO"} 28: ${mongod_dbpath="/var/db/mongodb"} 29: ${mongod_flags="--logpath ${mongod_dbpath}/mongod.log --logappend --setParameter=disabledSecureAllocatorDomains=\*"} 30: ${mongod_user="mongodb"} 31: ${mongod_group="mongodb"} 32: ${mongod_config="%%PREFIX%%/etc/mongodb.conf"} 33 34pidfile="${mongod_dbpath}/mongod.lock" 35command=%%PREFIX%%/bin/${name} 36command_args="--config $mongod_config --dbpath $mongod_dbpath --fork >/dev/null 2>/dev/null" 37start_precmd="${name}_prestart" 38 39mongod_create_dbpath() 40{ 41 mkdir ${mongod_dbpath} >/dev/null 2>/dev/null 42 [ $? -eq 0 ] && chown -R ${mongod_user}:${mongod_group} ${mongod_dbpath} 43} 44 45mongod_prestart() 46{ 47 if [ ! -d ${mongod_dbpath} ]; then 48 mongod_create_dbpath || return 1 49 fi 50 return 0 51} 52 53run_rc_command "$1" 54