Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #227 #344

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions files/internals/tlog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
###
# Copyright (C) 2002-2008, R-fx Networks <[email protected]>
# Copyright (C) 2008, Ryan MacDonald <[email protected]>
# Copyright (C) 2019, Tommaso De Marchi <[email protected]> <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -52,37 +53,37 @@ TSIZE=`cat $BASERUN/$TLOG` >> /dev/null 2>&1

getsize() {
if [ ! -f "$BASERUN/$TLOG" ]; then
SIZE=`stat -c %s $FILE`
SIZE=`wc -l $FILE | cut -d' ' -f1`
echo $SIZE > $BASERUN/$TLOG
NEWSIZE=`stat -c %s $FILE`
NEWSIZE=`wc -l $FILE | cut -d' ' -f1`
elif [ -f "$BASERUN/$TLOG" ] && [ "$TSIZE" == "0" ]; then
SIZE=`stat -c %s $FILE`
SIZE=`wc -l $FILE | cut -d' ' -f1`
echo $SIZE > $BASERUN/$TLOG
NEWSIZE=`stat -c %s $FILE`
NEWSIZE=`wc -l $FILE | cut -d' ' -f1`
SIZE=0
else
SIZE=`cat $BASERUN/$TLOG`
NEWSIZE=`stat -c %s $FILE`
NEWSIZE=`wc -l $FILE | cut -d' ' -f1`
fi
}

getsize

if [ ! "$NEWSIZE" -lt "$SIZE" ] && [ "$NEWSIZE" -ne "$SIZE" ]; then
tail -c `expr $NEWSIZE - $SIZE` $FILE
tail -`expr $NEWSIZE - $SIZE` $FILE
echo $NEWSIZE > $BASERUN/$TLOG
elif [ "$NEWSIZE" -lt "$SIZE" ]; then
elif [ "$NEWSIZE" -lt "$SIZE" ]; then
if [ -f "$FILE.1" ]; then
RTSIZE=`stat -c %s $FILE.1`
tail -c `expr $RTSIZE - $SIZE` $FILE.1
RTSIZE=`wc -l $FILE.1 | cut -d' ' -f1`
tail `expr $RTSIZE - $SIZE` $FILE.1
elif [ -f "$FILE.1.gz" ]; then
gunzip $FILE.1.gz
RTSIZE=`stat -c %s $FILE.1`
tail -c `expr $RTSIZE - $SIZE` $FILE.1
RTSIZE=`wc -l $FILE.1 | cut -d' ' -f1`
tail `expr $RTSIZE - $SIZE` $FILE.1
gzip $FILE.1
fi
SIZE=0
echo "$NEWSIZE" > $BASERUN/$TLOG
tail -c `expr $NEWSIZE - $SIZE` $FILE
tail `expr $NEWSIZE - $SIZE` $FILE
echo $NEWSIZE > $BASERUN/$TLOG
fi