Dan Čermák c4ced5459d
Add fallback for SLE 11 guest machines
SLE 11 does not ship systemd and then using systemctl poweroff does not
work. Therefore we fall back to using /sbin/shutdown for machines without
systemd.
This fixes https://github.com/hashicorp/vagrant/issues/12487
2021-08-06 12:55:32 +02:00

21 lines
591 B
Ruby

module VagrantPlugins
module GuestSUSE
module Cap
class Halt
def self.halt(machine)
begin
if machine.communicate.test("test -e /usr/bin/systemctl")
machine.communicate.sudo("/usr/bin/systemctl poweroff &")
else
machine.communicate.sudo("/sbin/shutdown -h now &")
end
rescue IOError, Vagrant::Errors::SSHDisconnected
# Do nothing, because it probably means the machine shut down
# and SSH connection was lost.
end
end
end
end
end
end