Skip to content

Instantly share code, notes, and snippets.

@tangx
Last active Nov 6, 2020
Embed
What would you like to do?
lego-letsencrypt.sh
#!/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="your@email.com"
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