Skip to content

Commit

Permalink
use letsencrypt certificate for ncp-web
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Aug 10, 2017
1 parent 182c41a commit e0d9aea
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions etc/nextcloudpi-config.d/letsencrypt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
DOMAIN_=mycloud.ownyourbits.com
[email protected]
NCDIR_=/var/www/nextcloud
VHOSTCFG_=/etc/apache2/sites-available/nextcloud.conf
VHOSTCFG=/etc/apache2/sites-available/nextcloud.conf
VHOSTCFG2=/etc/apache2/sites-available/ncp.conf
DESCRIPTION="Automatic signed SSL certificates"

install()
Expand All @@ -42,12 +43,15 @@ Your certificate will be automatically renewed every month
# tested with git version v0.11.0-71-g018a304
configure()
{
grep -q ServerName $VHOSTCFG_ && \
sed -i "s|ServerName .*|ServerName $DOMAIN_|" $VHOSTCFG_ || \
sed -i "/DocumentRoot/aServerName $DOMAIN_" $VHOSTCFG_
grep -q ServerName $VHOSTCFG && \
sed -i "s|ServerName .*|ServerName $DOMAIN_|" $VHOSTCFG || \
sed -i "/DocumentRoot/aServerName $DOMAIN_" $VHOSTCFG

sed -i "s|SSLCertificateFile.*|SSLCertificateFile /etc/letsencrypt/live/$DOMAIN_/fullchain.pem|" $VHOSTCFG_
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile /etc/letsencrypt/live/$DOMAIN_/privkey.pem|" $VHOSTCFG_
sed -i "s|SSLCertificateFile.*|SSLCertificateFile /etc/letsencrypt/live/$DOMAIN_/fullchain.pem|" $VHOSTCFG
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile /etc/letsencrypt/live/$DOMAIN_/privkey.pem|" $VHOSTCFG

sed -i "s|SSLCertificateFile.*|SSLCertificateFile /etc/letsencrypt/live/$DOMAIN_/fullchain.pem|" $VHOSTCFG2
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile /etc/letsencrypt/live/$DOMAIN_/privkey.pem|" $VHOSTCFG2

/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
Expand Down

0 comments on commit e0d9aea

Please sign in to comment.