Better Ubuntu systemd detection
Check the running process at PID 1 to determine which init system is currently in use.
This commit is contained in:
parent
3b7117b689
commit
c7186236f1
|
@ -7,7 +7,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_etc_hostname
|
def update_etc_hostname
|
||||||
return super unless vivid?
|
return super unless systemd?
|
||||||
sudo("hostnamectl set-hostname '#{short_hostname}'")
|
sudo("hostnamectl set-hostname '#{short_hostname}'")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ module VagrantPlugins
|
||||||
if hardy?
|
if hardy?
|
||||||
# hostname.sh returns 1, so use `true` to get a 0 exitcode
|
# hostname.sh returns 1, so use `true` to get a 0 exitcode
|
||||||
sudo("/etc/init.d/hostname.sh start; true")
|
sudo("/etc/init.d/hostname.sh start; true")
|
||||||
elsif vivid?
|
elsif systemd?
|
||||||
# Service runs via hostnamectl
|
# Service runs via hostnamectl
|
||||||
else
|
else
|
||||||
sudo("service hostname start")
|
sudo("service hostname start")
|
||||||
|
@ -26,19 +26,25 @@ module VagrantPlugins
|
||||||
os_version("hardy")
|
os_version("hardy")
|
||||||
end
|
end
|
||||||
|
|
||||||
def vivid?
|
|
||||||
os_version("vivid")
|
|
||||||
end
|
|
||||||
|
|
||||||
def renew_dhcp
|
def renew_dhcp
|
||||||
sudo("ifdown -a; ifup -a; ifup -a --allow=hotplug")
|
sudo("ifdown -a; ifup -a; ifup -a --allow=hotplug")
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def init_package
|
||||||
|
machine.communicate.execute('cat /proc/1/comm') do |type, data|
|
||||||
|
return data.chomp if type == :stdout
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def os_version(name)
|
def os_version(name)
|
||||||
machine.communicate.test("[ `lsb_release -c -s` = #{name} ]")
|
machine.communicate.test("[ `lsb_release -c -s` = #{name} ]")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def systemd?
|
||||||
|
init_package == 'systemd'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue