2
0

Minor improvements

* 110-startlogs.sh no longer repeats existing log lines.
* Added a missing ACL suggestion in nginx_xport.inc
This commit is contained in:
Kovács Zoltán 2025-03-31 12:05:01 +02:00
parent 7ab0d50abf
commit 449a5012a9
3 changed files with 18 additions and 4 deletions

BIN
.metadata

Binary file not shown.

View File

@ -4,6 +4,7 @@
# Needs
# setfacl -m u:www-data:r [...]/configs/xport_backup
# setfacl -m u:www-data:rx [...]/storage/backups
# setfacl -m u:www-data:rx [...]/storage/backups/export
# setfacl -d -m u:www-data:r [...]/storage/backups/export
# ACLs.
location /export {

View File

@ -6,7 +6,9 @@
# Author: Kovács Zoltán <kovacsz@marcusconsulting.hu>
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
#
# 2025-02-26 v0.1
# 2025-03-29 v0.3
# mod: no longer repeats existing log lines.
# 2025-02-26 v0.2
# fix: a silly typo (commandtring) blocked the startup.
# 2025-02-02 v0.1 Initial release
@ -27,7 +29,7 @@ MSG_MISSINGYML="Fatal: didn't find the docker-compose.yml file"
# Checks the dependencies.
TR=$(which tr 2>/dev/null)
if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi
for item in cut dirname docker grep ps readlink
for item in cut date dirname docker grep ps readlink tail
do
if [ -n "$(which $item)" ]
then export $(echo $item | "$TR" '[:lower:]' '[:upper:]' | "$TR" '-' '_')=$(which $item)
@ -93,9 +95,20 @@ else
if [ -n "$service" ]; then
# Converts the service's name to an actual running container's name.
container="$("$DOCKER" inspect -f '{{.Name}}' $(cd "$BASE_DIR"; "$DOCKER_COMPOSE" $commandstring ps -q "$service") | "$CUT" -c2-)"
# It will not start a new log if it already exists.
# It will not start the log process if it already exists.
if [ -z "$("$PS" auxww | "$GREP" "$DOCKER" | "$GREP" 'logs' | "$GREP" "$container" )" ]; then
"$DOCKER" logs -t -f $container >> "$BASE_DIR/$LOGDIR/$service.log" 2>&1 &
# Determines the last existing log line in the log file (if any).
logline="$("$TAIL" -n1 "$BASE_DIR/$LOGDIR/$service.log" 2>/dev/null)"
# Gets the timestamp from this line.
[[ -n "$logline" ]] \
&& timestamp="$(echo "$logline" | "$CUT" -d' ' -f1 2>/dev/null)" \
|| timestamp="invalid"
# Checks the validity.
[[ $("$DATE" -d "$timestamp" >/dev/null 2>&1; echo $?) -eq 0 ]] \
&& since="$timestamp" \
|| since="1970-01-01T00:00Z"
# Only logs the new lines (actually repeats the last one - TODO!).
"$DOCKER" logs -t --since "$since" -f $container >> "$BASE_DIR/$LOGDIR/$service.log" 2>&1 &
fi
fi
done