get-refs: add --full-files and --full-web options

This commit is contained in:
E. S. 2024-01-08 07:29:00 +00:00
parent f9a91073bd
commit 5462ac4b94

View File

@ -1,9 +1,47 @@
#!/bin/bash
source ~/.local/my/bash/bashrc
files="4in1.ws_access.log files.4in1.ws_access.log"
for f in $files; do
echo "> $f"
my_ssh root@4in1 cat "/var/log/nginx/$f" | awk '{print $11}' | grep -v 4in1.ws | sed 's/"//g' | sort | uniq
WEBSITE_LOG_FILENAME="4in1.ws_access.log"
FILES_LOG_FILENAME="files.4in1.ws_access.log"
FULL_WEB=0
FULL_FILES=0
usage() {
echo "usage: $0 [--full-web] [--full-files] [-h|--help]"
}
# Parse command-line arguments
while [ "$#" -gt 0 ]; do
case "$1" in
--full-web)
FULL_WEB=1
shift
;;
--full-files)
FULL_FILES=1
shift
;;
-h|--help)
usage
exit 0
;;
*)
2>&1 echo "error: unknown option: $1"
usage
exit 1
;;
esac
done
# Execution branches
if [ "$FULL_WEB" = "1" ]; then
my_ssh root@4in1 cat "/var/log/nginx/$WEBSITE_LOG_FILENAME" | less
elif [ "$FULL_FILES" = "1" ]; then
my_ssh root@4in1 cat "/var/log/nginx/$FILES_LOG_FILENAME" | less
else
for f in $WEBSITE_LOG_FILENAME $FILES_LOG_FILENAME; do
echo "> $f"
my_ssh root@4in1 cat "/var/log/nginx/$f" | awk '{print $11}' | grep -v 4in1.ws | sed 's/"//g' | sort | uniq
done
fi