provisioning tool for building opinionated architecture
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.4 KiB

8 months ago
8 months ago
  1. #!/bin/bash
  2. MANDATORY_PACKAGES_STRING="nginx php-fpm postgresql-client php-pgsql php-intl php-curl php-gd php-zip php-imap php-xml php-mbstring"
  3. function check() {
  4. PREFIX="recipe:dolibarr:check"
  5. : $PREFIX
  6. check_mandatory_packages || return 11
  7. check_one_release || return 12
  8. echo "container <$CONTAINER> approved successfully!"
  9. return 0
  10. }
  11. function check_mandatory_packages() {
  12. lxc exec "$CONTAINER" -- bash <<EOF
  13. set -Eeuo pipefail
  14. mapfile -t PACKAGES <<< "$MANDATORY_PACKAGES_STRING"
  15. for package in \${PACKAGES[@]}; do
  16. dpkg -l "\$package" 2>/dev/null | grep -q ^ii
  17. done
  18. EOF
  19. }
  20. function check_one_release() {
  21. lxc exec "$CONTAINER" -- /TOOLBOX/fd -1q -tf "dolibarr-" /var/www
  22. }
  23. function install() {
  24. echo "recipe:dolibarr installing..."
  25. lxc exec "$CONTAINER" -- bash <<EOF
  26. cloud-init status --wait >/dev/null
  27. apt update
  28. apt install -y $MANDATORY_PACKAGES_STRING
  29. cd /var/www
  30. PATH="\$PATH:/opt/miaou-bash/tools"
  31. VERSION="\$(wget_semver github Dolibarr/dolibarr)"
  32. if [[ ! -f "dolibarr-\$VERSION.tgz" ]]; then
  33. wget_release github Dolibarr/dolibarr
  34. else
  35. echo "dolibarr version=\$VERSION already downloaded!"
  36. fi
  37. EOF
  38. }
  39. . "$MIAOU_BASEDIR/lib/init.sh"
  40. arg1_required "$@"
  41. readonly CONTAINER="$1"
  42. launch_container "$CONTAINER"
  43. check || (
  44. install
  45. check
  46. )