-
Notifications
You must be signed in to change notification settings - Fork 0
/
avast-gui.in
executable file
·171 lines (154 loc) · 6.42 KB
/
avast-gui.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/bash
####################################################################
#
# Unofficial GUI for Avast
#
####################################################################
VER=%VER%
GICON=/usr/share/avast-gui/icons/icon-transp.png
GICONBIZ=/usr/share/avast-gui/icons/icon-biz.svg
TITLE="Avast Antivirus for Linux (unofficial UI)"
DEBUG=1
ARG=$1
MAINPID=$$
[ $DEBUG -eq 1 ] && echo "mainpid $MAINPID"
# main window
F_MAIN(){
ANS=$1
# grab current versions
VPSVER=$(scan -V)
AVVER=$(avast -V)
# check if we have a notify running already
ps aux | grep -v grep | grep -q AvastAntivirusforLinuxNotify
NOTIFY=$?
YADPID=99
if [ $NOTIFY -ne 0 ];then
if [ "$ANS" != "11" ];then
[ $DEBUG -eq 1 ] && echo "background notification started"
yad --notification --image=$GICON \
--menu='Scan!avast-gui scan|Update!avast-gui update|Settings!avast-gui settings|Exit!quit' \
--command='/bin/sh -c avast-gui' \
--icon-size=16 --no-middle --text=AvastAntivirusforLinuxNotify --auto-kill &
YADPID=$!
[ $DEBUG -eq 1 ] && echo Notify started with $YADPID
else
[ $DEBUG -eq 1 ] && echo "foreground notification started"
yad --notification --image=$GICON \
--menu='Scan!avast-gui scan|Update!avast-gui update|Settings!avast-gui settings|Exit!quit' \
--command='avast-gui 0' \
--icon-size=16 --no-middle --text=AvastAntivirusforLinuxNotify --auto-kill
return 252
fi
else
[ $DEBUG -eq 1 ] && echo "quit bc notify is set already"
#exit 252
fi
if [ "$ANS" != "11" ];then
[ $DEBUG -eq 1 ] && echo "main window started"
yad --icon=$GICON --image=$GICONBIZ --title="$TITLE" \
--item-width="100" --width="530" --height="300" \
--icons --read-dir=/usr/share/avast-gui/desktopfiles --auto-kill \
--text="\
<b>Avast:</b> v${AVVER}\ / <b>GUI:</b> v${VER}\n\
<b>Service: $AVAST_STATE</b>\n\
<b>Local Virus Database:</b> $VPSVER\n\n\
<b>Double click</b> an item to perform an action:"\
--icon-size=64 \
--button="Hide:11"
ANS=$?
else
[ $DEBUG -eq 1 ] && echo "skipping main window bc ANS = $ANS"
exit
fi
[ $DEBUG -eq 1 ] && echo "ANS: $ANS, PID: $YADPID"
[ "$YADPID" -ne 99 ] && kill $YADPID
return $ANS
}
# settings window
F_SETTINGS(){
yad --icon=$GICON --height=200 --width=400 --title="$TITLE" --text="\n\n\t\t$FUNCNAME coming soon"
}
# update window
F_UPDATE(){
yad --icon=$GICON --height=200 --width=400 --title="$TITLE" --text="\n\n\t\t$FUNCNAME coming soon"
}
# scan window
F_SCAN(){
yad --icon=$GICON --height=200 --width=400 --title="$TITLE" --text="\n\n\t\t$FUNCNAME coming soon"
}
# license window
F_LIC(){
yad --icon=$GICON --height=200 --width=400 --title="$TITLE" --text="\n\n\t\t$FUNCNAME coming soon"
}
F_STATE(){
unset RESTFOR
# grab current versions
VPSVER=$(scan -V)
AVVER=$(avast -V)
# get service states
ACT_AVAST=$(systemctl show avast --no-page |grep ActiveState | cut -d "=" -f 2)
SUB_AVAST=$(systemctl show avast --no-page |grep SubState | cut -d "=" -f 2)
ACT_FSS=$(systemctl show avast-fss --no-page |grep ActiveState | cut -d "=" -f 2)
SUB_FSS=$(systemctl show avast-fss --no-page |grep SubState | cut -d "=" -f 2)
ACT_VPS=$(systemctl show avast-vpsupdate.timer --no-page |grep ActiveState | cut -d "=" -f 2)
SUB_VPS=$(systemctl show avast-vpsupdate.timer --no-page |grep SubState | cut -d "=" -f 2)
pacman -Q avast-rest 2>&1 > /dev/null
if [ $? -eq 0 ];then
ACT_REST=$(systemctl show avast-rest --no-page |grep ActiveState | cut -d "=" -f 2)
SUB_REST=$(systemctl show avast-rest --no-page |grep SubState | cut -d "=" -f 2)
RESTFOR="${ACT_REST}:${SUB_REST}:REST"
else
REST_STATE="not installed"
fi
for st in ${ACT_AVAST}:${SUB_AVAST}:AVAST ${ACT_FSS}:${SUB_FSS}:FSS $ACT_VPS:${SUB_VPS}:VPS $RESTFOR; do
AST=$(echo "$st" | cut -d ":" -f 1)
SST=$(echo "$st" | cut -d ":" -f 2)
N=$(echo "$st" | cut -d ":" -f 3)
if [ ${SST} == "running" ]||[ ${SST} == "waiting" ];then
declare ${N}_STATE="<span color='#009933'>${AST}/${SST}</span>"
else
declare ${N}_STATE="<span color='#CC2222'>${AST}/${SST}</span>"
fi
done
yad --icon=$GICON --height=100 --width=400 --title='Service States' \
--text="\n\n\
\t<b>Avast version:</b>\t\t${AVVER}\n\
\t<b>VPS version:</b>\t\t\t${VPSVER}\n\n\n\
\t<b>Avast Service:</b>\t\t\t${AVAST_STATE}\n\n\
\t<b>File Server Shield:</b>\t\t${FSS_STATE}\n\n\
\t<b>VPS Updater:</b>\t\t\t${VPS_STATE}\n\n\
\t<b>REST Service:</b>\t\t\t${REST_STATE}"\
--button=Close
}
F_ABOUT(){
yad --icon=$GICON --height=200 --width=400 --title="$TITLE" --text="\n\n\t\t$FUNCNAME coming soon"
# services: <a target="_blank" href="https://icons8.com/icon/Gkju9C9xs2XV/dienstleistungen">Dienstleistungen</a> icon by <a target="_blank" href="https://icons8.com">Icons8</a>
# settings: <a target="_blank" href="https://icons8.com/icon/AuMLFRmG95tQ/bearbeiten">Bearbeiten</a> icon by <a target="_blank" href="https://icons8.com">Icons8</a>
# update: <a target="_blank" href="https://icons8.com/icon/F3gTbetqcmoM/synchronisieren">Synchronisieren</a> icon by <a target="_blank" href="https://icons8.com">Icons8</a>
# scan: <a target="_blank" href="https://icons8.com/icon/3159/suche">Suche</a> icon by <a target="_blank" href="https://icons8.com">Icons8</a>
# about: <a target="_blank" href="https://icons8.com/icon/42SQTTISIN17/info">Info</a> icon by <a target="_blank" href="https://icons8.com">Icons8</a>
# license: <a target="_blank" href="https://icons8.com/icon/ljgEvPDgyC3y/scrollen">Scrollen</a> icon by <a target="_blank" href="https://icons8.com">Icons8</a>
}
case $ARG in
settings) F_SETTINGS ;;
update) F_UPDATE ;;
scan) F_SCAN ;;
license) F_LIC ;;
state) F_STATE ;;
about) F_ABOUT ;;
*) MARG=$1
while true ;do
[ $DEBUG -eq 1 ] && echo "starting F_MAIN with $MARG"
F_MAIN $MARG
RET=$?
[ $DEBUG -eq 1 ] && echo RET is $RET
if [ $RET -eq 252 ];then
pkill -P $$
#[ $$ != $MAINPID ] &&
kill $MAINPID
break
fi
MARG=$RET
done
;;
esac