forked from pwman3/pwman3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provision_vagrant.sh
executable file
·65 lines (46 loc) · 1.84 KB
/
provision_vagrant.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
61
62
63
#!/usr/bin/env bash
export DEBIAN_FRONTEND=noninteractive
sudo locale-gen "en_US.UTF-8"
sudo dpkg-reconfigure locales
echo "LC_ALL=en_US.UTF-8" >> /etc/environment
echo "LANG=en_US.UTF-8" >> /etc/environment
PACKAGES="python-psycopg2 sqlite3 git postgresql-server-dev-9.3 \
python-dev python3-dev libffi-dev \
postgresql-9.3 python3-psycopg2 mysql-server-5.6 build-essential"
apt-get update
apt-get install -y ${PACKAGES}
if [ ! -f /usr/local/bin/pip ]; then
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
fi
if [ ! -f /usr/local/bin/pip3 ]; then
sudo python3 get-pip.py
fi
sudo mysqladmin -u root password toor
PYTHON_PACKAGES="psycopg2 pymysql pymongo==2.8 pexpect coverage unittest2 \
virtualenvwrapper"
sudo pip3 install ${PYTHON_PACKAGES}
sudo pip install ${PYTHON_PACKAGES}
# install mongodb
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu \
"$(lsb_release -sc)"/mongodb-org/3.0 multiverse" \
| sudo tee /etc/apt/sources.list.d/mongodb-org-3.1.list
sudo apt-get update
sudo apt-get install -y mongodb-org
cd /home/vagrant
if [ ! -d pwman3 ]; then
git clone https://github.com/pwman3/pwman3.git
chown vagrant:vagrant -R pwman3
fi
# setup mysql
mysql -e 'CREATE DATABASE IF NOT EXISTS pwmantest' -uroot --password=toor
mysql -e "create user 'pwman'@'localhost' IDENTIFIED BY '123456'" -uroot --password=toor
mysql -e "grant all on pwmantest.* to 'pwman'@'localhost';" -uroot --password=toor
# setup postgresql
sudo -u postgres psql -c "CREATE USER tester WITH PASSWORD '123456';" -U postgres
sudo -u postgres psql -c 'create database pwman;' -U postgres
sudo -u postgres psql -c 'grant ALL ON DATABASE pwman to tester' -U postgres
# setup mongodb
mongo < /home/vagrant/pwman3/tests/init_mongo.js
#mongo pwmantest --eval 'db.addUser("tester", "12345678");'