Skip to content

Commit

Permalink
Fix service discovery during installation; improve deprecation log me…
Browse files Browse the repository at this point in the history
…ssage
  • Loading branch information
Vladimir Moravec committed Apr 16, 2014
1 parent 8d6442d commit a971e8e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion library/runlevel/src/modules/Service.rb
Expand Up @@ -412,7 +412,7 @@ def failure event, service_name, error=""


def deprecate message
log.warn "[DEPRECIATION] #{caller[0].split.last} is deprecated; #{message}"
log.warn "[DEPRECIATION] #{caller[0].split.last} in \"#{caller[1]}\" is deprecated; #{message}"
end

publish :function => :GetUnitId, :type => "string (string)"
Expand Down
14 changes: 12 additions & 2 deletions library/systemd/src/lib/yast2/systemd_unit.rb
Expand Up @@ -200,19 +200,29 @@ class InstallationProperties < OpenStruct
def initialize systemd_unit
super()
self[:systemd_unit] = systemd_unit
status = get_status
self[:status] = get_status
self[:raw] = status.stdout
self[:error] = status.stderr
self[:exit] = status.exit
self[:enabled?] = status.exit.zero?
self[:not_found?] = status.stderr.empty? ? false : true
self[:not_found?] = service_missing?
end

private

def get_status
systemd_unit.command("is-enabled")
end

# Analyze the exit code and stdout of the command `systemctl is-enabled service_name`
def service_missing?
# the service exists and it's enabled
return false if status.exit.zero?
# the service exists and it's disabled
return false if status.exit.nonzero? && status.stdout.strip.match(/\Adisabled$/)
# for all other cases the service does not exist
true
end
end
end
end

0 comments on commit a971e8e

Please sign in to comment.