gentoo/guest: #8406 support systemd when changing hostname

This commit is contained in:
Simon Detheridge 2017-03-24 11:55:44 +00:00
parent f807e5a8be
commit e06848a649
1 changed files with 8 additions and 2 deletions

View File

@ -9,8 +9,14 @@ module VagrantPlugins
basename = name.split(".", 2)[0]
comm.sudo <<-EOH.gsub(/^ {14}/, "")
# Set the hostname
hostname '#{basename}'
echo "hostname=#{basename}" > /etc/conf.d/hostname
# Use hostnamectl on systemd
if [[ `systemctl` =~ -\.mount ]]; then
systemctl set-hostname '#{name}'
else
hostname '#{basename}'
echo "hostname=#{basename}" > /etc/conf.d/hostname
fi
# Remove comments and blank lines from /etc/hosts
sed -i'' -e 's/#.*$//' /etc/hosts