-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathprovision.sh
executable file
·60 lines (48 loc) · 2.11 KB
/
provision.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
#
# Copyright (C) 2014 meltmedia ([email protected])
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Provisioning script executed by Vagrant.
#
# configure apt for mongo install
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
# add source for Java 8
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
# install mongo
sudo apt-get install -y mongodb-org=3.2.6 mongodb-org-server=3.2.6 mongodb-org-shell=3.2.6 mongodb-org-mongos=3.2.6 mongodb-org-tools=3.2.6
# pin mongo versions
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
# reconfigure mongo to bind to all interfaces.
sudo sed -i"" 's/^ bindIp: 127.0.0.1/ bindIp: 0.0.0.0/' /etc/mongod.conf
sudo cat <<EOT >> /etc/mongod.conf
replication:
oplogSizeMB: 1024
replSetName: rs0
EOT
# restart mongo to apply config changes.
sudo service mongod restart
# install Java 8
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
sudo apt-get install oracle-java8-installer --assume-yes
# add the example user.
mongo -eval 'db.createUser({user: "example", pwd: "example", roles:[{role: "read", db: "local"}, {role: "readWrite", db:"example"}]})'
mongo --eval "rs.initiate()"