Skip to content

Instantly share code, notes, and snippets.

@tangx
Last active November 6, 2020 16:41
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 tangx/c1eb22faf2f0f72c31d4a40e3694ed25 to your computer and use it in GitHub Desktop.
Save tangx/c1eb22faf2f0f72c31d4a40e3694ed25 to your computer and use it in GitHub Desktop.
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