Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
desc 'Configures apache with a new phusion passenger virtual host; USAGE: sake passenger:new server_name=myapp rails_dir=/projects/my_rails_app' task 'passenger:new' do unless (ENV.include?("server_name") and (ENV.include?("rails_dir") and File.exists?(File.join(ENV["rails_dir"], "public")))) then raise("\nUSAGE: sake passenger:new server_name=myapp rails_dir=/projects/my_rails_app/\n\n") end server_name = ENV["server_name"] rails_public_dir = File.join(File.expand_path(ENV["rails_dir"]), "public") httpd_conf = "/etc/apache2/other/httpd-mod-rails.conf" commands = [] puts("Updating your /etc/hosts with an alias for #{server_name} to 127.0.0.1") (commands << "echo '127.0.0.1 #{server_name}' >> /etc/hosts") puts("Adding new virtual host to apache") virtual_host_template = [] (virtual_host_template << "") (virtual_host_template << "<VirtualHost *:80>") (virtual_host_template << " ServerName #{server_name}") (virtual_host_template << " DocumentRoot #{rails_public_dir}") (virtual_host_template << " RailsEnv development") (virtual_host_template << "</VirtualHost>") (commands << "echo '#{virtual_host_template.join("\\n")}' >> #{httpd_conf}") puts("Restarting apache") (commands << "apachectl graceful") system("sudo -p 'sudo password for %u: ' sh -c \"#{commands.join(" && ")}\"") end
This paste will be private.
From the Design Piracy series on my blog: