#!/bin/bash
if [ ! -d /etc/letsencrypt/archive/HOSTNAME_TOKEN ]; then
+
+ # Nasty hack for getting port 443/80 if needed
+ /etc/init.d/nginx stop &> /dev/null
+ /etc/init.d/apache2 stop &> /dev/null
+
+ # Lets get us some SSL
cd /srv/letsencrypt
./letsencrypt-auto certonly --standalone --agree-tos --email LETSENCRYPT_EMAIL_TOKEN -d HOSTNAME_TOKEN -d SERVERNAME_TOKEN
+
+ # Nasty hack for putting thoes services back online, okay :)
+ /etc/init.d/nginx start &> /dev/null
+ /etc/init.d/apache2 start &> /dev/null
fi
server {
listen 80;
- server_name GMG_FQDN_TOKEN;
+ server_name SERVERNAME_TOKEN;
include /etc/nginx/mediagoblin-common.conf;
## redirect http to https ##
rewrite ^ https://$server_name$request_uri? permanent;
- access_log /var/log/nginx/GMG_FQDN_TOKEN-ssl.access.log;
- error_log /var/log/nginx/GMG_FQDN_TOKEN-ssl.error.log;
+ access_log /var/log/nginx/SERVERNAME_TOKEN-ssl.access.log;
+ error_log /var/log/nginx/SERVERNAME_TOKEN-ssl.error.log;
}
server {
include /etc/nginx/mediagoblin-common.conf;
- access_log /var/log/nginx/GMG_FQDN_TOKEN-ssl.access.log;
- error_log /var/log/nginx/GMG_FQDN_TOKEN-ssl.error.log;
+ access_log /var/log/nginx/SERVERNAME_TOKEN-ssl.access.log;
+ error_log /var/log/nginx/SERVERNAME_TOKEN-ssl.error.log;
ssl on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
- ssl_certificate /etc/letsencrypt/live/GMG_FQDN_TOKEN/fullchain.pem;
- ssl_certificate_key /etc/letsencrypt/live/GMG_FQDN_TOKEN/privkey.pem;
+ ssl_certificate /etc/letsencrypt/live/SERVERNAME_TOKEN/fullchain.pem;
+ ssl_certificate_key /etc/letsencrypt/live/SERVERNAME_TOKEN/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
sed 's^GMG_PATH_TOKEN^'$GMG_PATH'^g' -i $target/etc/nginx/mediagoblin-common.conf
sed 's^GMG_FQDN_TOKEN^'$fqdn'^g' -i $target/etc/nginx/sites-available/mediagoblin
+sed 's^SERVERNAME_TOKEN^'$fqdn'^g' -i $target/etc/nginx/sites-available/mediagoblin
# enable nginx config
$ROOTCMD ln -s /etc/nginx/sites-available/mediagoblin /etc/nginx/sites-enabled/mediagoblin