diff --git a/.metadata b/.metadata index 48dffc2..90dc165 100644 Binary files a/.metadata and b/.metadata differ diff --git a/.templates/nginx/nginx_xport.inc b/.templates/nginx/nginx_xport.inc index 66362d6..b460c2d 100644 --- a/.templates/nginx/nginx_xport.inc +++ b/.templates/nginx/nginx_xport.inc @@ -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 { diff --git a/tools/startup.d/110-startlogs.sh b/tools/startup.d/110-startlogs.sh index 7067e63..1a696ad 100755 --- a/tools/startup.d/110-startlogs.sh +++ b/tools/startup.d/110-startlogs.sh @@ -6,7 +6,9 @@ # Author: Kovács Zoltán # 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