From: Jacob Bachmeyer Date: Sun, 2 Apr 2023 01:03:32 +0000 (-0500) Subject: Expand FTP index builder tool X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3edf62e16d2f8a35db2bbbe70c27a33d8d4e424a;p=gatekeeper.git Expand FTP index builder tool --- diff --git a/make-ftpindex.sh b/make-ftpindex.sh old mode 100644 new mode 100755 index 58cd618..5771285 --- a/make-ftpindex.sh +++ b/make-ftpindex.sh @@ -1,4 +1,13 @@ #!/bin/sh +# shellcheck disable=SC2006,SC2268 + +Version_Notice=' +make-ftpindex (GNU Secure Software Gatekeeper) 0.2-pre +Copyright (C) 2023 Jacob Bachmeyer. +License GPLv3+: GNU GPL version 3 or later +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. +' # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,7 +22,87 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -ls -lrRt /home/ftp | gzip -9 -c > /home/ftp/ls-lrRt.txt.gz -cd /home/ftp -find . | gzip -9 -c > /home/ftp/find.txt.gz -tree -aJsD --timefmt %s | gzip -9 -c > /home/ftp/tree.json.gz +version () { echo "$Version_Notice" | awk '/^$/ { next } + $1 == "Copyright" { out = $1 OFS $2 } + out && $NF ~ /[[:digit:]]/ { yr = $NF } + out && $NF !~ /[[:digit:]]/ { + for (i = NF; i>0 && $i !~ /[[:digit:]]/; i--) ; + if ($i ~ /[[:digit:]]/) yr = $i; i++ + sub(/^[[:digit:]]+-/, "", yr) + for (out = out OFS yr; i<=NF; i++) out = out OFS $i + print out; out = ""; next + } + !out { print }' + exit 0 +} + +usage () { + echo usage: "$0" ' []' +} + +help () { + usage + cat < "${StageDir}"/find.txt.gz +tree -aJsD --timefmt %s | gzip -9 -c > "${StageDir}"/tree.json.gz +cd .. || error cannot move to parent of "'$PublicDir'" +# shellcheck disable=SC2012 # for obvious reasons... +ls -lrRt "$(basename "$PublicDir")" | gzip -9 -c > "${StageDir}"/ls-lrRt.txt.gz + +if $DryRun; then exit 0; fi + +mv -f "${StageDir}"/ls-lrRt.txt.gz \ + "${StageDir}"/find.txt.gz \ + "${StageDir}"/tree.json.gz \ + "${PublicDir}" + +# EOF