Last active
November 6, 2020 16:41
-
-
Save tangx/c1eb22faf2f0f72c31d4a40e3694ed25 to your computer and use it in GitHub Desktop.
lego-letsencrypt.sh
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 | |
# | |
# lego-letsencrypt.sh | |
# | |
cd $(dirname $0) | |
which lego || { | |
lego_ver=v3.7.0 | |
wget -c https://github.com/go-acme/lego/releases/download/${lego_ver}/lego_${lego_ver}_linux_amd64.tar.gz -o lego.tar.gz | |
tar xf lego.tar.gz | |
cp -a lego /usr/local/bin/lego | |
} | |
DomainList="*.example.com,*.example.org" | |
EMAIL="[email protected]" | |
export ALICLOUD_ACCESS_KEY=LTAxxxxxx | |
export ALICLOUD_SECRET_KEY=yyyyyyyyyyyyyyyyy | |
Domains="" | |
for domain in ${DOMAINs//,/ }; do | |
{ | |
Domains="${Domains} --domain=${domain}" | |
} | |
done | |
function run() { | |
lego --email="${EMAIL}" \ | |
${Domains} \ | |
--path=$(pwd) --dns alidns --accept-tos run | |
} | |
function renew() { | |
lego --email="${EMAIL}" \ | |
${Domains} \ | |
--path=$(pwd) --dns alidns --accept-tos renew | |
} | |
function _usage() { | |
echo "$0 run|renew" | |
exit 1 | |
} | |
case $1 in | |
run | renew) $1 ;; | |
*) _usage ;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment