4in1_tools/web/get-refs.sh
2024-07-25 02:58:08 +03:00

48 lines
1.0 KiB
Bash
Executable File

#!/usr/local/bin/bash
source ~/.local/my/bash/bashrc
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 [--web] [--files] [-h|--help]"
}
# Parse command-line arguments
while [ "$#" -gt 0 ]; do
case "$1" in
--web)
FULL_WEB=1
shift
;;
--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