-
Notifications
You must be signed in to change notification settings - Fork 4
/
install_clam
executable file
·149 lines (121 loc) · 3.79 KB
/
install_clam
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
#!/bin/bash
set -e
PATH=/bin:/usr/bin:/usr/sbin
#
# Configuration
# --------------------------------------------
# Configure URL and checksum if installing different version
#
URL=http://www.clamxav.com/downloads/ClamXav_2.7.5.dmg
SHA=edf4e44a1b58bb01cda49e9c51766c4d26620400
DMG=/tmp/clamxav.dmg
USER=$(whoami)
# Configuratipn ends here
# --------------------------------------------
install_clam() {
echo '**** Installing ClamXav ...'
test -d /Applications/ClamXav.app && { echo "Please uninstall ClamXAv first"; exit 1; }
sudo -l > /dev/null
curl --progress-bar ${URL} -o ${DMG}
REAL_SHA=$(openssl sha1 ${DMG} |awk '{print $2}')
test ${SHA} == ${REAL_SHA} || { echo "Error verifying DMG checksum"; exit 1; }
DEVICE=$(hdiutil mount ${DMG} | awk '$3 ~ /Volumes/ {print $1}' 2> /dev/null)
sudo cp -R "/Volumes/ClamXav/ClamXav.app" /Applications
hdiutil detach ${DEVICE} > /dev/null 2>&1
}
run_clam () {
echo '**** Launching ClamXav ...'
osascript <<EOF > /dev/null 2>&1
tell application "System Events" to display alert "ClamXav Installation" message "After installing ClamXav you will be asked to install configuration" as critical buttons "OK" default button 1
EOF
open -W /Applications/ClamXav.app
osascript <<EOF > /dev/null 2>&1
with timeout of 3600 seconds
tell application "System Events"
display alert "Install Configuration" message "After ClamXav finishes installing engine, and downloading virus updates, click on 'Continue'. Please do not click earlier." as critical buttons { "Continue", "Cancel"} default button 1 cancel button 2
end tell
end timeout
EOF
if [ $? != 0 ]; then
exit 1
fi
}
create_sentry_plict() {
echo '**** Creating Sentry plist ...'
cat <<EOF > ~/Library/LaunchAgents/uk.co.markallan.clamxav.sentry.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>uk.co.markallan.clamxav.sentry</string>
<key>OnDemand</key>
<true/>
<key>KeepAlive</key>
<dict>
<key>OtherJobEnabled</key>
<dict>
<key>com.clamav.clamd</key>
<false/>
</dict>
</dict>
<key>LimitLoadToSessionType</key>
<string>Aqua</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/ClamXav.app/Contents/Resources/ClamXav Sentry.app/Contents/MacOS/ClamXav Sentry</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>${USER}</string>
</dict>
</plist>
EOF
}
create_freshclam_plist(){
echo '**** Creating Freshclam plist ...'
cat <<EOF > ~/Library/LaunchAgents/uk.co.markallan.clamxav.freshclam.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>uk.co.markallan.clamxav.freshclam</string>
<key>OnDemand</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Applications/ClamXav.app/Contents/Resources/ScheduleHelper</string>
<string>update</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Hour</key>
<integer>0</integer>
<key>Minute</key>
<integer>45</integer>
</dict>
</array>
</dict>
</plist>
EOF
}
launch_agents(){
for i in uk.co.markallan.clamxav.freshclam.plist uk.co.markallan.clamxav.sentry.plist; do
sudo chown root:staff ~/Library/LaunchAgents/$i
sudo chmod 644 ~/Library/LaunchAgents/$i
sudo launchctl load ~/Library/LaunchAgents/$i
done
}
# --------------------------------------------
# MAIN
# --------------------------------------------
install_clam
run_clam
create_freshclam_plist
create_sentry_plict
launch_agents