Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- ## Will add a new rails host for the specified directory.
- ## Usage: sudo board-train directory domain
- if ARGV[0].nil? || ARGV[1].nil?
- puts "Usage: #{__FILE__} directory domain"
- exit
- end
- domain = ARGV[1]
- app_dir = File.join(File.expand_path(ARGV[0]), "public")
- puts "Domain: #{domain}"
- puts "Path: #{app_dir}"
- File.open("/etc/hosts", "a") do |f|
- f.puts "127.0.0.1 #{domain}"
- end
- vhost_template = <<END
- <VirtualHost *:80>
- RailsEnv development
- ServerName #{domain}
- DocumentRoot #{app_dir}
- <Directory "#{app_dir}">
- Order allow,deny
- Allow from all
- </Directory>
- </VirtualHost>
- END
- File.open("/etc/apache2/sites/#{domain}", "w+") do |f|
- f.write vhost_template
- end
- system "apachectl restart"
Add Comment
Please, Sign In to add comment