-
Notifications
You must be signed in to change notification settings - Fork 1
/
init_env_mac.sh
executable file
·93 lines (79 loc) · 2.84 KB
/
init_env_mac.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
#!/usr/bin/env bash
function install_package {
brew search postgis
brew tap homebrew/versions
sed -i .bak 's/postgresql/postgresql9/g' /usr/local/Library/Formula/postgis15.rb
brew install postgis15
brew install couchdb
brew install gdal
brew install geoip
brew install gettext
sudo brew link gettext
pip install numpy
}
function install_python_env {
curl -o setuptools-0.6c11-py2.7.egg http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg#md5=bfa92100bd772d5a213eedd356d64086
sudo sh setuptools-0.6c11-py2.7.egg
sudo easy_install pip
sudo pip install virtualenv
[ -d ~/virtual_env ] || mkdir virtual_env
cd virtual_env
virtualenv datawinners
[ -f ~/.bash_profile ] || touch ~/.bash_profile
echo 'alias dw="source ~/virtual_env/datawinners/bin/activate"' >> ~/.bash_profile
echo 'export PATH=/usr/local/Cellar/postgresql9/9.0.8/bin:$PATH' >> ~/.bash_profile
. ~/.bash_profile
}
function init_db {
initdb /usr/local/var/postgres9
[ -d /usr/local/var/postgres9 ] || mkdir -p /usr/local/var/postgres9
pg_ctl -D /usr/local/var/postgres9 -l /usr/local/var/postgres9/server.log start
}
function create_datawinners_db {
createdb geodjango
createlang plpgsql geodjango
psql -d geodjango -c 'create role jenkins login createdb createrole;'
psql -d geodjango -f '/usr/local/share/postgis/postgis.sql'
psql -d geodjango -f '/usr/local/share/postgis/spatial_ref_sys.sql'
psql -d geodjango -c 'grant all privileges on all tables in schema public to jenkins;'
}
function create_postgis_db {
POSTGIS_SQL_PATH=/usr/local/share/postgis
createdb -E UTF8 template_postgis # Create the template spatial database.
createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql # Loading the PostGIS SQL routines
psql -d template_postgis -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql
psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;" # Enabling users to alter spatial tables.
psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
}
function clone_code_base {
[ -d ~/workspace] || mkdir ~/workspace
cd ~/workspace
clone_repository datawinners
clone_repository mangrove
clone_repository shape_files
}
function clone_repository {
git clone https://github.com/mangroveorg/$1.git $1
}
function install_dependency {
dw
cd ~/workspace/datawinners
python datawinners/manage.py syncdb
python datawinners/manage.py migrate
python datawinners/manage.py loadshapes
couchdb -b
./build.sh init
}
function main {
install_package
install_python_env
init_db
create_datawinners_db
create_postgis_db
clone_code_base
install_dependency
}
main