-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpatch.sh
66 lines (52 loc) · 1.72 KB
/
patch.sh
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
#!/bin/sh
declare -a mirror_list=(
"database.clamav.net"
"packages.microsoft.com/clamav"
"pivotal-clamav-mirror.s3.amazonaws.com"
"clamavdb.c3sl.ufpr.br"
"www.syscu.net/download/clamav"
"clmvupd.deltamoby.ru"
"clamav.mirror.eterfund.ru"
"clamav.mirror.eterfund.org"
)
if (( $EUID != 0 )); then
echo "Please run as root"
exit 1
fi
declare -a available=()
declare -a result=()
echo "Mirrors testing:"
for i in "${!mirror_list[@]}"; do
echo -n "$((i+1))/${#mirror_list[@]} ${mirror_list[$i]}... "
response=$(curl --silent --range 0-511 --write-out "%{http_code}" --output daily.cvd.part "https://${mirror_list[$i]}/daily.cvd")
if [ $response -lt 300 ] ; then
name=$(cut -d ":" -f1 daily.cvd.part 2> /dev/null)
dt=$(cut -d ":" -f2 daily.cvd.part 2> /dev/null)
if [ "$name" = "ClamAV-VDB" ]; then
echo "Success"
result+=("$(printf '%-40s UPD: %s' "${mirror_list[$i]}" "$dt")")
available+=("${mirror_list[$i]}")
else
echo "Failed (Wrong file)"
fi
else
echo "Failed (Error $response)"
fi
rm daily.cvd.part 2> /dev/null
done
echo -e "\nAvailable mirrors:"
PS3="Choose a mirror: "
COLUMNS=1
select option in "${result[@]}" "Quit"
do
if [[ $REPLY = "$(( ${#result[@]}+1 ))" ]]; then
echo "Goodbye"
exit 0
fi
mirror="${available[${REPLY}-1]}"
break
done
sed -i "s|DatabaseMirror .*|DatabaseMirror $mirror|" /var/packages/AntiVirus/target/engine/clamav/etc/freshclam.conf
rm /var/packages/AntiVirus/target/engine/clamav/var/lib/freshclam.dat 2> /dev/null
echo -e "\nAntiVirus configuration has been successfully updated. Restarting AntiVirus..."
synopkg restart AntiVirus