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
61 lines
1.5 KiB
#!/bin/bash
|
|
|
|
MANDATORY_PACKAGES_STRING="nginx php-fpm php-mysql php-zip php-gd php-xml php-ldap php-imap composer mariadb-client"
|
|
|
|
### CHECK
|
|
|
|
function check() {
|
|
PREFIX="recipe:limesurvey:check"
|
|
check_mandatory_packages || return 21
|
|
check_limesurvey_zip || return 22
|
|
return 0
|
|
}
|
|
|
|
function check_mandatory_packages() {
|
|
lxc exec "$CONTAINER" -- bash <<EOF
|
|
set -Eeuo pipefail
|
|
mapfile -t PACKAGES <<< "$MANDATORY_PACKAGES_STRING"
|
|
for package in \${PACKAGES[@]}; do
|
|
dpkg -l "\$package" 2>/dev/null | grep -q ^ii
|
|
done
|
|
EOF
|
|
}
|
|
|
|
function check_limesurvey_zip() {
|
|
lxc exec "$CONTAINER" -- test -f /var/www/limesurvey-latest.zip
|
|
}
|
|
|
|
### INSTALL
|
|
|
|
function install() {
|
|
PREFIX="recipe:limesurvey:install"
|
|
: $PREFIX
|
|
launch_container "$CONTAINER"
|
|
echo "initializing limesurvey ... "
|
|
|
|
lxc exec "$CONTAINER" -- bash <<EOF
|
|
set -Eeuo pipefail
|
|
echo installing limesurvey...
|
|
apt-get install -y $MANDATORY_PACKAGES_STRING
|
|
rm -f /etc/nginx/sites-enabled/default
|
|
rm -f /etc/nginx/sites-available/default
|
|
systemctl reload nginx
|
|
|
|
latest_release=\$(curl -s https://community.limesurvey.org/downloads/ | grep 'https://download.limesurvey.org/latest-master/.*\.zip' -o)
|
|
wget "\$latest_release" -qO /var/www/limesurvey-latest.zip
|
|
mkdir -p /var/www/limesurvey
|
|
EOF
|
|
echo "OK"
|
|
|
|
}
|
|
|
|
### MAIN
|
|
|
|
. "$MIAOU_BASEDIR/lib/init.sh"
|
|
arg1_required "$@"
|
|
readonly CONTAINER="$1"
|
|
|
|
check || (
|
|
install
|
|
check
|
|
)
|