#!/bin/bash
# chkconfig: 2345 55 25
# description: mongodb

### BEGIN INIT INFO
# Provides:          mongodb
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts mongodb
# Description:       starts the mongodb
### END INIT INFO

MONGO_PATH=/www/server/mongodb
if [ ! -f $MONGO_PATH/bin/mongod ];then
	echo "No installation of mognodb."
	exit;
fi

Config=/www/server/mongodb/config.conf
User=mongo

start()
{
	#chmod -R mongo:mongo /www/server/mongodb
	sudo -u $User mongod -f $Config
}

stop()
{
	sudo -u $User mongod --shutdown -f $Config
}

case "$1" in
        'start')
                start
                ;;
        'stop')
                stop
                ;;
        'restart')
        		stop
                start
                ;;
        *)
                echo "Usage: /etc/init.d/mongodb {start|stop|restart}"
        ;;
esac
