Skip to content

Commit

Permalink
letsencrypt without restarting apache
Browse files Browse the repository at this point in the history
  • Loading branch information
nacho committed Aug 10, 2017
1 parent beb9bc1 commit 4cdf14e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions etc/nextcloudpi-config.d/letsencrypt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

DOMAIN_=mycloud.ownyourbits.com
EMAIL_=mycloud@ownyourbits.com
NCDIR_=/var/www/nextcloud
VHOSTCFG_=/etc/apache2/sites-available/nextcloud.conf
DESCRIPTION="Automatic signed SSL certificates"

Expand All @@ -32,7 +33,7 @@ show_info()
--backtitle "NextCloudPi configuration" \
--title "Warning" \
"Internet access is required for this configuration to complete
Your certificate will be automatically renewed every month
" \
20 90
Expand All @@ -45,13 +46,17 @@ configure()
sed -i "s|ServerName .*|ServerName $DOMAIN_|" $VHOSTCFG_ || \
sed -i "/DocumentRoot/aServerName $DOMAIN_" $VHOSTCFG_

/etc/letsencrypt/letsencrypt-auto -n --no-self-upgrade --apache --hsts --agree-tos -m $EMAIL_ -d $DOMAIN_ || return 1
sed -i "s|SSLCertificateFile.*|SSLCertificateFile /etc/letsencrypt/live/$DOMAIN_/fullchain.pem|" $VHOSTCFG_
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile /etc/letsencrypt/live/$DOMAIN_/privkey.pem|" $VHOSTCFG_

/etc/letsencrypt/letsencrypt-auto certonly -n --no-self-upgrade --webroot -w $NCDIR_ --hsts --agree-tos -m $EMAIL_ -d $DOMAIN_ || return 1
echo "* 1 * * 1 root /etc/letsencrypt/certbot-auto renew --quiet" > /etc/cron.d/letsencrypt-ncp

cd /var/www/nextcloud
sudo -u www-data php occ config:system:set trusted_domains 4 --value=$DOMAIN_

service apache2 reload
# delayed in bg so it does not kill the connection, and we get AJAX response
( sleep 2 && systemctl restart apache2 ) &>/dev/null &
}

cleanup()
Expand Down

0 comments on commit 4cdf14e

Please sign in to comment.