Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdavid committed Aug 10, 2018
1 parent 671d2f5 commit b141f7a
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 42 deletions.
87 changes: 59 additions & 28 deletions src/include/samba-server/complex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,37 +63,68 @@ def ProgressStatus
end

# Write settings dialog
# @return `abort if aborted and `next otherwise
#
# @return [Symbol] :next if service is saved successfully
# :abort otherwise
def WriteDialog
Wizard.RestoreHelp(Ops.get_string(@HELPS, "write", ""))
# Bugzilla #120080 - 'reload' instead of 'restart'
# If there some connected users, SAMBA is running and should be running also after the Write() operation
# and the Progress was turned on before Writing SAMBA conf
connected_users = SambaService.ConnectedUsers
Builtins.y2milestone(
"Number of connected users: %1",
Builtins.size(connected_users)
)
report_restart_popup = Ops.greater_than(Builtins.size(connected_users), 0) &&
SambaService.GetServiceRunning &&
SambaService.GetServiceAutoStart &&
ProgressStatus()

ret = SambaServer.Write(false)

# If popup should be shown and SAMBA is still/again running
if report_restart_popup && SambaService.GetServiceRunning
# TRANSLATORS: a popup message
Report.Message(
_(
"Because users are currently connected to this Samba server,\n" +
"the server configuration has been reloaded instead of restarted.\n" +
"To confirm that all settings are applied despite possibly disconnecting the users,\n" +
"run 'systemctl restart smb' and 'systemctl restart nmb'"
)
)

ProgressStatus() if switch_to_reload?

return :abort unless save_status

show_not_restarted_message

:next
end

def save_status
if Mode.auto || Mode.commandline
# Replacemnet of action from restart to reload, if needed, is performed
# at {SambaConfig#Write} which is a module of SambaClient
SambaServer.Write(false)
else
services.restart if switch_to_reload?
services.save
end
ret ? :next : :abort
end

def service_running?
if Mode.auto || Mode.commandline
SambaService.GetServiceRunning
else
services.currently_active?
end
end

def switch_to_reload?
@switch_to_reload ||=
begin
if Mode.auto || Mode.commandline
service_running? && connected_users? && SambaService.GetServiceAutoStart
else
services.action == :restart && services.currently_active? && connected_users?
end
end
end

def connected_users?
@connnected_users ||= SambaService.ConnectedUsers.count > 0
true
end

def show_not_restarted_message
return unless switch_to_reload? && service_running?

# TRANSLATORS: a popup message
Report.Message(
_(
"Because users are currently connected to this Samba server,\n" +
"the server configuration has been reloaded instead of restarted.\n" +
"To confirm that all settings are applied despite possibly disconnecting the users,\n" +
"run 'systemctl restart smb' and 'systemctl restart nmb'"
)
)
end
end
end
34 changes: 20 additions & 14 deletions src/include/samba-server/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,25 @@
# Lukas Ocilka <locilka@suse.cz>
#
# $Id$

require "cwm/service_widget"
require "yast2/system_service"
require "yast2/compound_service"

module Yast
module SambaServerDialogsInclude

def service_widget
@service_widget ||= ::CWM::ServiceWidget.new(services)
end

def services
@services ||= Yast2::CompoundService.new(
Yast2::SystemService.find("nmb"),
Yast2::SystemService.find("smb")
)
end

def initialize_samba_server_dialogs(include_target)
Yast.import "UI"

Expand Down Expand Up @@ -1167,15 +1184,15 @@ def Installation_Conf_Tab
100,
VBox(
VSpacing(1),
"SERVICE START",
"service_widget",
VSpacing(1),
"FIREWALL",
VStretch()
)
),
HWeight(2, Empty())
),
"widget_names" => ["SERVICE START", "FIREWALL"]
"widget_names" => ["service_widget", "FIREWALL"]
},
"shares" => {
"header" => _("&Shares"),
Expand Down Expand Up @@ -1267,18 +1284,7 @@ def Installation_Conf_Tab
)

tabs_widget_descr = {
"SERVICE START" => CWMServiceStart.CreateAutoStartWidget(
{
"get_service_auto_start" => fun_ref(
SambaService.method(:GetServiceAutoStart),
"boolean ()"
),
"set_service_auto_start" => fun_ref(
SambaService.method(:SetServiceAutoStart),
"void (boolean)"
)
}
),
"service_widget" => service_widget.cwm_definition,
# BNC #247344, BNC #541958 (comment #18)
"FIREWALL" => CWMFirewallInterfaces.CreateOpenFirewallWidget(
{
Expand Down

0 comments on commit b141f7a

Please sign in to comment.