Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- # ./script on -- turn restrictions on
- # ./script off -- turn restrictions off
- @hosts = '/etc/hosts'
- @time_eaters = [
- 'habrahabr.ru',
- 'pink.habrahabr.ru',
- ];
- def deny_time_eaters
- File.open(@hosts, 'a') do |f|
- f.puts( @time_eaters.map {|s| "127.0.0.1 %-30s # TIME EATER" % s} )
- end
- end
- def allow_time_eaters
- system "sed -i.bak '/TIME EATER/ d' #{@hosts}"
- end
- action = ARGV.shift || 'on'
- case action
- when 'on' then deny_time_eaters
- when 'off' then allow_time_eaters
- else
- raise "Unkwnown action '#{action}'"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement