Skip to content

Commit

Permalink
Preserve values of exported global vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Scavo committed Jan 1, 2017
1 parent 165495e commit 7de80e9
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions lib/config_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,22 @@ create_config () {
/bin/cat <<- DEFAULT_CONFIG_FILE > $config_file
#!/bin/bash
# MDQ base URL
MDQ_BASE_URL=http://mdq-beta.incommon.org/global
# default MDQ base URL
[ -z "\$MDQ_BASE_URL" ] && MDQ_BASE_URL=http://mdq-beta.incommon.org/global
# basic curl defaults
CONNECT_TIMEOUT_DEFAULT=2
MAX_REDIRS_DEFAULT=3
[ -z "\$CONNECT_TIMEOUT_DEFAULT" ] && CONNECT_TIMEOUT_DEFAULT=2
[ -z "\$MAX_REDIRS_DEFAULT" ] && MAX_REDIRS_DEFAULT=3
# default SAML2 endpoint for testing
SAML2_SP_ENTITY_ID=https://service1.internet2.edu/shibboleth
SAML2_SP_ACS_URL=https://service1.internet2.edu/Shibboleth.sso/SAML2/POST
SAML2_SP_ACS_BINDING=urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST
[ -z "\$SAML2_SP_ENTITY_ID" ] && SAML2_SP_ENTITY_ID=https://service1.internet2.edu/shibboleth
[ -z "\$SAML2_SP_ACS_URL" ] && SAML2_SP_ACS_URL=https://service1.internet2.edu/Shibboleth.sso/SAML2/POST
[ -z "\$SAML2_SP_ACS_BINDING" ] && SAML2_SP_ACS_BINDING=urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST
# default SAML1 endpoint for testing
SAML1_SP_ENTITY_ID=https://service1.internet2.edu/shibboleth
SAML1_SP_ACS_URL=https://service1.internet2.edu/Shibboleth.sso/SAML/POST
SAML1_SP_ACS_BINDING=urn:oasis:names:tc:SAML:1.0:profiles:browser-post
[ -z "\$SAML1_SP_ENTITY_ID" ] && SAML1_SP_ENTITY_ID=https://service1.internet2.edu/shibboleth
[ -z "\$SAML1_SP_ACS_URL" ] && SAML1_SP_ACS_URL=https://service1.internet2.edu/Shibboleth.sso/SAML/POST
[ -z "\$SAML1_SP_ACS_BINDING" ] && SAML1_SP_ACS_BINDING=urn:oasis:names:tc:SAML:1.0:profiles:browser-post
DEFAULT_CONFIG_FILE

$verbose_mode && echo "$FUNCNAME created default config file $config_file"
Expand Down Expand Up @@ -132,8 +132,10 @@ load_config () {
config_file="$1"

# create config file if necessary
if [ ! -f "$config_file" ]; then
$verbose_mode && echo "$FUNCNAME creating default config file $config_file"
if [ -f "$config_file" ]; then
$verbose_mode && echo "$FUNCNAME using config file $config_file"
else
$verbose_mode && echo "$FUNCNAME creating config file $config_file"
create_config $local_opts $config_file
status_code=$?
if [ $status_code -ne 0 ]; then
Expand All @@ -151,6 +153,15 @@ load_config () {
return $status_code
fi

# validate config file
$verbose_mode && echo "$FUNCNAME validating config file $config_file"
validate_config $local_opts
status_code=$?
if [ $status_code -ne 0 ]; then
echo "ERROR: $FUNCNAME failed to verify config file $config_file" >&2
return $status_code
fi

return 0
}

Expand Down

0 comments on commit 7de80e9

Please sign in to comment.