Skip to content

Instantly share code, notes, and snippets.

Created December 11, 2015 21:22
Show Gist options
  • Save anonymous/dfc7d893e94f30317dfa to your computer and use it in GitHub Desktop.
Save anonymous/dfc7d893e94f30317dfa to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
#Author: Vatsaev Aslan (@avatsaev)
#Repository: https://github.com/avatsaev/mackeeper_blocker
#request root previleges in order to modify hosts file
if ENV["USER"] != "root"
exec("sudo #{ENV['_']} #{ARGV.join(' ')}")
exit
end
#initiate domain list array
mk_address_list = [
"mackeeperapp.mackeeper.com",
"mackeeperapp2.mackeeper.com",
"mackeeperapp3.mackeeper.com",
"mackeeper.com"
]
#open hosts file in append mode
open('/etc/hosts', 'a') do |f|
#for every domain name
mk_address_list.each do |addr|
p "Adding #{addr} to hosts file..."
f.puts "127.0.0.1 #{addr}"
p "✔︎ Done."
end
f.close
end
p "-----------"
p "✔︎ Script finished running."
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment