Class: Y2Remote::Remote

Inherits:
Object
  • Object
show all
Includes:
Singleton, Yast::I18n, Yast::Logger
Defined in:
src/lib/y2remote/remote.rb

Constant Summary collapse

GRAPHICAL_TARGET =
"graphical".freeze
FIREWALL_SERVICES =
["tigervnc", "tigervnc-https"].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRemote

Constructor


46
47
48
49
50
51
52
53
# File 'src/lib/y2remote/remote.rb', line 46

def initialize
  import_modules

  textdomain "network"

  @modes = []
  @proposed = false
end

Instance Attribute Details

#modesObject (readonly)

List of Y2Remote::Modes::Base subclasses that are the enabled VNC running modes


38
39
40
# File 'src/lib/y2remote/remote.rb', line 38

def modes
  @modes
end

#proposedObject Also known as: proposed?

[Boolean] whether the configuration has been proposed or not


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

def proposed
  @proposed
end

Instance Method Details

#configure_display_managerBoolean

Updates the VNC and xdm configuration

Called from #write. Ensures that required packages are installed, enables vnc services and xdm and writes the configuration files, reporting any error in the process.


160
161
162
163
164
165
166
167
# File 'src/lib/y2remote/remote.rb', line 160

def configure_display_manager
  if enabled? && !Yast::Package.InstallAll(required_packages)
    log.error "Installing of required packages failed"
    return false
  end
  Y2Remote::Modes.update_status(modes)
  display_manager.write_remote_access(enabled?)
end

#disable!Array<Y2Remote::Mode>

Removes all the running modes


83
84
85
# File 'src/lib/y2remote/remote.rb', line 83

def disable!
  @modes = []
end

#disabled?Boolean

Checks if remote administration is currently disallowed


76
77
78
# File 'src/lib/y2remote/remote.rb', line 76

def disabled?
  modes.empty?
end

#display_managerObject


101
102
103
# File 'src/lib/y2remote/remote.rb', line 101

def display_manager
  @display_manager ||= Y2Remote::DisplayManager.instance
end

#enable!Object

Enables the Y2Remote::Modes::VNC mode


61
62
63
# File 'src/lib/y2remote/remote.rb', line 61

def enable!
  enable_mode!(Y2Remote::Modes::VNC.instance)
end

#enable_manager!Object

Enables the Y2Remote::Modes::Manager mode


66
67
68
# File 'src/lib/y2remote/remote.rb', line 66

def enable_manager!
  enable_mode!(Y2Remote::Modes::Manager.instance)
end

#enable_web!Object

Enables the Y2Remote::Modes::Web mode


71
72
73
# File 'src/lib/y2remote/remote.rb', line 71

def enable_web!
  enable_mode!(Y2Remote::Modes::Web.instance)
end

#enabled?Boolean

Checks if remote administration is currently allowed


56
57
58
# File 'src/lib/y2remote/remote.rb', line 56

def enabled?
  !disabled?
end

#propose!Boolean

Propose the vnc configuration if it has not been proposed yet


145
146
147
148
149
150
151
# File 'src/lib/y2remote/remote.rb', line 145

def propose!
  return false if proposed?

  Yast::Linuxrc.vnc ? enable_vnc! : disable!
  log.info("Remote Administration was proposed as: #{modes.inspect}")
  @proposed = true
end

#readBoolean

Read the current status of vnc and the enabled modes


108
109
110
111
112
113
114
# File 'src/lib/y2remote/remote.rb', line 108

def read
  return true unless display_manager.remote_access?

  @modes = Y2Remote::Modes.running_modes

  true
end

#reset!Object

Reset the proposal configuration enabling vnc if it was enabled by linuxrc


136
137
138
139
140
# File 'src/lib/y2remote/remote.rb', line 136

def reset!
  @proposed = false

  propose!
end

#restart_servicesObject

Restarts services, reporting errors to the user


170
171
172
173
174
175
# File 'src/lib/y2remote/remote.rb', line 170

def restart_services
  Yast2::Systemd::Target.set_default(GRAPHICAL_TARGET) if enabled?
  Y2Remote::Modes.restart_modes(modes)

  display_manager.restart if enabled?
end

#summaryString

Return a summary of the current remote configuration


180
181
182
183
184
# File 'src/lib/y2remote/remote.rb', line 180

def summary
  return _("Remote administration is enabled.") if enabled?

  _("Remote administration is disabled.")
end

#web_enabled?Boolean

Whether some of the VNC running modes is Web or not


90
91
92
# File 'src/lib/y2remote/remote.rb', line 90

def web_enabled?
  modes.include?(Y2Remote::Modes::Web.instance)
end

#with_manager?Boolean

Whether the vnc manager mode is enabled or not


97
98
99
# File 'src/lib/y2remote/remote.rb', line 97

def with_manager?
  modes.include?(Y2Remote::Modes::Manager.instance)
end

#writeBoolean

Update the SCR according to vnc settings


119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'src/lib/y2remote/remote.rb', line 119

def write
  configure_write_steps

  next_stage(_("Configuring display manager..."))
  return false unless configure_display_manager

  if Yast::Mode.normal
    next_stage(_("Restarting the service..."))
    restart_services
    next_stage
  end

  true
end