forked from GENI-NSF/geni-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprep-ch.sh
executable file
·137 lines (112 loc) · 4.45 KB
/
prep-ch.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
#!/bin/sh
# A script to configure a GPO lab VM with the right stuff
# to allow the prototype clearinghouse to run.
check_errs()
{
# Function. Parameter 1 is the return code
# Para. 2 is text to display on failure.
if [ "${1}" -ne "0" ]; then
echo "ERROR # ${1} : ${2}"
# as a bonus, make our script exit with the right error code.
exit ${1}
fi
}
PKGS="postgresql git-core apache2 php5-pgsql php-mdb2-driver-pgsql"
PKGS="$PKGS php5-uuid php5-curl curl python-psycopg2 autoconf libtool"
PKGS="$PKGS putty"
# Packages for gcf/omni
PKGS="$PKGS python-m2crypto python-dateutil python-pyopenssl"
PKGS="$PKGS libxmlsec1 xmlsec1 libxmlsec1-openssl libxmlsec1-dev"
/usr/bin/sudo /usr/bin/apt-get update
check_errs $? "apt-get failed to update"
/usr/bin/sudo /usr/bin/apt-get -y dist-upgrade
check_errs $? "apt-get failed to dist-upgrade"
/usr/bin/sudo /usr/bin/apt-get install -y ${PKGS}
check_errs $? "apt-get failed to install packages"
#
# gcf installation
#
SHARE_DIR=/usr/share/geni-ch/portal
# Make a directory for gcf to live in
if [ ! -d "${SHARE_DIR}" ]; then
/usr/bin/sudo /bin/mkdir -p "${SHARE_DIR}"
fi
GCF=gcf-2.4-rc2
GCF_PKG=${GCF}.tar.gz
/usr/bin/wget http://www.gpolab.bbn.com/internal/projects/proto-ch/${GCF_PKG}
/usr/bin/sudo /bin/tar xzfC "${GCF_PKG}" "${SHARE_DIR}"
/usr/bin/sudo /bin/ln -s -f ${SHARE_DIR}/${GCF} ${SHARE_DIR}/gcf
SFA_TMP_FILES="/tmp/sfa.log /tmp/sfa_import.log"
/usr/bin/sudo /usr/bin/touch ${SFA_TMP_FILES}
/usr/bin/sudo /bin/chmod 777 ${SFA_TMP_FILES}
/usr/bin/sudo /bin/cp -R portal/gcf.d ${SHARE_DIR}
#
# Enable Apache rewrite module
#
/usr/bin/sudo /usr/sbin/a2enmod rewrite
#
# Restart Apache to find the new php packages.
#
/usr/bin/sudo /usr/sbin/service apache2 restart
# Set postgres password
echo
echo
echo "@@@@@@@@@@@@@@@@@@@@@"
echo "@"
echo "@ Please enter a database password for the 'postgres' user"
echo "@"
/usr/bin/sudo -u postgres /usr/bin/psql -c \\password
# Enable postgres accessibility in postgres.conf and pg_hba.conf
#----------------------------------------------------------------------
# Patch postgresql.conf to listen for network connections
#----------------------------------------------------------------------
/usr/bin/sudo /usr/bin/patch --backup -p 0 /etc/postgresql/8.4/main/postgresql.conf <<EOF
--- postgresql.conf.orig 2011-01-07 13:20:50.840787089 -0500
+++ postgresql.conf 2011-01-07 13:23:10.984792098 -0500
@@ -60,6 +60,7 @@
# comma-separated list of addresses;
# defaults to 'localhost', '*' = all
# (change requires restart)
+listen_addresses = '*'
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
# Note: Increasing max_connections costs ~400 bytes of shared memory per
EOF
check_errs $? "failed to patch postgresql.conf"
#----------------------------------------------------------------------
# Patch pg_hba.conf to allow md5 authentication from anywhere
#----------------------------------------------------------------------
/usr/bin/sudo /usr/bin/patch --backup -p 0 /etc/postgresql/8.4/main/pg_hba.conf <<EOF
--- pg_hba.conf.orig 2011-01-07 13:21:05.936789520 -0500
+++ pg_hba.conf 2011-01-07 13:31:12.880789053 -0500
@@ -84,3 +84,4 @@
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
+host all all 0.0.0.0/0 md5
EOF
check_errs $? "failed to patch pg_hba.conf"
#----------------------------------------------------------------------
# Restart PostgreSQL
#----------------------------------------------------------------------
/usr/bin/sudo /usr/sbin/service postgresql-8.4 restart
check_errs $? "failed to restart postgresql-8.4"
#----------------------------------------------------------------------
# Create the portal user and db
#----------------------------------------------------------------------
/usr/bin/sudo -u postgres /usr/bin/createuser -S -D -R portal
check_errs $? "failed to create user portal"
echo
echo
echo "@@@@@@@@@@@@@@@@@@@@@"
echo "@"
echo "@ Please enter a new database password for the 'portal' user"
echo "@"
/usr/bin/sudo -u postgres /usr/bin/psql -c "\\password portal"
check_errs $? "failed to set the password for portal user"
/usr/bin/sudo -u postgres /usr/bin/createdb portal
check_errs $? "failed to create the portal database"
#----------------------------------------------------------------------
# All done.
#----------------------------------------------------------------------
exit 0