forked from osm-search/Nominatim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvagrant-provision.sh
executable file
·170 lines (122 loc) · 4.15 KB
/
vagrant-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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash
## During 'vagrant provision' this script runs as root and the current
## directory is '/root'
USERNAME=vagrant
###
### maybe create ubuntu user
###
# if [[ ! `id -u $USERNAME` ]]; then
# useradd $USERNAME --create-home --shell /bin/bash
#
# # give sudo power
# echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/99-$USERNAME-user
# chmod 0440 /etc/sudoers.d/99-$USERNAME-user
# service sudo restart
#
# # add basic .profile
# cp -r .ssh .profile .bashrc /home/$USERNAME/
# chown -R $USERNAME /home/$USERNAME/.*
# chgrp -R $USERNAME /home/$USERNAME/.*
#
# # now ideally login as $USERNAME and continue
# su $USERNAME -l
# fi
sudo apt-get update -qq
sudo apt-get upgrade -y
# sudo apt-get install -y git-core screen
sudo apt-get install -y build-essential libxml2-dev libgeos-dev libpq-dev libbz2-dev \
libtool automake libproj-dev libboost-dev libboost-system-dev \
libboost-filesystem-dev libboost-thread-dev
sudo apt-get autoremove -y
# get arrow-keys working in terminal (e.g. editing in vi)
echo 'stty sane' >> ~/.bash_profile
echo 'export TERM=linux' >> ~/.bash_profile
source ~/.bash_profile
###
### PostgreSQL 9.3 + PostGIS 2.1
###
sudo apt-get install -y postgresql-9.3-postgis-2.1 postgresql-contrib-9.3 postgresql-server-dev-9.3
# already included: proj-bin libgeos-dev
# make sure OS-authenticated users (e.g. $USERNAME) can access
sudo sed -i "s/ident/trust/" /etc/postgresql/9.3/main/pg_hba.conf
sudo sed -i "s/md5/trust/" /etc/postgresql/9.3/main/pg_hba.conf
sudo sed -i "s/peer/trust/" /etc/postgresql/9.3/main/pg_hba.conf
sudo /etc/init.d/postgresql restart
# creates the role
sudo -u postgres createuser -s $USERNAME
###
### PHP for frontend
###
sudo apt-get install -y php5 php5-pgsql php-pear
sudo pear install DB
# get rid of some warning
# where is the ini file? 'php --ini'
echo "date.timezone = 'Etc/UTC'" | sudo tee /etc/php5/cli/conf.d/99-timezone.ini > /dev/null
###
### Nominatim
###
sudo apt-get install -y libprotobuf-c0-dev protobuf-c-compiler \
libgeos-c1 libgeos++-dev \
lua5.2 liblua5.2-dev
# git clone --recursive https://github.com/twain47/Nominatim.git
# now ideally login as $USERNAME and continue
su $USERNAME -l
cd /home/vagrant/Nominatim
# cd ~/Nominatim
./autogen.sh
./configure
make
chmod +x ./
chmod +x ./module
LOCALSETTINGS_FILE='settings/local.php'
if [[ -e "$LOCALSETTINGS_FILE" ]]; then
echo "$LOCALSETTINGS_FILE already exist, writing to settings/local-vagrant.php instead."
LOCALSETTINGS_FILE='settings/local-vagrant.php'
fi
# IP=`curl -s http://bot.whatismyipaddress.com`
IP=localhost
echo "<?php
// General settings
@define('CONST_Database_DSN', 'pgsql://@/nominatim');
// Paths
@define('CONST_Postgresql_Version', '9.3');
@define('CONST_Postgis_Version', '2.1');
// Website settings
@define('CONST_Website_BaseURL', 'http://$IP:8089/nominatim/');
" > $LOCALSETTINGS_FILE
###
### Setup Apache/website
###
sudo -u postgres createuser -SDR www-data
echo '
Listen 8089
<VirtualHost *:8089>
# DirectoryIndex index.html
# ErrorDocument 403 /index.html
DocumentRoot "/var/www/"
<Directory "/var/www/nominatim/">
Options FollowSymLinks MultiViews
AddType text/html .php
</Directory>
</VirtualHost>
' | sudo tee /etc/apache2/sites-enabled/nominatim.conf > /dev/null
sudo apache2ctl graceful
sudo mkdir -m 755 /var/www/nominatim
sudo chown $USERNAME /var/www/nominatim
./utils/setup.php --threads 1 --create-website /var/www/nominatim
# if you get 'permission denied for relation word', then try
# GRANT usage ON SCHEMA public TO "www-data";
# GRANT SELECT ON ALL TABLES IN SCHEMA public TO "www-data";
##
## Test suite (Python)
## https://github.com/twain47/Nominatim/tree/master/tests
##
sudo apt-get install -y python-dev python-pip python-Levenshtein tidy
sudo pip install lettuce nose pytidylib haversine psycopg2 shapely
##
## Test suite (PHP)
## https://github.com/twain47/Nominatim/tree/master/tests-php
##
wget --no-clobber -q https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit