Skip to content

Instantly share code, notes, and snippets.

@lmas
Last active April 23, 2016 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmas/119b964326e9ec244e7f691b66fcfb09 to your computer and use it in GitHub Desktop.
Save lmas/119b964326e9ec244e7f691b66fcfb09 to your computer and use it in GitHub Desktop.
#!/bin/bash
EMAIL="your@email.com"
LEGOROOT="/path/to/lego"
function renew {
domain="$1"
path="$2"
$LEGOROOT/lego --key-type rsa4096 --accept-tos --path "$LEGOROOT/.lego" --email "$EMAIL" \
--webroot "$path" --domains "$domain" --domains "www.$domain" \
renew 1>> "$LEGOROOT/renew.log" 2>&1
ret=$?
if [ $ret -eq 0 ]; then
cp "$LEGOROOT/.lego/certificates/$domain.crt" /etc/nginx/ssl/lego/
chown root:root "/etc/nginx/ssl/lego/$domain.crt"
cp "$LEGOROOT/.lego/certificates/$domain.key" /etc/nginx/ssl/lego/
chown root:root "/etc/nginx/ssl/lego/$domain.key"
echo -e "$domain was renewed.\n" >> "$LEGOROOT/renew.log"
else
echo -e "$domain failed to renew!\n" >> "$LEGOROOT/renew.log"
fi
}
renew www.domain.1" "/path/to/static1"
renew "www.domain.2" "/path/to/static2"
service nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment