Skip to content

Instantly share code, notes, and snippets.

@zsim0n
Created June 1, 2014 09:25
Show Gist options
  • Save zsim0n/ba1a25e87e81e9eb04a5 to your computer and use it in GitHub Desktop.
Save zsim0n/ba1a25e87e81e9eb04a5 to your computer and use it in GitHub Desktop.
Provision timezone in vagrant
config.vm.provision :shell, :inline => "echo \"Europe/Copenhagen\" | sudo tee /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata"
Source: http://www.jaimegago.com/dynamic-guestrhel6-and-cousinshostos-x-time-zone-sync-in-vagrant-virtualbox-provider/
$script = <<SCRIPT
CurrentTimeZone=$(cat /etc/sysconfig/clock |cut -d'=' -f'2')
if [ ! $CurrentTimeZone == $1 ];then
cat << EOF > /etc/sysconfig/clock
ZONE=$1
EOF
ln -sf /usr/share/zoneinfo/$1 /etc/localtime
fi
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment