Module: Y2Remote::Modes::SocketBased
Overview
Common methods for handling systemd sockets
Instance Method Summary collapse
-
#disable! ⇒ Boolean
Convenience method to disable the systemd socket reporting an error in case of failure.
-
#enable! ⇒ Boolean
Convenience method to enable the systemd socket reporting an error in case of failure.
-
#enabled? ⇒ Boolean
Convenience method which return whether the socket is enabled or not.
-
#restart! ⇒ Boolean
Convenience method to restart the systemd socket reporting an error in case of failure.
-
#socket ⇒ Yast2::Systemd::Socket?
Obtain the systemd socket itself.
-
#socket_name ⇒ Object
Name of the socket to be managed.
-
#stop! ⇒ Boolean
Convenience method to stop the systemd socket reporting an error in case of failure.
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
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
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
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
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 |
#socket ⇒ Yast2::Systemd::Socket?
Obtain the systemd socket itself
41 42 43 |
# File 'src/lib/y2remote/modes/socket_based.rb', line 41 def socket Yast2::Systemd::Socket.find(socket_name) end |
#socket_name ⇒ Object
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
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 |