1
0

dev-set-up-environment.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env bash
  2. if [[ ! -d "/vagrant" ]]; then
  3. echo "This script should be run in the Vagrant environment"
  4. exit 1
  5. fi
  6. if [[ $EUID -ne 0 ]]; then
  7. echo "This script should be run as root"
  8. exit 1
  9. fi
  10. source "/vagrant/devtools/dev-fixtures.sh"
  11. # create our test users
  12. if id -u $FIXED_USER &>/dev/null; then
  13. echo "Normal user already exists"
  14. else
  15. echo "Creating normal user"
  16. useradd $FIXED_USER
  17. fi
  18. if id -u $FIXED_LONG_USER &>/dev/null; then
  19. echo "Long user already exists"
  20. else
  21. echo "Creating long user"
  22. useradd $FIXED_LONG_USER
  23. fi
  24. # locale generation
  25. # remove most of this file, it slows down locale-gen
  26. if grep -F -q "en_GB.UTF-8 UTF-8" /var/lib/locales/supported.d/en; then
  27. echo "Removing existing locales"
  28. echo "en_US.UTF-8 UTF-8" > /var/lib/locales/supported.d/en
  29. fi
  30. # uncomment these from the config file
  31. if grep -F -q "# fr_FR.UTF-8" /etc/locale.gen; then
  32. sed -i '/fr_FR.UTF-8/s/^# //g' /etc/locale.gen
  33. fi
  34. if grep -F -q "# ja_JP.UTF-8" /etc/locale.gen; then
  35. sed -i '/ja_JP.UTF-8/s/^# //g' /etc/locale.gen
  36. fi
  37. # only regenerate locales if the config files are newer than the locale archive
  38. if [[ ( /var/lib/locales/supported.d/en -nt /usr/lib/locale/locale-archive ) || \
  39. ( /etc/locale_gen -nt /usr/lib/locale/locale-archive ) ]]; then
  40. locale-gen
  41. else
  42. echo "Locales already generated"
  43. fi