Sun Jun 30 13:48:06 2019 UTC ()
databases/mongodb3: Belatedly add files/

For no good reason, I didn't add the files/ directory from the pre-4
version of mongodb.  Pointed out by Oskar.


(gdt)
diff -r0 -r1.1 pkgsrc/databases/mongodb3/files/mongodb.sh
diff -r0 -r1.1 pkgsrc/databases/mongodb3/files/smf/manifest.xml
diff -r0 -r1.1 pkgsrc/databases/mongodb3/files/smf/mongodb.sh

File Added: pkgsrc/databases/mongodb3/files/mongodb.sh
#!@RCD_SCRIPTS_SHELL@
#
# $NetBSD: mongodb.sh,v 1.1 2019/06/30 13:48:06 gdt Exp $
#
# PROVIDE: mongodb
# REQUIRE: DAEMON LOGIN mountall
# KEYWORD: shutdown
#
# You will need to set some variables in /etc/rc.conf to start MongoDB:
#
# mongodb=YES
#
# The following variables are optional:
#
#     mongodb_user="@MONGODB_USER@"	# user to run mongod as
#     mongodb_group="@MONGODB_GROUP@"	# group to run mongod as
#     mongodb_dbpath="@MONGODB_DBPATH@"	# path to MongoDB database directory
#

if [ -f /etc/rc.subr ]; then
	. /etc/rc.subr
fi

name="mongodb"
rcvar=${name}
command="@PREFIX@/bin/mongod"
: ${mongodb_user:=@MONGODB_USER@}
: ${mongodb_group:=@MONGODB_GROUP@}
: ${mongodb_dbpath:=@MONGODB_DBPATH@}
pidfile="${mongodb_dbpath}/mongod.pid"
logfile="${mongodb_dbpath}/mongod.log"
required_dirs="${mongodb_dbpath}"

command_args="--fork --logpath ${logfile} --logappend --pidfilepath ${pidfile} --dbpath ${mongodb_dbpath} --smallfiles"

load_rc_config ${name}
run_rc_command "$1"

File Added: pkgsrc/databases/mongodb3/files/smf/manifest.xml
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
  <service name='@SMF_PREFIX@/@SMF_NAME@' type='service' version='0'>
    <create_default_instance enabled='false'/>
    <single_instance/>
    <dependency name='fs' grouping='require_all' restart_on='none' type='service'>
      <service_fmri value='svc:/system/filesystem/local'/>
    </dependency>
    <dependency name='net' grouping='require_all' restart_on='none' type='service'>
      <service_fmri value='svc:/network/loopback'/>
    </dependency>
    <dependency name='config' grouping='require_all' restart_on='none' type='path'>
      <service_fmri value='file://@PKG_SYSCONFDIR@/mongod.conf'/>
    </dependency>
    <method_context working_directory='@MONGODB_DBPATH@'>
      <method_credential group='@MONGODB_USER@' user='@MONGODB_GROUP@'/>
        <method_environment>
          <envvar name='PATH' value='@PREFIX@/bin:@PREFIX@/gnu/bin:@PREFIX@/sbin:/usr/bin:/usr/sbin'/>
        </method_environment>
    </method_context>
    <exec_method name='start' type='method' exec='@PREFIX@/@SMF_METHOD_FILE.mongodb@ start' timeout_seconds='18446744073709551615'/>
    <exec_method name='stop' type='method' exec='@PREFIX@/@SMF_METHOD_FILE.mongodb@ stop' timeout_seconds='18446744073709551615'/>
    <exec_method name='restart' type='method' exec='@PREFIX@/@SMF_METHOD_FILE.mongodb@ restart' timeout_seconds='18446744073709551615'/>
      <property_group name='replication' type='application'>
       <propval name='name' type='astring' value=''/>
       <propval name='key' type='astring' value=''/>
       <propval name='members' type='astring' value=''/>
      </property_group>
      <template>
        <common_name>
          <loctext xml:lang='C'>MongoDB Database</loctext>
        </common_name>
        <documentation>
          <doc_link name='wiki.joyent.com' uri='http://wiki.joyent.com/display/jpc2/Joyent+MongoDB+SmartMachine'/>
        </documentation>
      </template>
  </service>
</service_bundle>


File Added: pkgsrc/databases/mongodb3/files/smf/mongodb.sh
#!/bin/bash
#
# SMF method for svc:/pkgsrc/mongodb:default

. /lib/svc/share/smf_include.sh

# mongodb doesn't really work with anything else but C locale
export LANG=C

PATH="@PREFIX@/bin:@PREFIX@/gnu/bin:@PREFIX@/sbin:/usr/bin:/usr/sbin";
MONGO_DBPATH="@MONGODB_DBPATH@";
MONGO_CONF="@PKG_SYSCONFDIR@/mongod.conf";
MONGO_PID="${MONGO_DBPATH}/mongod.pid";

case "$1" in
        'start')
                mongod --fork -f ${MONGO_CONF} --pidfilepath ${MONGO_PID}
                ;;

        'stop')
                [[ -s ${MONGO_PID} ]] && kill $(cat ${MONGO_PID}) 2>/dev/null
                ;;

        'restart')
                [[ -s ${MONGO_PID} ]] && kill $(cat ${MONGO_PID}) 2>/dev/null
                sleep 3;
                mongod --fork -f ${MONGO_CONF} --pidfilepath ${MONGO_PID}
                ;;
        *)
                echo "usage: $0 { start | stop | restart }"
                exit 1;
                ;;
esac