Skip to content

Commit

Permalink
Set default log level
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Scavo committed May 5, 2017
1 parent ca82239 commit 69387b8
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions bin/list_all_entities_exported.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,39 @@

display_help () {
/bin/cat <<- HELP_MSG
This script ...
This script produces two CSV files from the InCommon export
aggregate. It is intended to be run as a cron job.
Usage: ${0##*/} [-hvq] -d OUT_DIR
Usage: ${0##*/} [-hv] -d OUT_DIR
This script takes a single command-line argument...
This script requires numerous environment variables...
Options:
-h Display this help message
-v Enable DEBUG mode
-d Specify output directory
-d Specify the output directory
Option -h is mutually exclusive of all other options.
LIBRARY
Option -d specifies the ultimate output directory, which is
usually a web directory. This option is REQUIRED.
ENVIRONMENT
This script leverages numerous environment variables:
BIN_DIR A directory of executable scripts
LIB_DIR A source library directory
CACHE_DIR An HTTP cache
TMPDIR A temporary directory
LOG_FILE A persistent log file
LOG_LEVEL The global log level [0..5]
All of the above environment variables are REQUIRED
(except LOG_LEVEL, which defaults to LOG_LEVEL=3).
Environment variable LIB_DIR specifies a directory containing at
least the following library files...
EXAMPLES
out_dir=
${0##*/} \$out_dir
\$ out_dir=/home/htdocs/www.incommonfederation.org/federation/metadata/
\$ ${0##*/} -d \$out_dir
HELP_MSG
}

Expand Down Expand Up @@ -105,6 +114,11 @@ if [ ! -f "$LOG_FILE" ] && [[ $LOG_FILE != /dev/* ]]; then
exit 2
fi

# default to INFO logging
if [ -z "$LOG_LEVEL" ]; then
LOG_LEVEL=3
fi

#######################################################################
# Process command-line options and arguments
#######################################################################
Expand Down Expand Up @@ -215,7 +229,7 @@ print_log_message -D "$script_name using metadata file: $md_location"

# get a fresh metadata file
print_log_message -D "$script_name writing XML file: $xml_file"
$cget $local_opts -F $md_location > $xml_file 2> /dev/null
$cget $local_opts -F $md_location > $xml_file
exit_code=$?
if [ $exit_code -eq 1 ]; then
# short-circuit if 304 response
Expand All @@ -229,7 +243,7 @@ fi

# create the first output file
print_log_message -D "$script_name writing output file: $csv_file1"
/usr/bin/xsltproc $xsl_file1 $xml_file > $csv_file1 2> /dev/null
/usr/bin/xsltproc $xsl_file1 $xml_file > $csv_file1
exit_code=$?
if [ $exit_code -ne 0 ]; then
print_log_message -E "$script_name: xsltproc failed ($exit_code) on stylesheet: $xsl_file1"
Expand All @@ -238,7 +252,7 @@ fi

# create the second output file
print_log_message -D "$script_name writing output file: $csv_file2"
/usr/bin/xsltproc $xsl_file2 $xml_file > $csv_file2 2> /dev/null
/usr/bin/xsltproc $xsl_file2 $xml_file > $csv_file2
exit_code=$?
if [ $exit_code -ne 0 ]; then
print_log_message -E "$script_name: xsltproc failed ($exit_code) on stylesheet: $xsl_file2"
Expand All @@ -247,7 +261,7 @@ fi

# move the output files to the web directory
print_log_message -D "$script_name moving output files to dir: $out_dir"
/bin/mv $csv_file1 $csv_file2 $out_dir 2> /dev/null
/bin/mv $csv_file1 $csv_file2 $out_dir
exit_code=$?
if [ $exit_code -ne 0 ]; then
print_log_message -E "$script_name: mv failed ($exit_code) to dir: $out_dir"
Expand Down

0 comments on commit 69387b8

Please sign in to comment.