From 281aa3497ffa411da718878ad64b4273bb88aea0 Mon Sep 17 00:00:00 2001 From: neil Date: Tue, 5 Apr 2016 21:08:19 +0800 Subject: [PATCH] Save user's PATH for cron job. --- le.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/le.sh b/le.sh index f0626fc0..d6de4b7e 100755 --- a/le.sh +++ b/le.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VER=1.2.1 +VER=1.2.2 PROJECT="https://github.com/Neilpang/le" DEFAULT_CA="https://acme-v01.api.letsencrypt.org" @@ -585,7 +585,7 @@ _saveaccountconf() { key="$1" value="$2" if [ "$ACCOUNT_CONF_PATH" ] ; then - _setopt $ACCOUNT_CONF_PATH "$key" "=" "$value" + _setopt $ACCOUNT_CONF_PATH "$key" "=" "\"$value\"" else _err "ACCOUNT_CONF_PATH is empty, can not save $key=$value" fi @@ -645,6 +645,13 @@ _initpath() { source "$ACCOUNT_CONF_PATH" fi + if [[ "$IN_CRON" ]] ; then + if [[ ! "$_USER_PATH_EXPORTED" ]] ; then + _USER_PATH_EXPORTED=1 + export PATH="$USER_PATH:$PATH" + fi + fi + if [ -z "$API" ] ; then if [ -z "$STAGE" ] ; then API="$DEFAULT_CA" @@ -1205,6 +1212,11 @@ issue() { _info "Your cert is in $CERT_PATH" cp "$CERT_PATH" "$CERT_FULLCHAIN_PATH" + + if [[ ! "$USER_PATH" ]] || [[ ! "$IN_CRON" ]] ; then + USER_PATH="$PATH" + _saveaccountconf "USER_PATH" "$USER_PATH" + fi fi @@ -1474,6 +1486,9 @@ _initconf() { #ACCOUNT_KEY_HASH=account key hash USER_AGENT=\"le.sh client: $PROJECT\" + +#USER_PATH="" + #dns api ####################### #Cloudflare: @@ -1605,7 +1620,9 @@ uninstall() { } cron() { + IN_CRON=1 renewAll + IN_CRON="" } version() {