diff --git a/resources/generate_cert.sh b/resources/generate_cert.sh index b510045..c5345f1 100755 --- a/resources/generate_cert.sh +++ b/resources/generate_cert.sh @@ -1,25 +1,24 @@ #!/bin/bash -# Directory where the certificate and key will be stored -CERT_DIR="$HOME/.nginx" - -# Certificate and key configuration -ALG_NAME="rsa" -ALG_SIZE="4096" -DAYS="3650" -CN="ip.aumaton.com" +# Key and certificate configuration +ALG_NAME=${ALG_NAME:-rsa} +ALG_SIZE=${ALG_SIZE:-4096} +DAYS=${DAYS:-3650} +CN=${CN:-ip.aumaton.com} +# Directory where the key and certificate will be stored +CERT_DIR="$HOME/.nginx" -# Check if the directory exists, create if not +# Make sure CERT_DIR exists if [ ! -d "$CERT_DIR" ]; then mkdir -p "$CERT_DIR" fi # Set the filenames -CERT_FILE="$CERT_DIR/cert.pem" KEY_FILE="$CERT_DIR/key.pem" +CERT_FILE="$CERT_DIR/cert.pem" # Generate the key and certificate openssl req -x509 -newkey $ALG_NAME:$ALG_SIZE -keyout "$KEY_FILE" -out "$CERT_FILE" -days $DAYS -nodes -subj "/CN=$CN" -echo "Certificate and key have been generated in $CERT_DIR" +echo "Key and certificate have been generated in $CERT_DIR"