Its not that I am ashamed of how I wrote my code I just think their is a better way to right to script below.(Not sure how) In order for me to use some commands I have to login to use sudo, I usually do this by launching terminal then sudo whatever and logging in then running the applescript. Any thoughts?
set thisDialog to display dialog "What Is The Url Of The Download Source?" default answer "http://superb-west.dl.sourceforge.net/sourceforge/clamav/clamav-0.90.2.tar.gz"
set textReturned to text returned of thisDialog
set targetSave to (POSIX path of (path to desktop))
do shell script "cd " & targetSave & ";/usr/bin/curl --silent --remote-name " & quoted form of textReturned
set AppleScript's text item delimiters to {"/"}
set fileName to last text item of textReturned as string
set AppleScript's text item delimiters to {""}
set AppleScript's text item delimiters to {"."}
set clamtext1 to first text item of fileName as string
set clamtext2 to second text item of fileName as string
set clamtext3 to third text item of fileName as string
set clamtext4 to fourth text item of fileName as string
set p to "." as string
set AppleScript's text item delimiters to {""}
set ClamAvTarGzArchive to ((path to desktop) & fileName) as string
set ClamAvTarArchive to ((path to desktop) & clamtext1 & p & clamtext2 & p & clamtext3 & p & clamtext4) as string
tell application "StuffIt Expander" to expand ClamAvTarGzArchive
tell application "StuffIt Expander" to expand ClamAvTarArchive
tell application "Finder" to move file ClamAvTarGzArchive to trash
tell application "Finder" to move file ClamAvTarArchive to trash
set targetClamavFolder to ((path to desktop) & clamtext1 & p & clamtext2 & p & clamtext3) as string
set freshclamLocation to targetClamavFolder & ":etc:freshclam.conf" as string
tell application "Finder" to move file freshclamLocation to trash
try
set freshClamContent to "DNSDatabaseInfo current.cvd.clamav.net
DatabaseMirror database.clamav.net
MaxAttempts 3
Checks 12
ScriptedUpdates yes"
set freshclamFilePath to freshclamLocation
set fileRef to open for access freshclamFilePath with write permission
set eof fileRef to 0
write freshClamContent to fileRef
close access fileRef
on error
try
close access fileRef
display dialog "Something Went Wrong With Opening/Writing: freshclam.conf"
end try
end try
try
do shell script "cd " & POSIX path of file targetClamavFolder & ";./configure --prefix=/usr/local/clamXav"
do shell script "cd " & POSIX path of file targetClamavFolder & ";make"
do shell script "cd " & POSIX path of file targetClamavFolder & ";sudo make install"
on error
display dialog "Something Went Wrong In The Build Process"
end try
try
do shell script "sudo chown -R root:admin /usr/local/clamXav/etc"
do shell script "sudo chmod 0775 /usr/local/clamXav/etc"
do shell script "sudo chmod 0664 /usr/local/clamXav/etc/*"
do shell script "sudo chown -R root:admin /usr/local/clamXav/bin"
do shell script "sudo chmod 0755 /usr/local/clamXav/bin"
do shell script "sudo chmod 0755 /usr/local/clamXav/bin/*"
do shell script "sudo chown clamav /usr/local/clamXav/bin/freshclam"
do shell script "sudo chmod u+s /usr/local/clamXav/bin/freshclam"
do shell script "sudo chown -R clamav:clamav /usr/local/clamXav/share/clamav"
do shell script "sudo chmod 0755 /usr/local/clamXav/share/clamav"
do shell script "sudo chmod 0644 /usr/local/clamXav/share/clamav/*"
do shell script "sudo touch /usr/local/clamXav/share/clamav/freshclam.log"
do shell script "sudo chmod a+rw /usr/local/clamXav/share/clamav/freshclam.log"
on error
display dialog "Something Went Wrong When I Tried To Set Permissions On Files!"
end try