hackedteam/rcs-db

View on GitHub
bin/rcs-db-mongod

Summary

Maintainability
Test Coverage
#!/usr/bin/env ruby

require 'rbconfig'

# ensure the working dir is correct
Dir.chdir File.dirname(File.dirname(File.realpath(__FILE__)))

# select the correct dir based upon the platform we are running on
case RbConfig::CONFIG['host_os']
  when /darwin/
    os = 'macos'
    ext = ''
  when /mingw/
    os = 'win'
    ext = '.exe'
end

datadir = Dir.pwd + '/data'
logdir = Dir.pwd + '/log'

# ensure the data directory is present
Dir::mkdir(datadir) if not File.directory?(datadir)
Dir::mkdir(logdir) if not File.directory?(logdir)

keyfile = Dir.pwd + '/config/mongodb.key'

# the mongod executable
mongod = Dir.pwd + '/mongodb/' + os + '/mongod' + ext

# the data path
parameters = "--dbpath #{datadir} --journal --nssize 64 --logpath #{logdir}/mongod.log --shardsvr --rest --keyFile #{keyfile}"

# custom arguments
custom = ARGV.join(' ')

# execute it
exec mongod + ' ' + parameters + ' ' + custom