dndex/init.sh

29 lines
476 B
Bash

#! /bin/bash
port=57017
if ! curl -sS localhost:$port > /dev/null; then
prefix=/tmp/whodunit.db
mkdir -p $prefix/data
mongod \
--dbpath $prefix/data \
--logpath $prefix/log \
--pidfilepath $prefix/pid \
--port $port \
--fork
fi
mshell() {
mongo \
--quiet \
--port $port \
--eval "$*"
}
remove() {
mshell \
'db.getSiblingDB("db")["col"].remove({})'
}
export DBURI=${DB_URI:-"mongodb://localhost:$port"}