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.

53 lines
1.3 KiB

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