Module: ApacheHelper
- Defined in:
- lib/apacheconf.rb
Constant Summary collapse
- DEFAULT_APACHE =
'/etc/apache2'
Instance Method Summary collapse
-
#disable(config) ⇒ Object
Disable the vhost (run with –disable or –off flag).
-
#enable(config) ⇒ Object
Enable the vhost (run with the –enable or –on flag).
- #error(message) ⇒ Object
-
#file(file) ⇒ Object
Great way to solve the problem of different file paths.
-
#get_out_file(config) ⇒ Object
Get the file where apache will write the vhost configuration.
-
#reload_apache ⇒ Object
This reloads apache assuming that this script exists for controlling it!.
Instance Method Details
#disable(config) ⇒ Object
Disable the vhost (run with –disable or –off flag)
27 28 29 30 |
# File 'lib/apacheconf.rb', line 27 def disable(config) config['apache_dir'] ||= DEFAULT_APACHE `sudo rm #{config['apache_dir']}/sites-enabled/#{config['site_name']}` end |
#enable(config) ⇒ Object
Enable the vhost (run with the –enable or –on flag)
21 22 23 24 |
# File 'lib/apacheconf.rb', line 21 def enable(config) config['apache_dir'] ||= DEFAULT_APACHE `sudo ln -s #{config['apache_dir']}/sites-available/#{config['site_name']} #{config['apache_dir']}/sites-enabled/#{config['site_name']}` end |
#error(message) ⇒ Object
9 |
# File 'lib/apacheconf.rb', line 9 def error() puts() || exit end |
#file(file) ⇒ Object
Great way to solve the problem of different file paths.
12 |
# File 'lib/apacheconf.rb', line 12 def file(file) "#{File.dirname(__FILE__)}/#{file}" end |
#get_out_file(config) ⇒ Object
Get the file where apache will write the vhost configuration.
15 16 17 18 |
# File 'lib/apacheconf.rb', line 15 def get_out_file(config) config['apache_dir'] ||= DEFAULT_APACHE "#{config['apache_dir']}/sites-available/#{config['site_name']}" end |
#reload_apache ⇒ Object
This reloads apache assuming that this script exists for controlling it!
34 35 36 |
# File 'lib/apacheconf.rb', line 34 def reload_apache `sudo /etc/init.d/apache2 reload` end |