guests/debian: Do not restart networking
Restarting networking causes Vagrant to disconnect and fail.
This commit is contained in:
parent
d1a071d403
commit
c4a0a86ee0
|
@ -2,22 +2,23 @@ module VagrantPlugins
|
|||
module GuestDebian
|
||||
module Cap
|
||||
class ChangeHostName
|
||||
# For more information, please see:
|
||||
#
|
||||
# https://wiki.debian.org/HowTo/ChangeHostname
|
||||
#
|
||||
def self.change_host_name(machine, name)
|
||||
comm = machine.communicate
|
||||
|
||||
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
||||
basename = name.split(".", 2)[0]
|
||||
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
||||
# Ensure exit on command error
|
||||
set -e
|
||||
|
||||
# Set the hostname
|
||||
echo '#{basename}' > /etc/hostname
|
||||
hostname -F /etc/hostname
|
||||
|
||||
if command -v hostnamectl; then
|
||||
hostnamectl set-hostname '#{basename}'
|
||||
fi
|
||||
|
||||
# Remove comments and blank lines from /etc/hosts
|
||||
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
|
||||
|
||||
|
@ -29,17 +30,13 @@ module VagrantPlugins
|
|||
# Update mailname
|
||||
echo '#{name}' > /etc/mailname
|
||||
|
||||
# Restart networking and force new DHCP
|
||||
# Restart hostname services
|
||||
if test -f /etc/init.d/hostname; then
|
||||
/etc/init.d/hostname start || true
|
||||
fi
|
||||
|
||||
if test -f /etc/init.d/hostname.sh; then
|
||||
invoke-rc.d hostname.sh start || true
|
||||
fi
|
||||
|
||||
if test -f /etc/init.d/networking; then
|
||||
invoke-rc.d networking force-reload || true
|
||||
fi
|
||||
|
||||
if test -f /etc/init.d/network-manager; then
|
||||
invoke-rc.d network-manager force-reload || true
|
||||
/etc/init.d/hostname.sh start || true
|
||||
fi
|
||||
EOH
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue