Class: Y2Remote::DisplayManager
- Inherits:
-
Object
- Object
- Y2Remote::DisplayManager
- Includes:
- Singleton, Yast::I18n, Yast::Logger
- Defined in:
- src/lib/y2remote/display_manager.rb
Overview
Class responsable of handle the display manager configuration for remote access.
Constant Summary collapse
- SERVICE =
Display manager service name
"display-manager".freeze
Instance Method Summary collapse
-
#enabled? ⇒ Boolean
Whether the display manager service is enabled or not.
-
#initialize ⇒ DisplayManager
constructor
Constructor.
-
#remote_access? ⇒ Boolean
Whether the display manager allow remote access or not.
-
#restart ⇒ Object
Restart the display manager service reporting an error in case of failure.
-
#write_remote_access(allowed) ⇒ Object
Write the sysconfig display manager configuration for remote access.
Constructor Details
#initialize ⇒ DisplayManager
Constructor
34 35 36 37 |
# File 'src/lib/y2remote/display_manager.rb', line 34 def initialize Yast.import "Service" textdomain "network" end |
Instance Method Details
#enabled? ⇒ Boolean
Whether the display manager service is enabled or not
42 43 44 |
# File 'src/lib/y2remote/display_manager.rb', line 42 def enabled? Yast::Service.Enabled(SERVICE) end |
#remote_access? ⇒ Boolean
Whether the display manager allow remote access or not. If the service is not enabled it returns false
50 51 52 53 54 |
# File 'src/lib/y2remote/display_manager.rb', line 50 def remote_access? return false unless enabled? Yast::SCR.Read(Yast.path(".sysconfig.displaymanager.DISPLAYMANAGER_REMOTE_ACCESS")) == "yes" end |
#restart ⇒ Object
Restart the display manager service reporting an error in case of failure.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'src/lib/y2remote/display_manager.rb', line 58 def restart if Yast::Service.active?(SERVICE) report_cannot_restart(SERVICE) if !Yast::Service.Reload(SERVICE) Yast::Report.Warning( _( "Your display manager must be restarted.\n" \ "To take the changes in remote administration into account, \n" \ "please restart it manually or log out and log in again." ) ) elsif !Yast::Service.Restart(SERVICE) report_cannot_restart(SERVICE) end end |
#write_remote_access(allowed) ⇒ Object
Write the sysconfig display manager configuration for remote access.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'src/lib/y2remote/display_manager.rb', line 77 def write_remote_access(allowed) # Set DISPLAYMANAGER_REMOTE_ACCESS in sysconfig/displaymanager Yast::SCR.Write( Yast.path(".sysconfig.displaymanager.DISPLAYMANAGER_REMOTE_ACCESS"), allowed ? "yes" : "no" ) Yast::SCR.Write( Yast.path(".sysconfig.displaymanager.DISPLAYMANAGER_ROOT_LOGIN_REMOTE"), allowed ? "yes" : "no" ) Yast::SCR.Write(Yast.path(".sysconfig.displaymanager"), nil) true end |