Class: Avm::EacUbuntuBase0::Apache::Resource
- Inherits:
-
Object
- Object
- Avm::EacUbuntuBase0::Apache::Resource
- Defined in:
- lib/avm/eac_ubuntu_base0/apache/resource.rb
Instance Method Summary collapse
- #available? ⇒ Boolean
- #available_path ⇒ Object
- #disable ⇒ Object
- #enable ⇒ Object
- #enabled? ⇒ Boolean
- #enabled_path ⇒ Object
- #remove ⇒ Object
- #remove_available ⇒ Object
- #remove_disabled ⇒ Object
- #write(content) ⇒ Object
Instance Method Details
#available? ⇒ Boolean
15 16 17 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 15 def available? apache.host_env.file(available_path).exist? end |
#available_path ⇒ Object
11 12 13 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 11 def available_path ::File.join(apache.etc_root, "#{directory_prefix}-available", "#{name}.conf") end |
#disable ⇒ Object
19 20 21 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 19 def disable apache.host_env.command('sudo', "a2dis#{type}", name).execute! end |
#enable ⇒ Object
23 24 25 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 23 def enable apache.host_env.command('sudo', "a2en#{type}", name).execute! end |
#enabled? ⇒ Boolean
31 32 33 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 31 def enabled? apache.host_env.file(enabled_path).exist? end |
#enabled_path ⇒ Object
27 28 29 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 27 def enabled_path ::File.join(apache.etc_root, "#{directory_prefix}-enabled", "#{name}.conf") end |
#remove ⇒ Object
35 36 37 38 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 35 def remove remove_disabled remove_available end |
#remove_available ⇒ Object
40 41 42 43 44 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 40 def remove_available raise 'Remove enabled before' if enabled? apache.host_env.command('sudo', 'rm', '-f', available_path).execute! if available? end |
#remove_disabled ⇒ Object
46 47 48 49 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 46 def remove_disabled disable if enabled? apache.host_env.command('sudo', 'rm', '-f', enabled_path).execute! if enabled? end |
#write(content) ⇒ Object
51 52 53 54 55 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 51 def write(content) ::EacRubyUtils::Envs.local.command('echo', content).pipe( apache.host_env.command('sudo', 'tee', available_path) ).execute! end |