Class: Y2Remote::Modes::Manager

Inherits:
Base
  • Object
show all
Defined in:
src/lib/y2remote/modes/manager.rb

Overview

This class is reponsible of vncmanager service management

Constant Summary collapse

SERVICE =

[String] Service name

"vncmanager".freeze
PACKAGES =

[Array] Packages needed by the service

["vncmanager"].freeze

Instance Method Summary collapse

Methods inherited from Base

#initialize, #installed?

Constructor Details

This class inherits a constructor from Y2Remote::Modes::Base

Instance Method Details

#disable!Boolean

Convenience method to disable the service reporting an error in case of failure. It return false if the service is not installed.

disabled; true if disabled with success


124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'src/lib/y2remote/modes/manager.rb', line 124

def disable!
  return false unless installed?

  textdomain "network"
  if !Yast::Service.Disable(SERVICE)
    Yast::Report.Error(
      _("Disabling service %{service} has failed") % { service: SERVICE }
    )
    return false
  end

  true
end

#enable!Boolean

Convenience method to enable the service reporting an error in case of failure. It return false if the service is not installed.

enabled; true if enabled with success


105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'src/lib/y2remote/modes/manager.rb', line 105

def enable!
  return false unless installed?

  textdomain "network"
  if !Yast::Service.Enable(SERVICE)
    Yast::Report.Error(
      _("Enabling service %{service} has failed") % { service: SERVICE }
    )
    return false
  end

  true
end

#enabled?Boolean

Convenience method with return whether the service is enabled


43
44
45
# File 'src/lib/y2remote/modes/manager.rb', line 43

def enabled?
  Yast::Service.Enabled(SERVICE)
end

#required_packagesArray<String>

Return the list of the packages needed by the service


36
37
38
# File 'src/lib/y2remote/modes/manager.rb', line 36

def required_packages
  PACKAGES
end

#restartBoolean

Convenience method to restart the service. It return false if the service is not installed.

restarted; true if restarted with success


79
80
81
82
# File 'src/lib/y2remote/modes/manager.rb', line 79

def restart
  return false unless installed?
  Yast::Service.Restart(SERVICE)
end

#restart!Boolean

Convenience method to restart the service reporting an error in case of failure. It return false if the service is not installed.

restarted; true if restarted with success


89
90
91
92
93
94
95
96
97
98
# File 'src/lib/y2remote/modes/manager.rb', line 89

def restart!
  return false unless installed?

  if !Yast::Service.Restart(SERVICE)
    Yast::Report.Error(Yast::Message.CannotRestartService(SERVICE))
    return false
  end

  true
end

#stopBoolean

Convenience method to stop the service. It return false if the service is not installed.

stopped; true if stopped with success


52
53
54
55
56
# File 'src/lib/y2remote/modes/manager.rb', line 52

def stop
  return false unless installed?

  Yast::Service.Stop(SERVICE)
end

#stop!Boolean

Convenience method to stop the service reporting an error in case of failure. It return false if the service is not installed.

stopped; true if stopped with success


63
64
65
66
67
68
69
70
71
72
# File 'src/lib/y2remote/modes/manager.rb', line 63

def stop!
  return false unless installed?

  if !Yast::Service.Stop(SERVICE)
    Yast::Report.Error(Yast::Message.CannotStopService(SERVICE))
    return false
  end

  true
end