From: Chris Koeritz Date: Tue, 12 Mar 2013 23:36:57 +0000 (-0400) Subject: fixing name of log dumping script. X-Git-Tag: 2.140.90~1055 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=1e8d6831eac21cf77a976e6e851ec6201c8992bb;p=feisty_meow.git fixing name of log dumping script. --- diff --git a/scripts/system/dump_log.sh b/scripts/system/dump_log.sh new file mode 100644 index 00000000..0311de8b --- /dev/null +++ b/scripts/system/dump_log.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# dumps out the log files according to the provided pattern, but makes sure that +# each one is dumped in chronological order, and any compressed logs are unpacked +# first. + +function assemble_log_file() +{ + logpath="$1"; shift + + # build an array of all the file names, in reverse order since we want the oldest + # files listed first. + full_set=($(ls -1 -r "$logpath"*)) + if [ ${#full_set[*]} -lt 1 ]; then + echo "No log files were found matching the pattern '$full_set'" + exit 1 + fi + + logdump="$(mktemp /tmp/$USER_logdump.XXXXXX)" + + for logy in ${full_set[*]}; do +#echo logy is $logy + if [[ $logy =~ .*\.gz ]]; then + gzip -d -c "$logy" >>"$logdump" + else + cat "$logy" >>"$logdump" + fi + done + + cat "$logdump" + \rm -f "$logdump" +} + + +############## + +logpath="$1"; shift + +if [ -z "$logpath" ]; then + echo "$(basename $0 .sh): Log file dumper" + echo + echo "This script requires a log path, which should be the prefix of some log files" + echo "that it will dump out. All files matching the prefix are printed to standard" + echo "output, and the log entries will be printed in chronological order. Any" + echo "compressed log files will be unpacked first before printing." + echo + echo "Example:" + echo -e "\t$(basename $0 .sh) /var/log/syslog" + echo + exit 1 +fi + +assemble_log_file "$logpath" + + diff --git a/scripts/system/dump_logs.sh b/scripts/system/dump_logs.sh deleted file mode 100644 index 0311de8b..00000000 --- a/scripts/system/dump_logs.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -# dumps out the log files according to the provided pattern, but makes sure that -# each one is dumped in chronological order, and any compressed logs are unpacked -# first. - -function assemble_log_file() -{ - logpath="$1"; shift - - # build an array of all the file names, in reverse order since we want the oldest - # files listed first. - full_set=($(ls -1 -r "$logpath"*)) - if [ ${#full_set[*]} -lt 1 ]; then - echo "No log files were found matching the pattern '$full_set'" - exit 1 - fi - - logdump="$(mktemp /tmp/$USER_logdump.XXXXXX)" - - for logy in ${full_set[*]}; do -#echo logy is $logy - if [[ $logy =~ .*\.gz ]]; then - gzip -d -c "$logy" >>"$logdump" - else - cat "$logy" >>"$logdump" - fi - done - - cat "$logdump" - \rm -f "$logdump" -} - - -############## - -logpath="$1"; shift - -if [ -z "$logpath" ]; then - echo "$(basename $0 .sh): Log file dumper" - echo - echo "This script requires a log path, which should be the prefix of some log files" - echo "that it will dump out. All files matching the prefix are printed to standard" - echo "output, and the log entries will be printed in chronological order. Any" - echo "compressed log files will be unpacked first before printing." - echo - echo "Example:" - echo -e "\t$(basename $0 .sh) /var/log/syslog" - echo - exit 1 -fi - -assemble_log_file "$logpath" - -