From 57e0cb772c45052c9488004dd7c6d28ba2ebe430 Mon Sep 17 00:00:00 2001 From: deityhub Date: Wed, 3 Feb 2021 10:19:37 +0100 Subject: [PATCH] setup private, public, tls_cert and tls_key key and export to machine --- ci/scripts/deployment-setup.sh | 17 +++++++++++++++++ install.sh | 25 +++++++++++++++++++++---- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/ci/scripts/deployment-setup.sh b/ci/scripts/deployment-setup.sh index f4087dbf3b..79e555ff9b 100644 --- a/ci/scripts/deployment-setup.sh +++ b/ci/scripts/deployment-setup.sh @@ -15,3 +15,20 @@ sudo mkdir /root/.kube || echo "Directory already created." #Init auth echo "Auth doctl" sudo doctl auth init -t $DIGITALOCEAN_TOKEN + +# create private key and public key +echo "Setup private and public key" +openssl genrsa -out private 2048 +chmod 0400 private +openssl rsa -in private -out public -pubout +# value of DKIM dns record +echo "DKIM DNS TXT Record" +echo "DNS Selector: fyipe._domainkey" +echo "DNS Value: v=DKIM1;p=$(grep -v '^-' public | tr -d '\n')" +export PRIVATE_KEY=$(cat private | base64) +# generate tls_cert.pem and tls_key.pem files with there keys +echo "Setup tls_cert and tls_key" +openssl req -x509 -nodes -days 2190 -newkey rsa:2048 -keyout tls_key.pem -out tls_cert.pem -subj "/C=US/ST=Massachusetts/L=Boston/O=Hackerbay/CN=globalminimalism.com" +# Encode your tls to base64 and export it +export TLS_KEY=$(cat tls_key.pem | base64) +export TLS_CERT=$(cat tls_cert.pem | base64) diff --git a/install.sh b/install.sh index 70d74b1df9..f0632d480a 100755 --- a/install.sh +++ b/install.sh @@ -1,17 +1,34 @@ #!/bin/bash # This script runs the local development server in Docker. -if [[ ! $(which docker) && ! $(docker --version) ]] -then +if [[ ! $(which docker) && ! $(docker --version) ]]; then echo -e "\033[91mPlease install Docker. https://docs.docker.com/install" exit fi +# create private key and public key +openssl genrsa -out private 2048 +chmod 0400 private +openssl rsa -in private -out public -pubout + +# value of DKIM dns record +echo "DKIM DNS TXT Record" +echo "DNS Selector: fyipe._domainkey" +echo "DNS Value: v=DKIM1;p=$(grep -v '^-' public | tr -d '\n')" +export PRIVATE_KEY=$(cat private | base64) + +# generate tls_cert.pem and tls_key.pem files with there keys +openssl req -x509 -nodes -days 2190 -newkey rsa:2048 -keyout tls_key.pem -out tls_cert.pem -subj "/C=US/ST=Massachusetts/L=Boston/O=Hackerbay/CN=globalminimalism.com" + +# Encode your tls to base64 and export it +export TLS_KEY=$(cat tls_key.pem | base64) +export TLS_CERT=$(cat tls_cert.pem | base64) + sudo chmod +x ./uninstall.sh sudo ./uninstall.sh -# Sleep +# Sleep sleep 5s #Docker compose up as a daemon. -sudo -E docker-compose up -d --build \ No newline at end of file +sudo -E docker-compose up -d --build