Module: Y2Remote::Modes::SocketBased
Overview
Common methods for handling systemd sockets
Class Method Summary collapse
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.
Class Method Details
.included(_base) ⇒ Object
27 28 29 30 31 |
# File 'src/lib/y2remote/modes/socket_based.rb', line 27 def self.included(_base) extend Yast::I18n textdomain "network" end |
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
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'src/lib/y2remote/modes/socket_based.rb', line 76 def disable! return false unless socket if enabled? && !socket.disable Yast::Report.Error( _("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
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'src/lib/y2remote/modes/socket_based.rb', line 58 def enable! return false unless socket if !socket.enable Yast::Report.Error( _("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 |
# 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
112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'src/lib/y2remote/modes/socket_based.rb', line 112 def restart! return false unless socket && stop! if !socket.start Yast::Report.Error( _("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
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'src/lib/y2remote/modes/socket_based.rb', line 94 def stop! return false unless socket if !socket.stop Yast::Report.Error( _("Stopping systemd socket %{socket} has failed") % { socket: socket_name } ) return false end true end |