exa/devtools/dev-set-up-environment.sh
Benjamin Sago 93bd052c70 Make Vagrant provisioning quieter and faster
• Install fewer Rust components
• Silence the output of some commands
• Only locale-gen the locales we need, and only do it once

While the 'vagrant up' and 'vagrant provision' times are still very long, and these benchmarks are very variable, there's a noticeable improvement here:

• 'vagrant up' has gone from ~244s to ~223s
• 'vagrant provision' has gone from ~21s to ~7s
2020-10-18 01:19:43 +01:00

56 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
if [[ ! -d "/vagrant" ]]; then
echo "This script should be run in the Vagrant environment"
exit 1
fi
if [[ $EUID -ne 0 ]]; then
echo "This script should be run as root"
exit 1
fi
source "/vagrant/devtools/dev-fixtures.sh"
# create our test users
if id -u $FIXED_USER &>/dev/null; then
echo "Normal user already exists"
else
echo "Creating normal user"
useradd $FIXED_USER
fi
if id -u $FIXED_LONG_USER &>/dev/null; then
echo "Long user already exists"
else
echo "Creating long user"
useradd $FIXED_LONG_USER
fi
# locale generation
# remove most of this file, it slows down locale-gen
if grep -F -q "en_GB.UTF-8 UTF-8" /var/lib/locales/supported.d/en; then
echo "Removing existing locales"
echo "en_US.UTF-8 UTF-8" > /var/lib/locales/supported.d/en
fi
# uncomment these from the config file
if grep -F -q "# fr_FR.UTF-8" /etc/locale.gen; then
sed -i '/fr_FR.UTF-8/s/^# //g' /etc/locale.gen
fi
if grep -F -q "# ja_JP.UTF-8" /etc/locale.gen; then
sed -i '/ja_JP.UTF-8/s/^# //g' /etc/locale.gen
fi
# only regenerate locales if the config files are newer than the locale archive
if [[ ( /var/lib/locales/supported.d/en -nt /usr/lib/locale/locale-archive ) || \
( /etc/locale_gen -nt /usr/lib/locale/locale-archive ) ]]; then
locale-gen
else
echo "Locales already generated"
fi