Module: Kanrisuru::Nginx::Package
- Extended by:
- OsPackage::Define
- Defined in:
- lib/kanrisuru/nginx/package.rb
Instance Method Summary collapse
- #apt_install ⇒ Object
- #apt_installed? ⇒ Boolean
- #apt_remove ⇒ Object
- #apt_update ⇒ Object
- #version ⇒ Object
- #yum_install ⇒ Object
- #yum_installed? ⇒ Boolean
- #yum_remove ⇒ Object
- #yum_update ⇒ Object
- #zypper_install ⇒ Object
- #zypper_installed? ⇒ Boolean
- #zypper_remove ⇒ Object
- #zypper_update ⇒ Object
Instance Method Details
#apt_install ⇒ Object
61 62 63 |
# File 'lib/kanrisuru/nginx/package.rb', line 61 def apt_install @host.apt('install', packages: ['nginx']) end |
#apt_installed? ⇒ Boolean
26 27 28 29 30 31 32 |
# File 'lib/kanrisuru/nginx/package.rb', line 26 def apt_installed? result = @host.apt('list', installed: true, packages: ['nginx']) return false if result.failure? package = result.find { |item| item.package == 'nginx' } Kanrisuru::Util.present?(package) && package.installed == true end |
#apt_remove ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/kanrisuru/nginx/package.rb', line 85 def apt_remove if @host.nginx.running? result = @host.nginx.stop return result unless result.success? end @host.apt('purge', packages: %w[nginx nginx-common]) end |
#apt_update ⇒ Object
73 74 75 |
# File 'lib/kanrisuru/nginx/package.rb', line 73 def apt_update @host.apt('update') end |
#version ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/kanrisuru/nginx/package.rb', line 50 def version command = Kanrisuru::Command.new('nginx -v') @host.execute_shell(command) Kanrisuru::Result.new(command) do |cmd| values = cmd.to_s.split('/') values[1].to_f end end |
#yum_install ⇒ Object
65 66 67 |
# File 'lib/kanrisuru/nginx/package.rb', line 65 def yum_install @host.yum('install', packages: ['nginx']) end |
#yum_installed? ⇒ Boolean
34 35 36 37 38 39 40 |
# File 'lib/kanrisuru/nginx/package.rb', line 34 def yum_installed? result = @host.yum('list', installed: true, query: 'nginx') return false if result.failure? package = result.find { |item| item.package == 'nginx' } Kanrisuru::Util.present?(package) end |
#yum_remove ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/kanrisuru/nginx/package.rb', line 94 def yum_remove if @host.nginx.running? result = @host.nginx.stop return result unless result.success? end @host.yum('remove', packages: ['nginx']) end |
#yum_update ⇒ Object
77 78 79 |
# File 'lib/kanrisuru/nginx/package.rb', line 77 def yum_update @host.yum('update') end |
#zypper_install ⇒ Object
69 70 71 |
# File 'lib/kanrisuru/nginx/package.rb', line 69 def zypper_install @host.zypper('install', packages: ['nginx']) end |
#zypper_installed? ⇒ Boolean
42 43 44 45 46 47 48 |
# File 'lib/kanrisuru/nginx/package.rb', line 42 def zypper_installed? result = @host.zypper('info', packages: ['nginx']) return false if result.failure? package = result.find { |item| item.package == 'nginx' } Kanrisuru::Util.present?(package) && package.installed == true end |
#zypper_remove ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/kanrisuru/nginx/package.rb', line 103 def zypper_remove if @host.nginx.running? result = @host.nginx.stop return result unless result.success? end @host.zypper('remove', packages: ['nginx']) end |
#zypper_update ⇒ Object
81 82 83 |
# File 'lib/kanrisuru/nginx/package.rb', line 81 def zypper_update @host.zypper('update') end |