Last active
April 23, 2016 13:59
-
-
Save lmas/119b964326e9ec244e7f691b66fcfb09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
EMAIL="[email protected]" | |
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