Fix `service network restart` on RHEL-7 / Fedora
RHEL-7 / Current Fedora versions tend to use NetworkManager for configuring the networks, and `service network restart` might fail. If the `NetworkManager` service is running, we should restart it, otherwise we try restarting `network`.
This commit is contained in:
parent
f37b0c26e8
commit
166d10d4e1
|
@ -31,8 +31,12 @@ module VagrantPlugins
|
||||||
sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
|
sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
|
||||||
}
|
}
|
||||||
|
|
||||||
# Restart network
|
# Restart network (through NetworkManager if running)
|
||||||
service network restart
|
if service NetworkManager status 2>&1 | grep -q running; then
|
||||||
|
service NetworkManager restart
|
||||||
|
else
|
||||||
|
service network restart
|
||||||
|
fi
|
||||||
EOH
|
EOH
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,7 +36,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
# Add the new interface and bring it back up
|
# Add the new interface and bring it back up
|
||||||
final_path = "#{network_scripts_dir}/ifcfg-#{network[:device]}"
|
final_path = "#{network_scripts_dir}/ifcfg-#{network[:device]}"
|
||||||
commands << <<-EOH.gsub(/^ */, '')
|
commands << <<-EOH.gsub(/^ {14}/, '')
|
||||||
# Down the interface before munging the config file. This might
|
# Down the interface before munging the config file. This might
|
||||||
# fail if the interface is not actually set up yet so ignore
|
# fail if the interface is not actually set up yet so ignore
|
||||||
# errors.
|
# errors.
|
||||||
|
@ -48,9 +48,13 @@ module VagrantPlugins
|
||||||
EOH
|
EOH
|
||||||
end
|
end
|
||||||
|
|
||||||
commands << <<-EOH.gsub(/^ */, '')
|
commands << <<-EOH.gsub(/^ {12}/, '')
|
||||||
# Restart network
|
# Restart network (through NetworkManager if running)
|
||||||
service network restart
|
if service NetworkManager status 2>&1 | grep -q running; then
|
||||||
|
service NetworkManager restart
|
||||||
|
else
|
||||||
|
service network restart
|
||||||
|
fi
|
||||||
EOH
|
EOH
|
||||||
|
|
||||||
comm.sudo(commands.join("\n"))
|
comm.sudo(commands.join("\n"))
|
||||||
|
|
Loading…
Reference in New Issue