#!/bin/bash domains=$1 lxc-attach -n c_proxy -- /etc/init.d/nginx stop for i in `echo $domains | tr ";" " "`; do lxc-attach -n c_proxy -- [ -d /etc/letsencrypt/live/$i/ ] && lxc-attach -n c_proxy -- rm -R /etc/letsencrypt/live/$i/ lxc-attach -n c_proxy -- [ -d /etc/letsencrypt/archive/$i/ ] && lxc-attach -n c_proxy -- rm -R /etc/letsencrypt/archive/$i/ done lxc-attach -n c_proxy -- /opt/letsencrypt/letsencrypt-auto certonly -d $domains --standalone lxc-attach -n c_proxy -- /etc/init.d/nginx start for i in `echo $domains | tr ";" " "`; do mkdir -p ./ssl_certs/$i for j in privkey.pem fullchain.pem chain.pem cert.pem; do lxc-attach -n c_proxy -- cat /etc/letsencrypt/live/$i/$j > ./ssl_certs/$i/$j done done