diff --git a/Config/ReverseProxy/create_letsencrypt_certs.sh b/Config/ReverseProxy/create_letsencrypt_certs.sh index 339779d..d0357bb 100755 --- a/Config/ReverseProxy/create_letsencrypt_certs.sh +++ b/Config/ReverseProxy/create_letsencrypt_certs.sh @@ -1,6 +1,8 @@ #!/bin/bash # Create a real cert for each file in config/conf.d/. +## Variables ## + DIR=`dirname $0` if [[ $DIR == \.* ]]; then DIR=`pwd` @@ -10,8 +12,10 @@ fi CERT_DIR=$DIR/../../Volumes/ReverseProxy/letsencrypt-certs echo "CERT_DIR=$CERT_DIR" +## Validations ## + # Ensure that fake certs were created at some point, or that the system has been run at least once. -if [[ ! -d $DIR/../../Volumes/ReverseProxy/letsencrypt-certs ]]; then +if [[ ! -d $CERT_DIR ]]; then echo "ERROR: Certificate directory does not exist yet. Run the placeholder script first." >&2 exit 1 fi @@ -23,6 +27,8 @@ if [[ $certbot_running != 1 ]]; then exit 1 fi +## Input ## + # Gather information from the user. echo -n "Please provide the email address you would like the certs bound to: " read email @@ -39,6 +45,8 @@ if [[ $confirm != "Y"* ]]; then exit 0 fi +## Main ## + # Loop over the proxy configuration files and ensure they have certs. ls $DIR/config/conf.d/*.* | while read file; do filename=`basename $file` @@ -71,3 +79,5 @@ ls $DIR/config/conf.d/*.* | while read file; do continue fi done + +exit 0 diff --git a/Config/ReverseProxy/create_placeholder_certs.sh b/Config/ReverseProxy/create_placeholder_certs.sh index 4335c50..fcc14f8 100755 --- a/Config/ReverseProxy/create_placeholder_certs.sh +++ b/Config/ReverseProxy/create_placeholder_certs.sh @@ -1,6 +1,8 @@ #!/bin/bash # Create a fake cert for each file in config/conf.d/. +## Variables ## + DIR=`dirname $0` if [[ $DIR == \.* ]]; then DIR=`pwd` @@ -10,8 +12,10 @@ fi CERT_DIR=$DIR/../../Volumes/ReverseProxy/letsencrypt-certs echo "CERT_DIR=$CERT_DIR" +## Main ## + # Create the directory if it does not exist. -mkdir -pv $DIR/../../Volumes/ReverseProxy/letsencrypt-certs +mkdir -pv $CERT_DIR # Loop over the proxy configuration files and ensure they have certs. ls $DIR/config/conf.d/*.* | while read file; do @@ -29,3 +33,5 @@ ls $DIR/config/conf.d/*.* | while read file; do echo "Certs already exist!" fi done + +exit 0