mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-19 21:04:06 -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
|
# 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"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
24
func/main.sh
24
func/main.sh
|
@ -59,25 +59,19 @@ log_event() {
|
||||||
log_history() {
|
log_history() {
|
||||||
cmd=$1
|
cmd=$1
|
||||||
undo=${2-no}
|
undo=${2-no}
|
||||||
log_user="$3"
|
log_user=${3-$user}
|
||||||
|
log=$VESTA/data/users/$log_user/history.log
|
||||||
|
|
||||||
if [ -z "$log_user" ]; then
|
touch $log
|
||||||
log_user="$user"
|
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
|
fi
|
||||||
|
|
||||||
touch $USER_DATA/history.log
|
curr_str=$(grep "ID=" $log | cut -f 2 -d \' | sort -n | tail -n1)
|
||||||
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)
|
|
||||||
id="$((curr_str +1))"
|
id="$((curr_str +1))"
|
||||||
|
echo "ID='$id' DATE='$DATE' TIME='$TIME' CMD='$cmd' UNDO='$undo'" >> $log
|
||||||
HISTORY="ID='$id' DATE='$DATE' TIME='$TIME' CMD='$cmd' UNDO='$undo'"
|
|
||||||
echo "$HISTORY" >> $VESTA/data/users/$log_user/history.log
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Argument list checker
|
# Argument list checker
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue