Skip to content

Instantly share code, notes, and snippets.

@beeftornado
Last active July 27, 2018 15:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beeftornado/9a0982d65d20cd914ee1 to your computer and use it in GitHub Desktop.
Save beeftornado/9a0982d65d20cd914ee1 to your computer and use it in GitHub Desktop.
sophos-anti-virus-home-edition91.rb
class SophosAntiVirusHomeEdition91 < Cask
module Utils
@@services = nil
def self.disable_sophos_services
# Stop any existing sophos or the install could hang
# Maybe it was only the permissions issue and not existing sophos, double check if needed
cmd = ['/usr/bin/sudo', '-E', '--', '/bin/launchctl', 'list'].join(' ')
@@services = `#{cmd}`
@@services.split.find_all{ |service| service.include? 'com.sophos' }.each do |service|
ohai "Stopping service #{service}..."
system '/usr/bin/sudo', '-E', '--',
'/bin/launchctl', 'unload', "/Library/LaunchDaemons/#{service}.plist"
end
end
def self.enable_sophos_services
# Re-enable sophos
@@services.split.find_all{ |service| service.include? 'com.sophos' }.each do |service|
ohai 'Starting service #{service}...'
system '/usr/bin/sudo', '-E', '--',
'/bin/launchctl', 'load', '-w', "/Library/LaunchDaemons/#{service}.plist"
end
end
end
version '9.1.4'
sha256 'c8d0739f480f781582ac5eeeb72820acee61072c1e81807dd60ff74fe8c76334'
# container_type :naked
url 'http://downloads.sophos.com/home-edition/savosx91_he.zip'
homepage 'http://www.sophos.com/en-us/products/free-tools/sophos-antivirus-for-mac-home-edition.aspx/'
# Found the process hanging while unpacking the zip with ditto. Running it in debug mode and then running
# the ditto command manually printed out a permission error inside the app bundle it was unpacking, which is
# certainly odd. Was trying a workaround where I would do the unpacking myself and then ensure proper permissions.
# The offending file was inside 'installer/Custom/*.vcs' and the owner did not have write permissions. (--r--r--r).
# There is an inconsistency with this theory though. Even the current sophos formula that only unpacks the installer
# without executing it runs the ditto command. Why does it only hang after adding the after_install block?
# My computer? Not sure.
# Utils.disable_sophos_services
# before_install do
# system '/usr/bin/sudo', '-E', '--',
# '/usr/bin/ditto', '-xk', '--', "/Library/Caches/Homebrew/sophos-anti-virus-home-edition91-latest.zip",
# "#{@cask.destination_path}"
# system '/usr/bin/sudo', '-E', '--',
# '/usr/sbin/chown', '-R', Etc.getlogin, "#{@cask.destination_path}"
# end
after_install do
# The real installation
# http://www.sophos.com/en-us/support/knowledgebase/14179.aspx
system '/usr/bin/sudo', '-E', '--',
"#{@cask.destination_path}/Sophos Anti-Virus Home Edition.app/Contents/MacOS/tools/InstallationDeployer", '--install'
# Done automatically by the installer?
# Util.enable_sophos_services
end
# link 'Sophos Anti-Virus Home Edition.app'
caveats do
reboot
# manual_installer "#{@cask.destination_path}/Sophos Anti-Virus Home Edition.app"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment