-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update generate_cert.sh to accept env variables
- Loading branch information
Showing
1 changed file
with
10 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |