Skip to content

Instantly share code, notes, and snippets.

@r38y
Created April 14, 2010 17:23
Show Gist options
  • Save r38y/366080 to your computer and use it in GitHub Desktop.
Save r38y/366080 to your computer and use it in GitHub Desktop.
MongoDB init.d script for Ubuntu 8.04 LTS
# since there is no deb package for Ubuntu 8.04 LTS, this is what I had to do
# download latest stable version of mongodb and move to /usr/local/mongodb
# add "export PATH=$PATH:/usr/local/mongodb/bin" to /etc/profile
# make directories for the data /db/mongodb/master and /db/mongodb/slave
# chown those directories to the user you want
# move this script to /etc/init.d/mongodb
# chmod +x /etc/init.d/mongodb
# update-rc.d mongodb defaults
RETVAL=0
case "$1" in
start)
echo "Starting MongoDB"
/usr/local/mongodb/bin/mongod --master --auth --port 27017 --dbpath /db/mongodb/master/ > /dev/null 2>&1 &
/usr/local/mongodb/bin/mongod --slave --auth --syncdelay 5 --source localhost --port 27018 --dbpath /db/mongodb/slave/ > /dev/null 2>&1 &
RETVAL=$?
;;
stop)
echo "Stopping MongoDB"
start-stop-daemon --stop --quiet --exec /usr/local/mongodb/bin/mongod
RETVAL=$?
;;
status)
RETVAL=$?
;;
*)
echo "Usage: mongodb {start|stop|status}"
exit 1
;;
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment