_err "No host, user and pass found.. If this is the first time deploying please set PANOS_HOST, PANOS_USER and PANOS_PASS in environment variables. Delete them after you have succesfully deployed certs."
return1
# Environment Checks
# PANOS_HOST
if["$PANOS_HOST"];then
_debug "Detected ENV variable PANOS_HOST. Saving to file."
_savedeployconf PANOS_HOST "$PANOS_HOST"1
else
else
_debug "Using saved env variables."
_debug "Attempting to load variable PANOS_HOST from file."
_getdeployconf PANOS_HOST
fi
fi
else
_debug "Detected ENV variables to be saved to the deploy conf."
# Encrypt and save user
# PANOS USER
if["$PANOS_USER"];then
_debug "Detected ENV variable PANOS_USER. Saving to file."
_savedeployconf PANOS_USER "$PANOS_USER"1
_savedeployconf PANOS_USER "$PANOS_USER"1
else
_debug "Attempting to load variable PANOS_USER from file."
_getdeployconf PANOS_USER
fi
# PANOS_KEY
if["$PANOS_PASS"];then
_debug "Detected ENV variable PANOS_PASS. Saving to file."
_savedeployconf PANOS_PASS "$PANOS_PASS"1
_savedeployconf PANOS_PASS "$PANOS_PASS"1
_savedeployconf PANOS_HOST "$PANOS_HOST"1
_panos_user="$PANOS_USER"
_panos_pass="$PANOS_PASS"
_panos_host="$PANOS_HOST"
else
_debug "Attempting to load variable PANOS_PASS from file."
_getdeployconf PANOS_PASS
fi
# PANOS_KEY
if["$PANOS_KEY"];then
if["$PANOS_KEY"];then
_debug "Detected ENV variable PANOS_KEY. Saving to file."
_savedeployconf PANOS_KEY "$PANOS_KEY"1
_savedeployconf PANOS_KEY "$PANOS_KEY"1
_panos_key="$PANOS_KEY"
else
else
_debug "Attempting to load variable PANOS_KEY from file."
_getdeployconf PANOS_KEY
_getdeployconf PANOS_KEY
_panos_key=$PANOS_KEY
fi
fi
#Store variables
_panos_host=$PANOS_HOST
_panos_key=$PANOS_KEY
_panos_user=$PANOS_USER
_panos_pass=$PANOS_PASS
#Test API Key if found. If the key is invalid, the variable panos_key will be unset.
if["$_panos_host"]&&["$_panos_key"];then
_debug "**** Testing API KEY ****"
deployer keytest
fi
fi
_debug "Let's use username and pass to generate token."
_err "No user and pass OR valid API key found.. If this is the first time deploying please set PANOS_USER and PANOS_PASS -- AND/OR -- PANOS_KEY in environment variables. Delete them after you have succesfully deployed certs."
return1
return1
else
else
#Test API Key
if["$_panos_key"];then
_debug "**** Testing Saved API KEY ****"
deployer testkey
fi
# Generate a new API key if no valid key exists
# Generate a new API key if no valid API key is found
if[ -z "$_panos_key"];then
if[ -z "$_panos_key"];then
_debug "**** Generating new PANOS API KEY ****"
_debug "**** Generating new PANOS API KEY ****"
deployer keygen
deployer keygen
@ -172,7 +208,7 @@ panos_deploy() {
# Confirm that a valid key was generated
# Confirm that a valid key was generated
if[ -z "$_panos_key"];then
if[ -z "$_panos_key"];then
_err "Missing apikey."
_err "Unable to generate an API key. The user and pass may be invalid or not authorized to generate a new key. Please check the credentials and try again"