Sha256: 82c88512d238b8a73369db22d0ef7758067213aaa5dd9c5564e7aa451a8463aa
Contents?: true
Size: 1.66 KB
Versions: 5
Compression:
Stored size: 1.66 KB
Contents
require_relative 'init/openrc' require_relative 'init/systemd' module DanarchyDeploy module Services class Init def self.new(deployment, options) puts "\n" + self.name deployment[:services].each do |service, params| next if ! params[:init] orig_actions = params[:init] puts "\n > Init actions for #{service}: #{params[:init].join(', ')}" params[:init].each do |action| puts " |+ Taking action: #{action} on #{service}" if options[:pretend] puts " Fake run: #{action} #{service}" else init_manager(deployment[:os], service, action, options) end end params[:init] = orig_actions end deployment end def self.init_manager(os, service, action, options) init = if os == 'gentoo' DanarchyDeploy::Services::Init::Openrc.new(service, options) else DanarchyDeploy::Services::Init::Systemd.new(service, options) end init_result = init.send(action) if init_result[:stderr] if init_result[:stderr].include?('unknown function') puts " ! Action: #{action} not available for service: #{service}.\n" + " ! A restart may be needed! Otherwise, remove this action from the deployment.\n" + " ! Not taking any action here.\n" else abort(" ! Action: #{service} #{action} failed!") end else puts " |+ Action: #{service} #{action} succeeded." end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems