-
-
Save derencius/392945 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# run with: curl -s http://gist.github.com/265272.txt | bash | |
set -e | |
localdir=$HOME/.mongodb | |
datadir=$localdir/data | |
conf=$localdir/mongod.conf | |
agentdir=$HOME/Library/LaunchAgents | |
agent=$agentdir/org.mongodb.mongod.plist | |
brew install mongodb | |
mongod=$(which mongod) | |
mkdir -p $datadir | |
mkdir -p $agentdir | |
# daemon configuration | |
echo "dbpath = $datadir | |
# Only accept local connections | |
bind_ip = 127.0.0.1" > $conf | |
# write launchd agent | |
echo "<?xml version='1.0' encoding='UTF-8'?> | |
<!DOCTYPE plist PUBLIC '-//Apple//DTD PLIST 1.0//EN' 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'> | |
<plist version='1.0'> | |
<dict> | |
<key>Label</key> | |
<string>org.mongodb.mongod</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>$mongod</string> | |
<string>run</string> | |
<string>--config</string> | |
<string>$conf</string> | |
</array> | |
<key>RunAtLoad</key> | |
<true/> | |
<key>KeepAlive</key> | |
<true/> | |
<key>WorkingDirectory</key> | |
<string>$localdir</string> | |
<key>StandardErrorPath</key> | |
<string>$localdir/error.log</string> | |
<key>StandardOutPath</key> | |
<string>$localdir/mongo.log</string> | |
</dict> | |
</plist>" > $agent | |
launchctl load $agent | |
echo "MongoDB should now be running - check its status at http://localhost:28017/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment