From 7a7256b3abb022f0da57b2945989e7f0dd20c733 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Fri, 24 Jun 2016 21:18:04 -0400 Subject: [PATCH] guests/debian: Exit on error when configuring hostname --- plugins/guests/debian/cap/change_host_name.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/guests/debian/cap/change_host_name.rb b/plugins/guests/debian/cap/change_host_name.rb index b2e972cac..7d34c7b90 100644 --- a/plugins/guests/debian/cap/change_host_name.rb +++ b/plugins/guests/debian/cap/change_host_name.rb @@ -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