Skip to content

Commit

Permalink
add scripts to generate demo root token
Browse files Browse the repository at this point in the history
  • Loading branch information
stremovsky committed Sep 29, 2023
1 parent 48436ed commit 51b3a16
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions generate-pgsql-demo-env-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh

echo 'creating ./data directory'
mkdir -p data
chmod 777 data
mkdir -p .env

echo 'generating .env/postgresql-postgres.env'
POSTGRES_PASSWORD=`< /dev/urandom LC_CTYPE=C tr -dc '_\*^A-Z-a-z-0-9' | head -c${1:-32};`
echo 'POSTGRES_PASSWORD='$POSTGRES_PASSWORD > .env/postgresql-postgres.env

echo 'generating .env/postgresql.env'
PGSQL_USER_PASSWORD=`< /dev/urandom LC_CTYPE=C tr -dc '_\*^A-Z-a-z-0-9' | head -c${1:-32};`
echo 'PGSQL_DATABASE=databunkerdb' > .env/postgresql.env
echo 'PGSQL_USER=bunkeruser' >> .env/postgresql.env
echo 'PGSQL_PASSWORD='$PGSQL_USER_PASSWORD >> .env/postgresql.env

echo 'generating .env/databunker.env'
KEY=`< /dev/urandom LC_CTYPE=C tr -dc 'a-f0-9' | head -c${1:-48};`
echo 'DATABUNKER_MASTERKEY='$KEY > .env/databunker.env
echo 'PGSQL_USER_NAME=bunkeruser' >> .env/databunker.env
echo 'PGSQL_USER_PASS='$PGSQL_USER_PASSWORD >> .env/databunker.env
echo 'PGSQL_HOST=postgresql' >> .env/databunker.env
echo 'PGSQL_PORT=5432' >> .env/databunker.env

echo 'generating ssl sertificate for postgres server'
rm -rf .env/pg-*
openssl req -new -text -passout pass:abcd -subj /CN=localhost -out .env/pg-server.req -keyout .env/pg-privkey.pem
openssl rsa -in .env/pg-privkey.pem -passin pass:abcd -out .env/pg-server.key
openssl req -x509 -in .env/pg-server.req -text -key .env/pg-server.key -out .env/pg-server.crt
chmod 400 .env/pg-*
sudo chown 999:0 .env/pg-*

echo 'generating .env/databunker-root.env'
ROOTTOKEN=DEMO
echo 'DATABUNKER_ROOTTOKEN='$ROOTTOKEN > .env/databunker-root.env

0 comments on commit 51b3a16

Please sign in to comment.