2016-03-16 22:33:38 +01:00
|
|
|
# Doodle3D logrotate configuration
|
|
|
|
|
|
|
|
compress
|
|
|
|
su
|
|
|
|
create
|
|
|
|
|
|
|
|
/tmp/wifibox.log /tmp/print3d-*.log {
|
|
|
|
rotate 2
|
|
|
|
size 1000k
|
|
|
|
missingok
|
|
|
|
olddir /tmp/wifibox-rotated
|
2016-03-18 16:28:21 +01:00
|
|
|
|
|
|
|
# as alternative to copytruncate (which *might* miss lines) we could implement
|
|
|
|
# SIGUSR1 in print3d and firmware to reopen their logs
|
|
|
|
copytruncate # 'create' is ignored with copytruncate, as the file stays in place
|
|
|
|
|
|
|
|
prerotate
|
|
|
|
FIRST_N_LINES=500
|
|
|
|
PRINT3D_LOGHEAD_FILE=print3d-loghead
|
|
|
|
WIFIBOX_LOGHEAD_FILE=wifibox-loghead
|
|
|
|
ROTATED_FILES_PATH=/tmp/wifibox-rotated
|
|
|
|
|
|
|
|
#Note: by looking at creation date of the print3d socket and comparing against that
|
|
|
|
# of print3d-loghead we could detect a server restart (e.g. due to reconnected printer)
|
|
|
|
|
|
|
|
echo "$1" | grep -q "print3d-.*\.log"
|
|
|
|
if [ $? -eq 0 -a ! -f "$ROTATED_FILES_PATH/$PRINT3D_LOGHEAD_FILE" ]; then
|
|
|
|
head -q -n$FIRST_N_LINES "$1" > "$ROTATED_FILES_PATH/$PRINT3D_LOGHEAD_FILE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$1" | grep -q "wifibox.log"
|
|
|
|
if [ $? -eq 0 -a ! -f "$ROTATED_FILES_PATH/$WIFIBOX_LOGHEAD_FILE" ]; then
|
|
|
|
head -q -n$FIRST_N_LINES "$1" > "$ROTATED_FILES_PATH/$WIFIBOX_LOGHEAD_FILE"
|
|
|
|
fi
|
|
|
|
endscript
|
2016-03-16 22:33:38 +01:00
|
|
|
}
|