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

Returns:

  • (Boolean)

    return false if the service is not installed or not



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

def disable!
  return false unless installed?

  textdomain "network"
  if !Yast::Service.Disable(SERVICE)
    Yast::Report.Error(
      format(_("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

Returns:

  • (Boolean)

    return false if the service is not installed or not



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

def enable!
  return false unless installed?

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

  true
end

#enabled?Boolean

Convenience method with return whether the service is enabled

Returns:

  • (Boolean)

    true if the service is enabled; false otherwise



41
42
43
# File 'src/lib/y2remote/modes/manager.rb', line 41

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

#required_packagesArray<String>

Return the list of the packages needed by the service

Returns:

  • (Array<String>)

    list of required packages



34
35
36
# File 'src/lib/y2remote/modes/manager.rb', line 34

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

Returns:

  • (Boolean)

    return false if the service is not installed or not



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

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

Returns:

  • (Boolean)

    return false if the service is not installed or not



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

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

Returns:

  • (Boolean)

    return false if the service is not installed or not



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

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

Returns:

  • (Boolean)

    return false if the service is not installed or not



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

def stop!
  return false unless installed?

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

  true
end