diff --git a/renew_cert.sh b/renew_cert.sh index 042b83e..52d3f51 100755 --- a/renew_cert.sh +++ b/renew_cert.sh @@ -5,10 +5,10 @@ path="$( cd "$(dirname "$0")" ; pwd -P )" ############# # variables acme_dir=/srv/certs/acme-challenge/.well-known/acme-challenge -opt_folder=$path/opt -account_key=$opt_folder/account.key -acme_tiny=$opt_folder/acme_tiny.py -openssl_conf=$opt_folder/openssl.conf +opt_dir=/srv/certs/.opt +account_key=$opt_dir/account.key +acme_tiny=$opt_dir/acme_tiny.py +openssl_conf=$opt_dir/openssl.conf ############# # script @@ -21,6 +21,11 @@ if [ $# -eq 0 ]; then exit 1 fi +if [ ! -d "$opt_dir" ]; then + echo "opt dir doesn't exists!" + exit 1 +fi + if [ ! -d "$acme_dir" ]; then echo "acme directory ($acme_dir) doesn't exists!" exit 1 @@ -32,12 +37,13 @@ if [ ! -f "$account_key" ]; then fi if [ ! -f "$acme_tiny" ]; then - echo "Python script acme_tiny.py is missing" + echo "Python script acme_tiny.py is missing. Downloading..." + wget -qo $acme_tiny https://raw.githubusercontent.com/diafygi/acme-tiny/4.0.3/acme_tiny.py exit 1 fi acme_dir=${acme_dir%/} -opt_folder=${opt_folder%/} +opt_dir=${opt_dir%/} # check if python is installed command -v python >/dev/null 2>&1 || { echo >&2 "I require python but it's not installed. Aborting."; exit 1; }