Skip to content

Instantly share code, notes, and snippets.

@yu81
Last active May 17, 2016 10:46
Show Gist options
  • Save yu81/5f8fa31a8e2e581a48ce5ce7434f8e51 to your computer and use it in GitHub Desktop.
Save yu81/5f8fa31a8e2e581a48ce5ce7434f8e51 to your computer and use it in GitHub Desktop.
Semi-automation script of Let's Encrypt. https://letsencrypt.org/
#!/bin/bash -xv
letsencrypt_path=$1
if [ ! -e ${letsencrypt_path}/certbot-auto ]; then
pushd ~/
git clone https://github.com/letsencrypt/letsencrypt && [ ! -e ${letsencrypt_path}/certbot-auto ] && exit 1
popd
fi
domain_name=$2
[ ${domain_name:-_} = "_" ] && exit 1
python_version=$(python --version 2>&1 | egrep -o "[0-9\.]+" )
pyenv_local_changed="false"
if [ "${python_version:0:1}" != 2 ]; then
pyenv install 2.7.11
pyenv local 2.7.11
pyenv_local_changed="true"
fi
function error_exit {
if [ "${pyenv_local_changed}" = "true" ]; then
rm .python_version
fi
exit 1
}
# ${letsencrypt_path}/letsencrypt-auto certonly -a standalone -d ${domain_name}
${letsencrypt_path}/certbot-auto certonly -a standalone -d ${domain_name}
[ $? != 0 ] && error_exit
sudo cp -p /etc/letsencrypt/live/${domain_name}/fullchain.pem ~/${domain_name/./_}_fullchain.pem
[ $? != 0 ] && error_exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment