From 2ae50f439866009c7cb2e61bea09149a86e5eb6a Mon Sep 17 00:00:00 2001 From: Peter Marquardt Date: Tue, 28 Apr 2026 09:19:46 +0200 Subject: [PATCH] remove cronolog - remove cronolog ( use bash ) - fix typo --- syncthing/startstop-syncthing.sh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/syncthing/startstop-syncthing.sh b/syncthing/startstop-syncthing.sh index 76296b7..7d07060 100755 --- a/syncthing/startstop-syncthing.sh +++ b/syncthing/startstop-syncthing.sh @@ -5,7 +5,7 @@ set -eu HOST=$(uname -n); HOST=${HOST%%.*} if [ ! -e "${0}.conf" ]; then - echo "FAIL: ${0}.conf mnissing, creating stub" + echo "FAIL: ${0}.conf missing, creating stub" set -x install -m 755 <( cat <<_EOC_ # gui/synthing address @@ -29,7 +29,23 @@ cd ${STD} CMD=/usr/bin/syncthing -CRONOLOG="/usr/sbin/cronolog ${STD}/logs/syncthing-%Y-%m.log -S ${STD}/logs/syncthing.log" +log_rotate() { + local logdir=${STD}/logs + local prefix=$1 + local symlink="$logdir/${prefix}.log" + local current_log="" + + mkdir -p "$logdir" + + while IFS= read -r line; do + local logfile="$logdir/${prefix}-$(date +%Y-%m).log" + if [[ "$logfile" != "$current_log" ]]; then + current_log="$logfile" + ln -sf "$current_log" "$symlink" + fi + printf '%s\n' "$line" >> "$current_log" + done +} case "${1:-}" in start) @@ -41,7 +57,8 @@ case "${1:-}" in --no-upgrade \ --gui-address=${FQDN}:${PORT} \ --no-port-probing \ - 2>&1 |$CRONOLOG & + 2>&1 | log_rotate syncthing & + # echo $! > /dev/shm/$USER/syncthing.pid ;; restart) $CMD cli --home=${STD} \