#!/bin/sh -ex

# debian cloud images comes pre-loaded with C.UTF-8 and cloud-init fails to
# process en_US.UTF-8 (for unclear reasons)

# Re-invoke as root if needed
if [ $(id -u) -ne "0" ]; then
   exec sudo $0 $*
fi

# All locales are commented out in /etc/locale.gen, appending is the easiest
# quick and dirty way

echo "{vm.locale} {vm.locale.encoding}" >>/etc/locale.gen
locale-gen
update-locale --locale-file=/etc/default/locale LANG={vm.locale}
