-
Notifications
You must be signed in to change notification settings - Fork 18
/
quickstart.sh
executable file
·81 lines (67 loc) · 3.04 KB
/
quickstart.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
#!/bin/bash -e
echo ""
echo "********************************************************************"
echo "********************************************************************"
echo ""
echo " UrbanFootprint quickstart process is starting ..."
echo ""
echo "********************************************************************"
echo "********************************************************************"
echo ""
apt-get update
apt-get install -y software-properties-common
apt-add-repository -y ppa:ansible/ansible-1.9
apt-get update
apt-get install -y ansible git
mkdir -p /srv/calthorpe/
# clone urbanfootprint repos
cd /srv/calthorpe/
git clone https://github.com/CalthorpeAnalytics/urbanfootprint.git urbanfootprint
cd /srv/calthorpe/urbanfootprint/
git submodule init
git submodule update
# run ansible provisioning
cd /srv/calthorpe/urbanfootprint/provisioning
ansible-galaxy install -f -r galaxy-roles.yml
ansible-playbook -v -i 'localhost', -c local site.yml
# let calthorpe user ssh in for fabric
su - calthorpe -c "ssh-keygen -f ~/.ssh/id_rsa -N ''"
su - calthorpe -c "ssh-keyscan -H localhost > ~/.ssh/known_hosts"
su - calthorpe -c "cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys"
# set file permissions
chown -R calthorpe:calthorpe /srv/calthorpe/urbanfootprint*
# stop all services
supervisorctl stop all
service supervisor stop
service postgresql restart
# install python dependencies (though really all we need is fabric as this point)
/srv/calthorpe_env/bin/pip install -r /srv/calthorpe/urbanfootprint/requirements.txt
chown -R calthorpe:calthorpe /srv/calthorpe_env
# copy sample environment settings for default configuration
cp /srv/calthorpe/urbanfootprint/.env.sample /srv/calthorpe/urbanfootprint/.env
chown calthorpe:calthorpe /srv/calthorpe/urbanfootprint/.env
# retrieve sample web database
wget -O /srv/datadump/urbanfootprint-sacog-web-db.sql.gz https://s3-us-west-2.amazonaws.com/uf-provisioning/urbanfootprint-sacog-web-db.sql.gz
gunzip -f /srv/datadump/urbanfootprint-sacog-web-db.sql.gz
# import sample web database
psql -U postgres -c "DROP DATABASE IF EXISTS urbanfootprint;"
psql -U postgres -c "CREATE DATABASE urbanfootprint;"
psql -U postgres -c "GRANT ALL ON DATABASE urbanfootprint TO calthorpe;"
psql -U postgres urbanfootprint < /srv/datadump/urbanfootprint-sacog-web-db.sql
# finish installation and deployment process
su - calthorpe -c "/srv/calthorpe_env/bin/fab -f /srv/calthorpe/urbanfootprint/footprint/installer localhost quickstart"
external_ip=$(curl -s 'https://api.ipify.org')
echo ""
echo "********************************************************************"
echo "********************************************************************"
echo ""
echo " UrbanFootprint quickstart is complete. Open your web browser to:"
echo " http://${external_ip}/"
echo " using the following default credentials:"
echo " user: [email protected]"
echo " pass: admin@uf"
echo ""
echo "********************************************************************"
echo "********************************************************************"
echo ""
exit 0