mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 10:37:39 -07:00
fixed bug in history loging func
This commit is contained in:
parent
c1afcd1005
commit
779b9cf521
2 changed files with 14 additions and 16 deletions
|
@ -69,7 +69,11 @@ chmod 644 $VESTA/data/packages/$package.pkg
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_history "added user package $package" '' 'admin'
|
||||
if [ "$rewrite" != 'yes' ]; then
|
||||
log_history "added user package $package" '' 'admin'
|
||||
else
|
||||
log_history "updated user package $package" '' 'admin'
|
||||
fi
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
||||
|
|
24
func/main.sh
24
func/main.sh
|
@ -59,25 +59,19 @@ log_event() {
|
|||
log_history() {
|
||||
cmd=$1
|
||||
undo=${2-no}
|
||||
log_user="$3"
|
||||
log_user=${3-$user}
|
||||
log=$VESTA/data/users/$log_user/history.log
|
||||
|
||||
if [ -z "$log_user" ]; then
|
||||
log_user="$user"
|
||||
touch $log
|
||||
if [ '99' -lt "$(wc -l $log |cut -f 1 -d ' ')" ]; then
|
||||
tail -n 99 $log > $log.moved
|
||||
mv -f $log.moved $log
|
||||
chmod 660 $log
|
||||
fi
|
||||
|
||||
touch $USER_DATA/history.log
|
||||
if [ '99' -lt "$(wc -l $USER_DATA/history.log |cut -f 1 -d ' ')" ]; then
|
||||
tail -n 99 $USER_DATA/history.log > $USER_DATA/history.log.mv
|
||||
mv -f $USER_DATA/history.log.mv $USER_DATA/history.log
|
||||
chmod 660 $USER_DATA/history.log
|
||||
fi
|
||||
|
||||
curr_str=$(grep "ID=" $VESTA/data/users/$log_user/history.log |\
|
||||
cut -f 2 -d \' | sort -n | tail -n1)
|
||||
curr_str=$(grep "ID=" $log | cut -f 2 -d \' | sort -n | tail -n1)
|
||||
id="$((curr_str +1))"
|
||||
|
||||
HISTORY="ID='$id' DATE='$DATE' TIME='$TIME' CMD='$cmd' UNDO='$undo'"
|
||||
echo "$HISTORY" >> $VESTA/data/users/$log_user/history.log
|
||||
echo "ID='$id' DATE='$DATE' TIME='$TIME' CMD='$cmd' UNDO='$undo'" >> $log
|
||||
}
|
||||
|
||||
# Argument list checker
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue