lib/shutter/command_line.rb in shutter-0.0.6 vs lib/shutter/command_line.rb in shutter-0.0.7
- old
+ new
@@ -12,11 +12,10 @@
puts "Shutter is currently only compatible with RedHat and its variants."
puts "Help make it compatible with others (github.com/rlyon/shutter)"
exit
end
end
-
@config_path = path
end
def iptables
@iptables ||= Shutter::IPTables::Base.new(@config_path)
@@ -31,10 +30,13 @@
options[:command] = :init
end
opts.on( '--reinit', 'Rereate the initial configuration files' ) do
options[:command] = :reinit
end
+ opts.on( '--upgrade', 'Rereate the base template to add new features' ) do
+ options[:command] = :upgrade
+ end
opts.on( '-s', '--save', 'Output the firewall to stdout. (DEFAULT)') do
options[:command] = :save
end
opts.on( '-r', '--restore', 'Load the firewall through iptables-restore.') do
options[:command] = :restore
@@ -76,9 +78,19 @@
end
def reinit
create_config_dir
Shutter::CONFIG_FILES.each do |name|
+ file = "#{@config_path}/#{name}"
+ File.open(file, 'w') do |f|
+ f.write(Shutter.const_get(name.upcase.gsub(/\./, "_")))
+ end
+ end
+ end
+
+ def upgrade
+ create_config_dir
+ ["base.ipt", "iface.forward"].each do |name|
file = "#{@config_path}/#{name}"
File.open(file, 'w') do |f|
f.write(Shutter.const_get(name.upcase.gsub(/\./, "_")))
end
end
\ No newline at end of file