-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision.sh
118 lines (94 loc) · 3.97 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
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
#!/bin/sh
echo "
########################################################################
_ _
_ __ _ __ _____ _(_)___(_) ___ _ __
| '_ \| '__/ _ \ \ / / / __| |/ _ \| '_ \
| |_) | | | (_) \ V /| \__ \ | (_) | | | |
| .__/|_| \___/ \_/ |_|___/_|\___/|_| |_|
|_|
Author: Andrew Duncan <[email protected]>, <[email protected]>
Project: nsvm
Experiment: Node out of range prediction
########################################################################
"
# Update and upgrade
echo "Updating system..."
apt-get update > /dev/null 2>&1
echo "Upgrading system packages..."
apt-get -y upgrade > /dev/null 2>&1
# Install system dependencies.
echo "Installing system dependencies: python-virtualenv, python-pip, tcl, tcl-dev, ns2..."
apt-get -y install python-virtualenv python-pip tcl tcl-dev ns2 > /dev/null 2>&1
echo "Installing ns-2 build dependencies: build-essential, autoconf, automake, libxmu-dev, dpkg-dev, libx11-dev..."
apt-get -y install build-essential autoconf automake libxmu-dev dpkg-dev libx11-dev > /dev/null 2>&1
# Build pip dependencies for numpy and scipy
echo "Building system dependencies for application dependencies: python-numpy, python-scipy."
apt-get -y build-dep python-numpy python-scipy > /dev/null 2>&1
# ns-2.35 build requires gcc-4.4
echo "Installing gcc-4.4 to build ns-2.35 with no code modifications."
apt-get -y install gcc-4.4 g++-4.4
# Build ns-2
if [ ! -d "/home/vagrant/ns-allinone-2.35" ];
then
cd /home/vagrant/
echo "Downloading ns-2.35 from sourceforge.net."
wget "http://downloads.sourceforge.net/project/nsnam/allinone/ns-allinone-2.35/ns-allinone-2.35.tar.gz?r=&ts=1395619377&use_mirror=tcpdiag"
mv ns-allinone*.tar.gz* ns-allinone-2.35.tar.gz
echo "Uncompressing tarball."
tar xzf ns-allinone-2.35.tar.gz
echo "Adding environment variables to .bashrc..."
cat /vagrant/bashrc_template.txt >> /home/vagrant/.bashrc
echo "Inserting aodve extensions..."
mkdir /home/vagrant/ns-allinone-2.35/ns-2.35/aodve/
cp /vagrant/aodve/* /home/vagrant/ns-allinone-2.35/ns-2.35/aodve/
# echo "Exporting CC=gcc-4.4 GXX=g++-4.4 to build ns-2."
export CC=gcc-4.4 CXX=g++-4.4
echo "Building ns-2..."
cd /home/vagrant/ns-allinone-2.35
/home/vagrant/ns-allinone-2.35/install > /dev/null 2>&1
echo "Fixing ownership permissions..."
chown -R vagrant:vagrant /home/vagrant/ns-allinone-2.35
fi
# Create a virtual environment for nsvm
if [ ! -d "/home/vagrant/nsvm_env2" ];
then
echo "Creating application virtual environment."
sudo -u vagrant virtualenv -p python2 /home/vagrant/nsvm_env2 > /dev/null 2>&1
fi
# Install all the dependencies in the order which satisfies requirements.
if [ -d /home/vagrant/nsvm_env2 ];
then
echo "Installing appliction dependencies."
echo "Installing numpy dependency..."
sudo -u vagrant /home/vagrant/nsvm_env2/bin/pip install numpy > /dev/null 2>&1
echo "Installing scipy dependency..."
sudo -u vagrant /home/vagrant/nsvm_env2/bin/pip install scipy > /dev/null 2>&1
echo "Installing pandas dependency..."
sudo -u vagrant /home/vagrant/nsvm_env2/bin/pip install pandas > /dev/null 2>&1
echo "Installing requirements for nsvm simulation..."
sudo -u vagrant /home/vagrant/nsvm_env2/bin/pip install -r /vagrant/simulation/requirements.txt > /dev/null 2>&1
echo "Done installing all application dependencies."
fi
# Remove previous timestamp-started file.
if [ -f /home/vagrant/started ];
then
echo "Clearing previous started file."
rm /home/vagrant/started
fi
# Create started file with timestamp.
touch /home/vagrant/started
echo "Timestamp file created under /home/vagrant/started"
if [ -d /home/vagrant/nsvm_env2 ] && [ -d /vagrant/simulation ] && [ -f /vagrant/nsvm.py ];
then
echo "
########################################################################
Running experiment...
"
cd /vagrant
sudo -u vagrant /home/vagrant/nsvm_env2/bin/python /vagrant/nsvm.py
echo "
Experiment complete.
########################################################################
"
fi