Module: Y2Remote::Modes::SocketBased

Included in:
VNC, Web
Defined in:
src/lib/y2remote/modes/socket_based.rb

Overview

Common methods for handling systemd sockets

Instance Method Summary collapse

Instance Method Details

#disable!Boolean

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

not disabled; true if disabled with success

Returns:

  • (Boolean)

    return false if the systemd socket is not present or



77
78
79
80
81
82
83
84
85
86
87
88
# File 'src/lib/y2remote/modes/socket_based.rb', line 77

def disable!
  return false unless socket

  if enabled? && !socket.disable
    Yast::Report.Error(
      format(_("Disabling systemd socket %{socket} has failed"), socket: socket_name)
    )
    return false
  end

  true
end

#enable!Boolean

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

not enabled; true if enabled with success

Returns:

  • (Boolean)

    return false if the systemd socket is not present or



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

def enable!
  return false unless socket

  if !socket.enable
    Yast::Report.Error(
      format(_("Enabling systemd socket %{socket} has failed"), socket: socket_name)
    )
    return false
  end

  true
end

#enabled?Boolean

Convenience method which return whether the socket is enabled or not

Returns:

  • (Boolean)

    true if the socket is enabled; false otherwise



48
49
50
51
52
# File 'src/lib/y2remote/modes/socket_based.rb', line 48

def enabled?
  return false unless socket

  socket.enabled?
end

#restart!Boolean

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

not restarted; true if restarted with success

Returns:

  • (Boolean)

    return false if the systemd socket is not present or



113
114
115
116
117
118
119
120
121
122
123
124
# File 'src/lib/y2remote/modes/socket_based.rb', line 113

def restart!
  return false unless socket && stop!

  if !socket.start
    Yast::Report.Error(
      format(_("Restarting systemd socket %{socket} has failed"), socket: socket_name)
    )
    return false
  end

  true
end

#socketYast2::Systemd::Socket?

Obtain the systemd socket itself

Returns:

  • (Yast2::Systemd::Socket, nil)


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

def socket
  Yast2::Systemd::Socket.find(socket_name)
end

#socket_nameObject

Name of the socket to be managed



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

def socket_name
  raise "Not implemented yet"
end

#stop!Boolean

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

not stopped; true if stopped with success

Returns:

  • (Boolean)

    return false if the systemd socket is not present or



95
96
97
98
99
100
101
102
103
104
105
106
# File 'src/lib/y2remote/modes/socket_based.rb', line 95

def stop!
  return false unless socket

  if !socket.stop
    Yast::Report.Error(
      format(_("Stopping systemd socket %{socket} has failed"), socket: socket_name)
    )
    return false
  end

  true
end