From 7e788687dd08d8c7f288ed3820df51e3c59be774 Mon Sep 17 00:00:00 2001 From: Alfonso Gamboa Date: Mon, 30 May 2022 23:13:20 -0700 Subject: [PATCH] store and rename logs upon reboot, do not delete --- SD_ROOT/wz_mini/etc/init.d/v3_init.sh | 13 +++++++++++-- SD_ROOT/wz_mini/etc/init.d/wz_cam.sh | 15 ++++++++++++++- SD_ROOT/wz_mini/etc/init.d/wz_post.sh | 12 +++++++++++- SD_ROOT/wz_mini/etc/init.d/wz_user.sh | 12 +++++++++++- SD_ROOT/wz_mini/usr/bin/watch_up.sh | 12 +++++++++++- 5 files changed, 58 insertions(+), 6 deletions(-) diff --git a/SD_ROOT/wz_mini/etc/init.d/v3_init.sh b/SD_ROOT/wz_mini/etc/init.d/v3_init.sh index f4c1aef..178e4d6 100755 --- a/SD_ROOT/wz_mini/etc/init.d/v3_init.sh +++ b/SD_ROOT/wz_mini/etc/init.d/v3_init.sh @@ -4,8 +4,17 @@ ### ###This file is run by switch_root, from the initramfs in the kernel. - -exec 1> /opt/wz_mini/log/v3_init.log 2>&1 +LOG_NAME=/opt/wz_mini/log/v3_init +if [[ -e $LOG_NAME.log || -L $LOG_NAME.log ]] ; then + i=0 + while [[ -e $LOG_NAME.log.$i || -L $LOG_NAME.log.$i ]] ; do + let i++ + done + mv $LOG_NAME.log $LOG_NAME.log.$i + LOG_NAME=$LOG_NAME +fi +touch -- "$LOG_NAME".log +exec 1> $LOG_NAME.log 2>&1 export WZMINI_CFG=/opt/wz_mini/wz_mini.conf diff --git a/SD_ROOT/wz_mini/etc/init.d/wz_cam.sh b/SD_ROOT/wz_mini/etc/init.d/wz_cam.sh index 5ce54ca..0a6b9d7 100755 --- a/SD_ROOT/wz_mini/etc/init.d/wz_cam.sh +++ b/SD_ROOT/wz_mini/etc/init.d/wz_cam.sh @@ -1,8 +1,21 @@ #!/bin/sh +LOG_NAME=/opt/wz_mini/log/wz_cam +if [[ -e $LOG_NAME.log || -L $LOG_NAME.log ]] ; then + i=0 + while [[ -e $LOG_NAME.log.$i || -L $LOG_NAME.log.$i ]] ; do + let i++ + done + mv $LOG_NAME.log $LOG_NAME.log.$i + LOG_NAME=$LOG_NAME +fi +touch -- "$LOG_NAME".log +exec 1> $LOG_NAME.log 2>&1 + set -x -exec 1> /opt/wz_mini/log/wz_cam.log 2>&1 +echo "welcome to wz_cam.sh" +echo "PID $$" cp /opt/wz_mini/etc/uvc.config /opt/wz_mini/usr/bin/uvc.config diff --git a/SD_ROOT/wz_mini/etc/init.d/wz_post.sh b/SD_ROOT/wz_mini/etc/init.d/wz_post.sh index 2d7c9f6..91179bf 100755 --- a/SD_ROOT/wz_mini/etc/init.d/wz_post.sh +++ b/SD_ROOT/wz_mini/etc/init.d/wz_post.sh @@ -2,7 +2,17 @@ ### This file is called by /etc/init.d/rcS, and is run before app_init.sh -exec 1> /opt/wz_mini/log/wz_post.log 2>&1 +LOG_NAME=/opt/wz_mini/log/wz_post +if [[ -e $LOG_NAME.log || -L $LOG_NAME.log ]] ; then + i=0 + while [[ -e $LOG_NAME.log.$i || -L $LOG_NAME.log.$i ]] ; do + let i++ + done + mv $LOG_NAME.log $LOG_NAME.log.$i + LOG_NAME=$LOG_NAME +fi +touch -- "$LOG_NAME".log +exec 1> $LOG_NAME.log 2>&1 set -x diff --git a/SD_ROOT/wz_mini/etc/init.d/wz_user.sh b/SD_ROOT/wz_mini/etc/init.d/wz_user.sh index c579c4d..f2a884f 100755 --- a/SD_ROOT/wz_mini/etc/init.d/wz_user.sh +++ b/SD_ROOT/wz_mini/etc/init.d/wz_user.sh @@ -1,6 +1,16 @@ #!/bin/sh -exec 1> /opt/wz_mini/log/wz_user.log 2>&1 +LOG_NAME=/opt/wz_mini/log/wz_user +if [[ -e $LOG_NAME.log || -L $LOG_NAME.log ]] ; then + i=0 + while [[ -e $LOG_NAME.log.$i || -L $LOG_NAME.log.$i ]] ; do + let i++ + done + mv $LOG_NAME.log $LOG_NAME.log.$i + LOG_NAME=$LOG_NAME +fi +touch -- "$LOG_NAME".log +exec 1> $LOG_NAME.log 2>&1 set -x diff --git a/SD_ROOT/wz_mini/usr/bin/watch_up.sh b/SD_ROOT/wz_mini/usr/bin/watch_up.sh index 1ad2bc8..929cfdb 100755 --- a/SD_ROOT/wz_mini/usr/bin/watch_up.sh +++ b/SD_ROOT/wz_mini/usr/bin/watch_up.sh @@ -1,6 +1,16 @@ #!/bin/sh -exec 1>> /opt/wz_mini/log/watch_up.log 2>&1 +LOG_NAME=/opt/wz_mini/log/watch_up +if [[ -e $LOG_NAME.log || -L $LOG_NAME.log ]] ; then + i=0 + while [[ -e $LOG_NAME.log.$i || -L $LOG_NAME.log.$i ]] ; do + let i++ + done + mv $LOG_NAME.log $LOG_NAME.log.$i + LOG_NAME=$LOG_NAME +fi +touch -- "$LOG_NAME".log +exec 1> $LOG_NAME.log 2>&1 set -x