mirror of
https://github.com/myvesta/vesta
synced 2025-08-21 05:44:08 -07:00
user notification in main func inc
This commit is contained in:
parent
51be240bd4
commit
a2251186e9
1 changed files with 35 additions and 0 deletions
35
func/main.sh
35
func/main.sh
|
@ -110,6 +110,7 @@ is_system_enabled() {
|
|||
fi
|
||||
}
|
||||
|
||||
|
||||
# User package check
|
||||
is_package_full() {
|
||||
case "$1" in
|
||||
|
@ -367,6 +368,40 @@ decrease_user_value() {
|
|||
sed -i "s/$key='$old'/$key='$new'/g" $conf
|
||||
}
|
||||
|
||||
# Notify user
|
||||
send_notice() {
|
||||
topic=$1
|
||||
notice=$2
|
||||
|
||||
if [ "$notify" = 'yes' ]; then
|
||||
touch $USER_DATA/notifications.conf
|
||||
chmod 660 $USER_DATA/notifications.conf
|
||||
|
||||
time_n_date=$(date +'%T %F')
|
||||
time=$(echo "$time_n_date" |cut -f 1 -d \ )
|
||||
date=$(echo "$time_n_date" |cut -f 2 -d \ )
|
||||
|
||||
nid=$(grep "NID=" $USER_DATA/notifications.conf |cut -f 2 -d \')
|
||||
nid=$(echo "$nid" |sort -n |tail -n1)
|
||||
if [ ! -z "$nid" ]; then
|
||||
nid="$((nid +1))"
|
||||
else
|
||||
nid=1
|
||||
fi
|
||||
|
||||
str="NID='$nid' TOPIC='$topic' NOTICE='$notice' TYPE='$type'"
|
||||
str="$str ACK='no' TIME='$time' DATE='$date'"
|
||||
|
||||
echo "$str" >> $USER_DATA/notifications.conf
|
||||
|
||||
if [ -z "$(grep NOTIFICATIONS $USER_DATA/user.conf)" ]; then
|
||||
sed -i "s/^TIME/NOTIFICATIONS='yes'\nTIME/g" $USER_DATA/user.conf
|
||||
else
|
||||
update_user_value "$user" '$NOTIFICATIONS' "yes"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Recalculate U_DISK value
|
||||
recalc_user_disk_usage() {
|
||||
u_usage=0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue