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.

61 lines
1.5 KiB

2 months ago
  1. #!/bin/bash
  2. MANDATORY_PACKAGES_STRING="nginx php-fpm php-mysql php-zip php-gd php-xml php-ldap php-imap composer mariadb-client"
  3. ### CHECK
  4. function check() {
  5. PREFIX="recipe:limesurvey:check"
  6. check_mandatory_packages || return 21
  7. check_limesurvey_zip || return 22
  8. return 0
  9. }
  10. function check_mandatory_packages() {
  11. lxc exec "$CONTAINER" -- bash <<EOF
  12. set -Eeuo pipefail
  13. mapfile -t PACKAGES <<< "$MANDATORY_PACKAGES_STRING"
  14. for package in \${PACKAGES[@]}; do
  15. dpkg -l "\$package" 2>/dev/null | grep -q ^ii
  16. done
  17. EOF
  18. }
  19. function check_limesurvey_zip() {
  20. lxc exec "$CONTAINER" -- test -f /var/www/limesurvey-latest.zip
  21. }
  22. ### INSTALL
  23. function install() {
  24. PREFIX="recipe:limesurvey:install"
  25. : $PREFIX
  26. launch_container "$CONTAINER"
  27. echo "initializing limesurvey ... "
  28. lxc exec "$CONTAINER" -- bash <<EOF
  29. set -Eeuo pipefail
  30. echo installing limesurvey...
  31. apt-get install -y $MANDATORY_PACKAGES_STRING
  32. rm -f /etc/nginx/sites-enabled/default
  33. rm -f /etc/nginx/sites-available/default
  34. systemctl reload nginx
  35. latest_release=\$(curl -s https://community.limesurvey.org/downloads/ | grep 'https://download.limesurvey.org/latest-master/.*\.zip' -o)
  36. wget "\$latest_release" -qO /var/www/limesurvey-latest.zip
  37. mkdir -p /var/www/limesurvey
  38. EOF
  39. echo "OK"
  40. }
  41. ### MAIN
  42. . "$MIAOU_BASEDIR/lib/init.sh"
  43. arg1_required "$@"
  44. readonly CONTAINER="$1"
  45. check || (
  46. install
  47. check
  48. )