diff --git a/ctimer.php b/ctimer.php index ea86a84..76ee7cf 100755 --- a/ctimer.php +++ b/ctimer.php @@ -10,6 +10,7 @@ * v.1.5.1 * - error message if json_decode fails * - tweaks to ctimer_remote (use builtin, /usr/bin/env and do not trust path) + * - output time with seconds * v.1.5 * - Bootstrap 4.5.2 * - host in json @@ -319,7 +320,7 @@ function generate_ctimes_html( $file_ctimes_grouped ) { foreach ( $files as $file ) { - $file_date = date( "Y-m-d H:i", $file['ctime'] ); + $file_date = date( "Y-m-d H:i:s", $file['ctime'] ); $fragment .= $file_date . ' - ' . ltrim( $file['name'], './' ) . '' . PHP_EOL; if ( empty( $fragment_date ) || $file_date < $fragment_date ) { diff --git a/ctimer_fetch b/ctimer_fetch index 7fde710..891adaf 100755 --- a/ctimer_fetch +++ b/ctimer_fetch @@ -1,6 +1,6 @@ #!/bin/bash # Fetch files specified by path from remote site -# set -x +#set -x if [ ! -f "$1" ] || [ ! -f "$1" ]; then echo "Please provide host-named file with list of paths (or directory with such fiels) to rsync as command line argument." @@ -8,21 +8,25 @@ if [ ! -f "$1" ] || [ ! -f "$1" ]; then fi host=$(basename $1) -dir="./${host}_files_$(date +%Y-%m-%d)" +dir="./${host}_files_$(date +%Y-%m-%d_%H-%M)" mkdir -p "${dir}/tree/" -rm -f "${dir}/_paths.txt" +mkdir -p "${dir}/_meta/" +rm -f "${dir}/_meta/paths.txt" rsync -azh --files-from="$1" "${host}":/ "${dir}/tree/" function safecp() { - idx=2 # set the copy index to 0 - dfn=${file##*/} # destination file name (dfn) w/path stripped - while [ -f "${dir}/${dfn}" ]; do # test if $dfn exist in output_dir - dfn=${file##*/}_$((idx++)) # if so, add copy index "_#" (increment until unique) + idx=1 # set the copy index to 1 + fn="${file##*/}" # destination file name (dfn) w/path stripped + dfn="$fn" + + while [ -f "${dir}/${dfn}" ]; do # test if $dfn exist in output_dir + dfn="${fn%.*}_$((idx++)).${fn##*.}" # if so, add copy index "_#" before extenison (increment until unique) done + cp "$file" "${dir}/${dfn}" - echo "${dfn} - ${file}" >> "${dir}/_paths.txt" + echo "${dfn} - ${file}" >> "${dir}/_meta/paths.txt" } while read -d '' file; do @@ -30,3 +34,5 @@ while read -d '' file; do done < <(find "${dir}/tree/" -type f -print0) rm -rf "${dir}/tree/" + +mv "$1" "${dir}"/_meta/"$host"