Created
December 11, 2015 21:22
-
-
Save anonymous/dfc7d893e94f30317dfa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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