guests/debian: Exit on error when configuring hostname

This commit is contained in:
Seth Vargo 2016-06-24 21:18:04 -04:00
parent 9134172ce6
commit 7a7256b3ab
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
1 changed files with 8 additions and 6 deletions

View File

@ -12,6 +12,8 @@ module VagrantPlugins
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
basename = name.split(".", 2)[0]
comm.sudo <<-EOH.gsub(/^ {14}/, '')
set -e
# Set the hostname
echo '#{basename}' > /etc/hostname
hostname -F /etc/hostname
@ -28,16 +30,16 @@ module VagrantPlugins
echo '#{name}' > /etc/mailname
# Restart networking and force new DHCP
if [ test -f /etc/init.d/hostname.sh ]; then
invoke-rc.d hostname.sh start
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
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
if test -f /etc/init.d/network-manager; then
invoke-rc.d network-manager force-reload || true
fi
EOH
end