strip blank lines from deny file, plus improve editing interface

This commit is contained in:
Rob Watson 2010-11-10 15:36:12 +00:00
parent 6123b38a55
commit ca026fd893
2 changed files with 7 additions and 2 deletions

View File

@ -4,7 +4,7 @@ require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'noproc
begin begin
case ARGV.first case ARGV.first
when 'on' when 'on', 'reload'
Noprocast.activate! Noprocast.activate!
when 'off' when 'off'
Noprocast.deactivate! Noprocast.deactivate!
@ -16,6 +16,11 @@ begin
exit exit
end end
Noprocast.edit! Noprocast.edit!
if Noprocast.active?
puts "Saved. Now: noprocast reload"
else
puts "Saved. Now: noprocast on"
end
when 'help', '-h', '--help', nil when 'help', '-h', '--help', nil
puts "Usage: [sudo] noprocast [on|off|status|edit]" puts "Usage: [sudo] noprocast [on|off|status|edit]"
end end

View File

@ -12,7 +12,7 @@ class Noprocast
def current_hosts def current_hosts
setup_deny_file_if_required! setup_deny_file_if_required!
File.read(deny_file_path).split(/\n/).map(&:strip) File.read(deny_file_path).split(/\n/).select { |line| line.match(/[a-zA-Z0-9]/) }.map(&:strip)
end end
def hosts_file_content def hosts_file_content