class Fixingthenet::Installer::InstallCommand
installs some templates for nginx and init.d
Private Instance Methods
command()
click to toggle source
# File lib/fixingthenet/installer/install_command.rb, line 30 def command # make sure the site exists render(app.template_path.join('nginx_app.conf.erb'),NGINX_SITES_DIR.join("fixingthenet-#{app.server_name}")) # install the location handler {app.template_path.join('app.conf.erb') => NGINX_APPS_DIR.join(app.full_name), app.template_path.join('initd.conf.erb') => INITD_DIR.join(app.full_name) }.each do |template_name, destination| render(template_name, destination) end `sudo /etc/init.d/#{app.full_name} reload` end
parse_options()
click to toggle source
# File lib/fixingthenet/installer/install_command.rb, line 10 def parse_options OptionParser.new do |opts| opts.banner = "Usage: ftn install [options]" parse_common_options(opts) opts.on("-p", "--port PORT", "Port") do |op| options[:port] = op end opts.on("-m", "--mount MOUNT_PATH", "Mount path") do |op| options[:mount_path] = op end opts.on("-t", "--template TEMPLATE_PATH", "Template path") do |op| options[:template_path] = Pathname.new(op) end end.parse!(args) end
render(template_name, destination)
click to toggle source
# File lib/fixingthenet/installer/install_command.rb, line 44 def render(template_name, destination) content=ERB.new(File.read(template_name)).result(binding) puts "#{template_name} -> #{destination}" if options[:verbose] write_content(destination, content) end
write_content(file, content)
click to toggle source
# File lib/fixingthenet/installer/install_command.rb, line 50 def write_content(file, content) File.open(file, "w") do |fd| fd.write content end FileUtils.chmod("u+x", file) end