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
13 14 15 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 13 def available? apache.host_env.file(available_path).exist? end |
#available_path ⇒ Object
9 10 11 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 9 def available_path ::File.join(apache.etc_root, "#{directory_prefix}-available", "#{name}.conf") end |
#disable ⇒ Object
17 18 19 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 17 def disable apache.host_env.command('sudo', "a2dis#{type}", name).execute! end |
#enable ⇒ Object
21 22 23 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 21 def enable apache.host_env.command('sudo', "a2en#{type}", name).execute! end |
#enabled? ⇒ Boolean
29 30 31 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 29 def enabled? apache.host_env.file(enabled_path).exist? end |
#enabled_path ⇒ Object
25 26 27 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 25 def enabled_path ::File.join(apache.etc_root, "#{directory_prefix}-enabled", "#{name}.conf") end |
#remove ⇒ Object
33 34 35 36 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 33 def remove remove_disabled remove_available end |
#remove_available ⇒ Object
38 39 40 41 42 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 38 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
44 45 46 47 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 44 def remove_disabled disable if enabled? apache.host_env.command('sudo', 'rm', '-f', enabled_path).execute! if enabled? end |
#write(content) ⇒ Object
49 50 51 52 53 |
# File 'lib/avm/eac_ubuntu_base0/apache/resource.rb', line 49 def write(content) ::EacRubyUtils::Envs.local.command('echo', content).pipe( apache.host_env.command('sudo', 'tee', available_path) ).execute! end |