Skip to content

Commit a225118

Browse files
author
Serghey Rodin
committed
user notification in main func inc
1 parent 51be240 commit a225118

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

func/main.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ is_system_enabled() {
110110
fi
111111
}
112112

113+
113114
# User package check
114115
is_package_full() {
115116
case "$1" in
@@ -367,6 +368,40 @@ decrease_user_value() {
367368
sed -i "s/$key='$old'/$key='$new'/g" $conf
368369
}
369370

371+
# Notify user
372+
send_notice() {
373+
topic=$1
374+
notice=$2
375+
376+
if [ "$notify" = 'yes' ]; then
377+
touch $USER_DATA/notifications.conf
378+
chmod 660 $USER_DATA/notifications.conf
379+
380+
time_n_date=$(date +'%T %F')
381+
time=$(echo "$time_n_date" |cut -f 1 -d \ )
382+
date=$(echo "$time_n_date" |cut -f 2 -d \ )
383+
384+
nid=$(grep "NID=" $USER_DATA/notifications.conf |cut -f 2 -d \')
385+
nid=$(echo "$nid" |sort -n |tail -n1)
386+
if [ ! -z "$nid" ]; then
387+
nid="$((nid +1))"
388+
else
389+
nid=1
390+
fi
391+
392+
str="NID='$nid' TOPIC='$topic' NOTICE='$notice' TYPE='$type'"
393+
str="$str ACK='no' TIME='$time' DATE='$date'"
394+
395+
echo "$str" >> $USER_DATA/notifications.conf
396+
397+
if [ -z "$(grep NOTIFICATIONS $USER_DATA/user.conf)" ]; then
398+
sed -i "s/^TIME/NOTIFICATIONS='yes'\nTIME/g" $USER_DATA/user.conf
399+
else
400+
update_user_value "$user" '$NOTIFICATIONS' "yes"
401+
fi
402+
fi
403+
}
404+
370405
# Recalculate U_DISK value
371406
recalc_user_disk_usage() {
372407
u_usage=0

0 commit comments

Comments
 (0)