diff --git a/README.md b/README.md index bcc6c30..574b757 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ export SMTP_FROM=server@email.com export SECRET_KEY=atLeast50RandomChars ################## Optional settings for storing files on S3 ################### + export DEFAULT_FILE_STORAGE=storages.backends.s3boto3.S3Boto3Storage export AWS_STORAGE_BUCKET_NAME=mybucket export AWS_ACCESS_KEY_ID=ABC.... @@ -122,6 +123,13 @@ export AWS_DEFAULT_ACL=public-read # files in the bucket are publicly readable. For example, via # AWS_DEFAULT_ACL=public-read. export AWS_S3_CUSTOM_DOMAIN=cdn.winget.pro -# To use a non-AWS S3 endpoint, you can optionally set the following: +# To use a non-AWS S3 endpoint such as Linode, you can optionally set: export AWS_S3_HOST=us-east-1.linodeobjects.com + +######### Optional settings for using a pre-generated SSL certificate ########## + +# The full certificate chain with multiple BEGIN / END CERTIFICATE blocks: +export SSL_CERTIFICATE="-----BEGIN CERTIFICATE-----\n..." +# The certificate private key. +export SSL_CERTIFICATE_KEY="-----BEGIN PRIVATE KEY-----\n..." ``` \ No newline at end of file diff --git a/install.sh b/install.sh index 92f62d2..8d1eea7 100644 --- a/install.sh +++ b/install.sh @@ -160,12 +160,25 @@ rm /etc/nginx/sites-enabled/default log 'Starting Nginx...' service nginx restart -log 'Generating SSL certificates...' -apt-get install certbot python3-certbot-nginx -y > /dev/null -certbot register --quiet --email $ADMIN_EMAIL --agree-tos -# `eval` is necessary to pass "-d" "my.com" instead of "-d my.com". -# The ${...:+ ...} constructs "-d a.com -d b.com" if $ALT_HOST_NAMES is set. -eval "certbot certonly --nginx --quiet --cert-name main -d $HOST_NAME${ALT_HOST_NAMES:+ -d ${ALT_HOST_NAMES// / -d }}" +if [[ -z "$SSL_CERTIFICATE" ]] +then + log 'Generating SSL certificates...' + apt-get install certbot python3-certbot-nginx -y > /dev/null + certbot register --quiet --email $ADMIN_EMAIL --agree-tos + # `eval` is necessary to pass "-d" "my.com" instead of "-d my.com". + # The ${...:+ ...} constructs "-d a.com -d b.com" if $ALT_HOST_NAMES is set. + eval "certbot certonly --nginx --quiet --cert-name main -d $HOST_NAME${ALT_HOST_NAMES:+ -d ${ALT_HOST_NAMES// / -d }}" +else + log 'Using provided SSL certificate...' + mkdir -p /etc/letsencrypt/live/main + chmod 700 /etc/letsencrypt/live + echo "$SSL_CERTIFICATE" > /etc/letsencrypt/live/main/fullchain.pem + chmod 644 /etc/letsencrypt/live/main/fullchain.pem + echo "$SSL_CERTIFICATE_KEY" > /etc/letsencrypt/live/main/privkey.pem + chmod 600 /etc/letsencrypt/live/main/privkey.pem +fi + +log 'Applying SSL config...' ln -sf /srv/conf/nginx/ssl /etc/nginx/includes/ssl service nginx restart