Skip to content

Commit

Permalink
add start.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelsquared committed Jul 1, 2020
1 parent 21e9858 commit 6c15610
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ RUN mkdir /build && \
make install && \
cd / && \
rm -rf /build

COPY start.sh /

ENTRYPOINT ["/start.sh"]
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Postgresql with GVM Libraries
32 changes: 32 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

if [ ! -d /data/database ]; then
echo "Creating Database folder..."
mkdir -p /data/database
chown postgres:postgres -R /data/database
su -c "/usr/lib/postgresql/12/bin/initdb --pgdata=/data/database" postgres
fi

chown postgres:postgres -R /data/database

echo "Starting PostgreSQL..."
su -c "/usr/lib/postgresql/12/bin/pg_ctl --timeout=600 --wait --pgdata=/data/database start" postgres

if [ ! -f "/data/firstrun" ]; then
echo "Creating Greenbone Vulnerability Manager database"
su -c "createuser -DRS gvm" postgres
su -c "createdb -O gvm gvmd" postgres
su -c "psql --dbname=gvmd --command='create role dba with superuser noinherit;'" postgres
su -c "psql --dbname=gvmd --command='grant dba to gvm;'" postgres
su -c "psql --dbname=gvmd --command='create extension \"uuid-ossp\";'" postgres
touch /data/firstrun
fi

function stop-postgresql()
{
su -c "/usr/lib/postgresql/12/bin/pg_ctl --wait --pgdata=/data/database stop" postgres
}

trap stop-postgresql EXIT

tail -f /var/log/postgresql/*

0 comments on commit 6c15610

Please sign in to comment.