Module: Kanrisuru::Nginx::Package

Extended by:
OsPackage::Define
Defined in:
lib/kanrisuru/nginx/package.rb

Instance Method Summary collapse

Instance Method Details

#apt_installObject



61
62
63
# File 'lib/kanrisuru/nginx/package.rb', line 61

def apt_install
  @host.apt('install', packages: ['nginx'])
end

#apt_installed?Boolean

Returns:

  • (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_removeObject



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_updateObject



73
74
75
# File 'lib/kanrisuru/nginx/package.rb', line 73

def apt_update
  @host.apt('update')
end

#versionObject



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_installObject



65
66
67
# File 'lib/kanrisuru/nginx/package.rb', line 65

def yum_install
  @host.yum('install', packages: ['nginx'])
end

#yum_installed?Boolean

Returns:

  • (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_removeObject



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_updateObject



77
78
79
# File 'lib/kanrisuru/nginx/package.rb', line 77

def yum_update
  @host.yum('update')
end

#zypper_installObject



69
70
71
# File 'lib/kanrisuru/nginx/package.rb', line 69

def zypper_install
  @host.zypper('install', packages: ['nginx'])
end

#zypper_installed?Boolean

Returns:

  • (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_removeObject



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_updateObject



81
82
83
# File 'lib/kanrisuru/nginx/package.rb', line 81

def zypper_update
  @host.zypper('update')
end