This repository has been archived by the owner on Dec 11, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VagrantfileLocal
120 lines (96 loc) · 4.23 KB
/
VagrantfileLocal
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# expfactory-vm, testing
# poldracklab
VAGRANTFILE_API_VERSION = "2"
$script = <<SCRIPT
if [ ! -d $HOME/miniconda2 ]
then
# install anaconda
wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
chmod +x miniconda.sh
./miniconda.sh -b
echo "export PATH=$HOME/miniconda2/bin:\\$PATH" >> .bashrc
echo "export PATH=$HOME/miniconda2/bin:\\$PATH" >> .env
fi
# install python packages
$HOME/miniconda2/bin/conda update --yes conda
$HOME/miniconda2/bin/pip install setuptools
$HOME/miniconda2/bin/conda install --yes pip numpy scipy nose traits networkx
$HOME/miniconda2/bin/conda install --yes pandas
sudo apt-get update -y > /dev/null
sudo apt-get install -y --force-yes git-core
sudo apt-get install -y --force-yes build-essential libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip
sudo apt-get install -y --force-yes nginx
# Install expfactory
sudo apt-get install -y --force-yes libreadline6 libreadline6-dev
sudo apt-get install -y --force-yes libncurses-dev
$HOME/miniconda2/bin/pip install python-Levenshtein
$HOME/miniconda2/bin/pip install expfactory
# Psiturk
$HOME/miniconda2/bin/pip install psiturk
sudo pip install --upgrade requests
psiturk-setup-example
# Install postgresql (not tested)
sudo apt-get install -y --force-yes postgresql postgresql-contrib
sudo apt-get install -y --force-yes pgadmin3
sudo apt-get install -y --force-yes libpq-dev
sudo -u postgres psql -c "CREATE USER expfactory WITH PASSWORD 'expfactory';"
sudo -u postgres psql -c "CREATE DATABASE expfactory;"
$HOME/miniconda2/bin/pip install psycopg2
# Install MySQL
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password expfactory'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password expfactory'
sudo apt-get install -y --force-yes libmysqlclient-dev
sudo apt-get install -y --force-yes mysql-server
$HOME/miniconda2/bin/pip install MySQL-python
sudo apt-get install -y --force-yes vim
sudo /etc/init.d/nginx start
# Install expfactory to generate everything else
mkdir -p $HOME/expfactory-build
if [ ! -d $HOME/expfactory-build/expfactory-python ]
then
git clone https://github.com/expfactory/expfactory-python.git $HOME/expfactory-build/expfactory-python
cd $HOME/expfactory-build/expfactory-python
$HOME/miniconda2/bin/pip install -r requirements.txt
$HOME/miniconda2/bin/python setup.py install
fi
# Download experiments, battery, vm, doc repos
sudo chmod u+x $HOME/expfactory-build/expfactory-python/script/download_repos.py
$HOME/miniconda2/bin/python $HOME/expfactory-build/expfactory-python/script/download_repos.py $HOME/expfactory-build
sudo mysql -uroot -pexpfactory < $HOME/expfactory-build/vm/script/createdb.sql
# Replace standard index.html with link to expfactory docs
sudo mv $HOME/expfactory-build/vm/static/index.html /var/www/nginx-default/index.html
CUSTOM_INSTALL="False"
if [[ $CUSTOM_INSTALL == "False" ]] ; then
sudo chmod u+x $HOME/expfactory-build/expfactory-python/script/standard_setup_battery.py
$HOME/miniconda2/bin/python $HOME/expfactory-build/expfactory-python/script/standard_setup_battery.py $HOME/expfactory-battery
else
if ! [ -f $HOME/custom_setup_battery.py ]; then
echo """
#!/usr/bin/python
from expfactory.battery import generate
import sys
battery_dest = sys.argv[1]
config = [SUB_CONFIG_SUB]
experiments = [SUB_EXPERIMENTS_SUB]
generate(battery_dest=battery_dest,experiments=experiments,config=config)
""" >/tmp/aijfaef
sudo cp /tmp/aijfaef $HOME/custom_setup_battery.py
fi
sudo chmod u+x $HOME/custom_setup_battery.py
$HOME/miniconda2/bin/python $HOME/custom_setup_battery.py $HOME/expfactory-battery
fi
# User should log in to battery folder
cd $HOME/expfactory-battery
echo "Experiment factory battery generation complete!"
echo "Log in with ssh vagrant"
echo "Your machine's external address is 192.128.0.20"
SCRIPT
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define :engine do |engine_config|
engine_config.vm.box = "ubuntu12.04-x64"
engine_config.vm.box_url = "http://files.vagrantup.com/precise64.box"
engine_config.vm.network :private_network, ip: "192.128.0.20"
engine_config.vm.hostname = 'expfactory-battery'
engine_config.vm.provision "shell", :privileged => false, inline: $script
end
end