mirror of
https://github.com/nix-community/home-manager
synced 2024-11-16 08:09:45 +01:00
systemd: escape unit names in systemctl commands
This commit is contained in:
parent
c5f35b7ff9
commit
0d246aa435
1 changed files with 5 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
||||||
require 'set'
|
require 'set'
|
||||||
require 'open3'
|
require 'open3'
|
||||||
|
require 'shellwords'
|
||||||
|
|
||||||
@dry_run = ENV['DRY_RUN']
|
@dry_run = ENV['DRY_RUN']
|
||||||
@verbose = ENV['VERBOSE']
|
@verbose = ENV['VERBOSE']
|
||||||
|
@ -143,14 +144,15 @@ end
|
||||||
def get_units_by_activity(units, active)
|
def get_units_by_activity(units, active)
|
||||||
return [] if units.empty?
|
return [] if units.empty?
|
||||||
units = units.to_a
|
units = units.to_a
|
||||||
is_active = `systemctl --user is-active #{units.join(' ')}`.split
|
is_active = `systemctl --user is-active #{units.shelljoin}`.split
|
||||||
units.select.with_index do |_, i|
|
units.select.with_index do |_, i|
|
||||||
(is_active[i] == 'active') == active
|
(is_active[i] == 'active') == active
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_restricted_units(units)
|
def get_restricted_units(units)
|
||||||
infos = `systemctl --user show -p RefuseManualStart -p RefuseManualStop #{units.to_a.join(' ')}`
|
units = units.to_a
|
||||||
|
infos = `systemctl --user show -p RefuseManualStart -p RefuseManualStop #{units.shelljoin}`
|
||||||
.split("\n\n")
|
.split("\n\n")
|
||||||
no_manual_start = []
|
no_manual_start = []
|
||||||
no_manual_stop = []
|
no_manual_stop = []
|
||||||
|
@ -173,7 +175,7 @@ end
|
||||||
def show_failed_services_status(services)
|
def show_failed_services_status(services)
|
||||||
puts
|
puts
|
||||||
services.each do |service|
|
services.each do |service|
|
||||||
run_cmd("systemctl --user status #{service}")
|
run_cmd("systemctl --user status #{service.shellescape}")
|
||||||
puts
|
puts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue