Sha256: cf348df99483990232cf028162d2cf0c3c154df4989c0d874536cca68ef000ec

Contents?: true

Size: 672 Bytes

Versions: 52

Compression:

Stored size: 672 Bytes

Contents

desc 'apache-site VIRTUAL_HOST', 'Enable the given virtual host, disabling all others'
def apache_site(*args)
  site = args.shift
  old_cwd = Dir.pwd
  Dir.chdir '/etc/apache2/sites-available/'

  # show available sites if no site was passed as argument
  unless site
    puts 'ERROR: Argument site is missing.'
    puts 'Please call: apache-site my-site'
    puts
    puts 'Available sites:'
    Dir.new(".").each do |file|
      puts "- #{file}" if file != '.' && file != '..'
    end
    exit
  end

  has_default = File.exists?('default')
  exec "sudo a2dissite \*; sudo a2ensite #{"default " if has_default}#{site} && sudo apache2ctl restart"
  Dir.chdir old_cwd
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
geordi-1.2.2 lib/geordi/commands/apache_site.rb
geordi-1.2.1 lib/geordi/commands/apache_site.rb
geordi-1.2.0 lib/geordi/commands/apache_site.rb
geordi-1.1.4 lib/geordi/commands/apache_site.rb
geordi-1.1.3 lib/geordi/commands/apache_site.rb
geordi-1.1.2 lib/geordi/commands/apache_site.rb
geordi-1.1.1 lib/geordi/commands/apache_site.rb
geordi-1.1.0 lib/geordi/commands/apache_site.rb
geordi-1.0.3 lib/geordi/commands/apache_site.rb
geordi-1.0.2 lib/geordi/commands/apache_site.rb
geordi-1.0.1 lib/geordi/commands/apache_site.rb
geordi-1.0.0 lib/geordi/commands/apache_site.rb