Subversion Repositories livecd

Rev

Rev 1 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1 Rev 169
1
#!/bin/bash
1
#!/bin/bash
2
#
2
#
3
# McAfee Antivirus Updater for Linux
3
# McAfee Antivirus Updater for Linux
4
# 
4
# 
5
# Urs Beyerle, PSI
5
# Urs Beyerle
6
#
6
#
7
 
7
 
8
echo
8
echo
9
echo "***************************************"
9
echo "***************************************"
10
echo "* McAfee Antivirus Updater            *"
10
echo "* McAfee Antivirus Updater            *"
11
echo "***************************************"
11
echo "***************************************"
12
echo
12
echo
13
 
13
 
14
DOWNLOAD_DIR=/tmp/download-mcafee-dat
14
DOWNLOAD_DIR=/tmp/download-mcafee-dat
15
UVSCAN_DIR=/usr/local/uvscan
15
UVSCAN_DIR=/usr/local/uvscan
16
DAT_URL=http://linux.web.psi.ch/mirror/antivirus/mcafee/pub/datfiles/english
16
DAT_URL=http://linux.web.psi.ch/mirror/antivirus/mcafee/pub/datfiles/english
17
 
17
 
18
 
18
 
19
update_failed ()
19
update_failed ()
20
{
20
{
21
    echo
21
    echo
22
    echo "***************************************"
22
    echo "***************************************"
23
    echo "* Update failed.                      *"
23
    echo "* Update failed.                      *"
24
    echo "***************************************"
24
    echo "***************************************"
25
    rm -rf $DOWNLOAD_DIR
25
    rm -rf $DOWNLOAD_DIR
26
    echo
26
    echo
27
    exit 1
27
    exit 1
28
}
28
}
29
 
29
 
30
update_success ()
30
update_success ()
31
{
31
{
32
    echo
32
    echo
33
    echo "***************************************"
33
    echo "***************************************"
34
    echo "* Update completed successfully.      *"
34
    echo "* Update completed successfully.      *"
35
    echo "***************************************"
35
    echo "***************************************"
36
    rm -rf $DOWNLOAD_DIR
36
    rm -rf $DOWNLOAD_DIR
37
    echo
37
    echo
38
    exit
38
    exit
39
}
39
}
40
 
40
 
41
update_notneeded ()
41
update_notneeded ()
42
{
42
{
43
    echo
43
    echo
44
    echo "Nothing to be done..."
44
    echo "Nothing to be done..."
45
    rm -rf $DOWNLOAD_DIR
45
    rm -rf $DOWNLOAD_DIR
46
    echo
46
    echo
47
    exit
47
    exit
48
}
48
}
49
 
49
 
50
### create dir for download
50
### create dir for download
51
rm -rf $DOWNLOAD_DIR
51
rm -rf $DOWNLOAD_DIR
52
mkdir -p $DOWNLOAD_DIR
52
mkdir -p $DOWNLOAD_DIR
53
cd $DOWNLOAD_DIR
53
cd $DOWNLOAD_DIR
54
 
54
 
55
### get update.ini
55
### get update.ini
56
echo "Download update.ini"
56
echo "Download update.ini"
57
wget --quiet $DAT_URL/update.ini
57
wget --quiet $DAT_URL/update.ini
58
if [ ! -e update.ini ]; then
58
if [ ! -e update.ini ]; then
59
    echo "Download failed."
59
    echo "Download failed."
60
    update_failed
60
    update_failed
61
fi
61
fi
62
 
62
 
63
### do we need new Dat files?
63
### do we need new Dat files?
64
Version=$( grep "DATVersion=" update.ini | cut -d"=" -f 2 | head -n 1 | sed 's/\r//' )
64
Version=$( grep "DATVersion=" update.ini | cut -d"=" -f 2 | head -n 1 | sed 's/\r//' )
65
uvscan --version | grep $Version
65
uvscan --version | grep $Version
66
if [ "$?" = "0" ]; then
66
if [ "$?" = "0" ]; then
67
    update_notneeded
67
    update_notneeded
68
fi
68
fi
69
 
69
 
70
### get ZipFileName
70
### get ZipFileName
71
dos2unix update.ini
71
dos2unix update.ini
72
ZipFileName=$( grep "FileName=dat-.*zip" update.ini | cut -d"=" -f 2 )
72
ZipFileName=$( grep "FileName=dat-.*zip" update.ini | cut -d"=" -f 2 )
73
if [ ! $ZipFileName ]; then
73
if [ ! $ZipFileName ]; then
74
    echo "Filename of dat-*.zip not found."
74
    echo "Filename of dat-*.zip not found."
75
    update_failed
75
    update_failed
76
fi
76
fi
77
    
77
    
78
### download $ZipFileName
78
### download $ZipFileName
79
echo "Download $ZipFileName ..."
79
echo "Download $ZipFileName ..."
80
wget $DAT_URL/$ZipFileName
80
wget $DAT_URL/$ZipFileName
81
if [ ! -e $ZipFileName ]; then
81
if [ ! -e $ZipFileName ]; then
82
    echo "Download of $ZipFileName failed."
82
    echo "Download of $ZipFileName failed."
83
    update_failed
83
    update_failed
84
fi
84
fi
85
 
85
 
86
### unzip and copy dat files
86
### unzip and copy dat files
87
unzip $ZipFileName
87
unzip $ZipFileName
88
DatFiles=$( ls *.dat )
88
DatFiles=$( ls *.dat )
89
if [ ${#DatFiles} == 0 ]; then
89
if [ ${#DatFiles} == 0 ]; then
90
    echo "No dat files found."
90
    echo "No dat files found."
91
    update_failed    
91
    update_failed    
92
fi
92
fi
93
 
93
 
94
echo "Copy *.dat files to $UVSCAN_DIR:"
94
echo "Copy *.dat files to $UVSCAN_DIR:"
95
for file in $DatFiles; do
95
for file in $DatFiles; do
96
    cp -a $file $UVSCAN_DIR/
96
    cp -a $file $UVSCAN_DIR/
97
    if [ "$?" != "0" ]; then
97
    if [ "$?" != "0" ]; then
98
	echo "$file could not be copied."
98
	echo "$file could not be copied."
99
    else
99
    else
100
	echo "$file copied."
100
	echo "$file copied."
101
	chmod 644 $UVSCAN_DIR/$file
101
	chmod 644 $UVSCAN_DIR/$file
102
    fi
102
    fi
103
done
103
done
104
 
104
 
105
echo 
105
echo 
106
uvscan --version
106
uvscan --version
107
update_success
107
update_success