From 69387b8a125b22e4fdd3a764a0897207d4b726fc Mon Sep 17 00:00:00 2001 From: Tom Scavo Date: Fri, 5 May 2017 18:55:26 -0400 Subject: [PATCH] Set default log level --- bin/list_all_entities_exported.sh | 48 ++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/bin/list_all_entities_exported.sh b/bin/list_all_entities_exported.sh index f08ec83..05bee2a 100755 --- a/bin/list_all_entities_exported.sh +++ b/bin/list_all_entities_exported.sh @@ -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 } @@ -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 ####################################################################### @@ -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 @@ -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" @@ -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" @@ -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"