Class: Y2Remote::DisplayManager

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeDisplayManager

Constructor


36
37
38
39
# File 'src/lib/y2remote/display_manager.rb', line 36

def initialize
  Yast.import "Service"
  textdomain "network"
end

Instance Method Details

#enabled?Boolean

Whether the display manager service is enabled or not


44
45
46
# File 'src/lib/y2remote/display_manager.rb', line 44

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


52
53
54
55
56
# File 'src/lib/y2remote/display_manager.rb', line 52

def remote_access?
  return false unless enabled?

  Yast::SCR.Read(Yast.path(".sysconfig.displaymanager.DISPLAYMANAGER_REMOTE_ACCESS")) == "yes"
end

#restartObject

Restart the display manager service reporting an error in case of failure.


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'src/lib/y2remote/display_manager.rb', line 60

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.


79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'src/lib/y2remote/display_manager.rb', line 79

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