-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup.sh
37 lines (26 loc) · 1.13 KB
/
startup.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
#!/bin/bash
if ! grep -q bdserver=$DBHOST /etc/boca.conf; then
touch ~/.pgpass
echo $DBHOST:5432:*:$DBUSER:$DBPASS > ~/.pgpass
chmod 600 ~/.pgpass
until psql -h "$DBHOST" -U "$DBUSER" -c '\l'; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
. /etc/boca.conf
echo "bdserver=$DBHOST" >> /etc/boca.conf
privatedir=$bocadir/src/private
PASSK=`makepasswd --chars 20`
awk -v dbhost="$DBHOST" -v pass="$DBPASS" -v passk="$PASSK" '{ if(index($0,"[\"dbpass\"]")>0) \
print "$conf[\"dbpass\"]=\"" pass "\";"; \
else if(index($0,"[\"dbhost\"]")>0) print "$conf[\"dbhost\"]=\"" dbhost "\";"; \
else if(index($0,"[\"dbsuperpass\"]")>0) print "$conf[\"dbsuperpass\"]=\"" pass "\";"; \
else if(index($0,"[\"key\"]")>0) print "$conf[\"key\"]=\"" passk "\";"; else print $0; }' \
< $privatedir/conf.php > $privatedir/conf.php1
mv -f $privatedir/conf.php1 $privatedir/conf.php
php ${bocadir}/src/private/createdb.php <<< $(echo YES)
echo 'bdcreated=y' >> /etc/boca.conf
fi
# Run the apache process in the foreground as in the php image
echo "[Boca startup] Starting apache..."
apache2-foreground