-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpg_provision.sh
More file actions
69 lines (48 loc) · 1.64 KB
/
pg_provision.sh
File metadata and controls
69 lines (48 loc) · 1.64 KB
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
#!/bin/sh
if [ -n "$2" ]
then
BFIP=$1
PGIP=$2
cat >> /etc/hosts <<-EOF
$BFIP bfserver
$PGIP pgwebserver
EOF
fi
# box should be already provisioned with required packages
cd /opt
git clone https://git.postgresql.org/git/pgweb.git
cd pgweb
sed -i s/psycopg2/psycopg2-binary/ requirements.txt
pip3 install -r requirements.txt
su - postgres -c 'createdb pgweb'
cat > pgweb/settings_local.py <<EOF
DEBUG=True
# TEMPLATE_DEBUG=DEBUG
SITE_ROOT="http://$PGIP:8000"
SESSION_COOKIE_SECURE=False
SESSION_COOKIE_DOMAIN=None
EOF
su - postgres -c "cd /opt/pgweb && ./manage.py migrate"
su - postgres -c "cd /opt/pgweb && psql -f sql/varnish.sql pgweb"
su - postgres -c "cd /opt/pgweb/pgweb && echo yes | ./load_initial_data.sh"
cat > /tmp/newusers.py <<EOF
from django.contrib.auth import get_user_model
get_user_model().objects.create_user(username='curly',
email='curly@foo.com', password='curlycurlycurly')
get_user_model().objects.create_user(username='larry',
email='larry@foo.com', password='larrylarrylarry')
get_user_model().objects.create_user(username='mo',
email='mo@foo.com', password='momomo')
EOF
su - postgres -c "cd /opt/pgweb && ./manage.py shell < /tmp/newusers.py"
cat > /tmp/authsite.sql <<EOF
insert into public.account_communityauthorg values(default,'testbf',false);
insert into public.account_communityauthsite values(default,'testbf site', 'http://$BFIP/auth','x4dFBEISD6WL7Op8JNI/1xY0RUJSQM4ySbgquGwTvlQ=','foo bar',1,2);
EOF
su - postgres -c "psql -f /tmp/authsite.sql pgweb"
cat <<EOF
Now login to the machine and as user postgres do:
cd /opt/pgweb
./manage.py runserver 0.0.0.0:8000
This can also usefully be run in screen session
EOF