-
Notifications
You must be signed in to change notification settings - Fork 0
/
installDBDryads.sh
66 lines (46 loc) · 1.55 KB
/
installDBDryads.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
#!/bin/bash
PG_DB='postgresql-9.4.4' # your version of PG
PG_FOLDER='postgres'
username='fgmehlin' # your name
PORTNUMBER=4445 # your port number
lcshit='en_US.UTF-8'
DB_DUMP='asl_db.pgsql' # name of your DB dump
clusterHome="/mnt/local/${username}"
pathToPostgres="${clusterHome}/postgres"
PG_HBA="pg_hba.conf"
PSQL_CONF="postgresql.conf"
if [ -d "/mnt/local/${fusername}" ]; then
echo "Creating /mnt/local/${username}"
mkdir "/mnt/local/${username}"
fi
echo "cd /mnt/local/fgmehlin"
cd "/mnt/local/${username}"
echo "extracting postgres"
tar xjf "$PG_DB.tar.bz2"
cd "$PG_DB"
./configure --prefix="/mnt/local/${username}/postgres"
echo "postgres configured"
make
make install
echo "postgres installed"
export LD_LIBRARY_PATH=/mnt/local/$username/postgres/lib
LC_CTYPE=$lcshit
export LC_CTYPE
$pathToPostgres/bin/initdb -D $pathToPostgres/db
cp -rf ~/asl/$PG_HBA $pathToPostgres/db/
cp -rf ~/asl/$PSQL_CONF $pathToPostgres/db/
$pathToPostgres/bin/postgres -D $pathToPostgres/db/ -p $PORTNUMBER -i -k $clusterHome >/mnt/local/$username/db.out 2>&1 &
while [ `cat /mnt/local/$username/db.out | grep 'database system is ready to accept connections' | wc -l` != 1 ]
do
sleep 1
done
$pathToPostgres/bin/createdb -p $PORTNUMBER -h $clusterHome
echo "Database created"
# Adapt this shit to your shit
$pathToPostgres/bin/psql -p $PORTNUMBER -h $clusterHome << EOF
create role asl_pg;
create database asl;
alter role asl_pg login;
alter database asl owner to asl_pg;
EOF
$pathToPostgres/bin/psql -p $PORTNUMBER -h $clusterHome -U asl_pg asl < $clusterHome/$DB_DUMP