lib/shutter/command_line.rb in shutter-0.0.5 vs lib/shutter/command_line.rb in shutter-0.0.6

- old
+ new

@@ -16,12 +16,15 @@ end @config_path = path end + def iptables + @iptables ||= Shutter::IPTables::Base.new(@config_path) + end + def execute - @iptables = Shutter::IPTables::Base.new(@config_path) options = {} optparse = OptionParser.new do |opts| opts.banner = "Usage: shutter [options]" options[:command] = :save opts.on( '--init', 'Create the initial configuration files' ) do @@ -82,24 +85,24 @@ end end def save init - @ipt = @iptables.generate + @ipt = iptables.generate puts @ipt end def restore init - @ipt = @iptables.generate + @ipt = iptables.generate IO.popen("#{Shutter::IPTables::IPTABLES_RESTORE}", "r+") do |iptr| iptr.puts @ipt ; iptr.close_write end persist if @persist end def persist - pfile = ENV['SHUTTER_PERSIST_FILE'] ? ENV['SHUTTER_PERSIST_FILE'] : @iptables.persist_file(@os) + pfile = ENV['SHUTTER_PERSIST_FILE'] ? ENV['SHUTTER_PERSIST_FILE'] : iptables.persist_file(@os) File.open(pfile, "w") do |f| f.write(@ipt) end end \ No newline at end of file