mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-19 21:04:06 -07:00
inproved +1counter function
This commit is contained in:
parent
a87fcd9555
commit
6894bb2b27
1 changed files with 8 additions and 19 deletions
|
@ -691,29 +691,18 @@ update_user_value() {
|
||||||
|
|
||||||
increase_user_value() {
|
increase_user_value() {
|
||||||
USER="$1"
|
USER="$1"
|
||||||
key="$2"
|
key="${2//$}"
|
||||||
|
|
||||||
# Defining conf
|
|
||||||
conf="$V_USERS/$USER/user.conf"
|
|
||||||
|
|
||||||
# Deleting $
|
|
||||||
key=$(echo "${key//$/}")
|
|
||||||
|
|
||||||
# Parsing current value
|
# Parsing current value
|
||||||
current_value=$(grep "$key=" $conf |cut -f 2 -d \')
|
conf="$V_USERS/$USER/user.conf"
|
||||||
|
old=$(grep "$key=" $conf | cut -f 2 -d \')
|
||||||
# Checking result
|
if [ -z "$old" ]; then
|
||||||
if [ -z "$current_value" ]; then
|
old=0
|
||||||
echo "Error: Parsing error"
|
|
||||||
log_event 'debug' "$E_PARSING $V_EVENT"
|
|
||||||
exit $E_PARSING
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Plus one
|
# Increasing
|
||||||
new_value=$(expr $current_value + 1 )
|
new=$((old + 1 ))
|
||||||
|
sed -i "s/$key='$old'/$key='$new'/g" $conf
|
||||||
# Changing config
|
|
||||||
sed -i "s/$key='$current_value'/$key='$new_value'/g" $conf
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is_type_valid() {
|
is_type_valid() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue