refactor script

This commit is contained in:
deityhub
2021-02-11 22:49:05 +01:00
parent 074fa99141
commit 4df7776386
3 changed files with 60 additions and 55 deletions

View File

@@ -6,23 +6,31 @@ if [[ ! $(which docker) && ! $(docker --version) ]]; then
exit
fi
# create private key and public key
openssl genrsa -out private 2048
chmod 0400 private
openssl rsa -in private -out public -pubout
if [[ ! -n $DOMAIN ]]; then
export DOMAIN=fyipe.com
fi
# 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)
if [[ ! -n $DKIM_PRIVATE_KEY ]]; then
# 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 DKIM_PRIVATE_KEY=$(cat private | base64)
fi
# 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)
if [[ ! -n $TLS_KEY ]] && [[ ! -n $TLS_CERT ]]; then
# 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=$DOMAIN"
# Encode your tls to base64 and export it
export TLS_KEY=$(cat tls_key.pem | base64)
export TLS_CERT=$(cat tls_cert.pem | base64)
fi
sudo chmod +x ./uninstall.sh
sudo ./uninstall.sh