-
-
Save artmouse/db68c306ae6eaabaf671 to your computer and use it in GitHub Desktop.
Auto refresh LetsEncrypt cert for NGINX
This file contains hidden or 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 | |
| echo "Running as user $USER" | |
| DIR=/home/letsencrypt/letsencrypt | |
| DOMAIN=mydomain.com | |
| $DIR/letsencrypt-auto -a webroot --webroot-path /home/letsencrypt/webroot/ \ | |
| --config-dir /home/letsencrypt/etc \ | |
| --logs-dir /home/letsencrypt/log \ | |
| --work-dir /home/letsencrypt/lib \ | |
| --agree-dev-preview \ | |
| --renew-by-default \ | |
| --server https://acme-v01.api.letsencrypt.org/directory \ | |
| -d "www.$DOMAIN" -d "$DOMAIN" certonly |
This file contains hidden or 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
| #Copy this file into /etc/cron.d | |
| SHELL=/bin/sh | |
| PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
| # m h dom mon dow user command | |
| @monthly /home/letsencrypt/letsencrypt-nginx |
This file contains hidden or 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 | |
| DIR=/home/letsencrypt | |
| SCRIPT=letsencrypt-cert | |
| USERNAME=letsencrypt | |
| pushd $DIR | |
| if [[ $USER != $USERNAME ]]; then | |
| sudo -H -u $USERNAME ./$SCRIPT | |
| else | |
| ./$SCRIPT | |
| fi | |
| popd | |
| if [ $? -eq 0 ]; then | |
| service nginx reload | |
| echo OK | |
| else | |
| echo FAIL | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment