From 533ce01bf23e38a1bf21de3eec64914e799e3907 Mon Sep 17 00:00:00 2001 From: Julio SANTILARIO BERTHILIER Date: Tue, 29 Apr 2025 16:38:52 +0200 Subject: [PATCH 1/3] adding SurveyGuardian --- .../20-activate-limesurvey-plugin.sh | 10 +++++++++- .../20-install-limesurvey-plugins.sh | 17 ++++++++++++++++- docker-stacks/etc/simva.install.d/simva-env.sh | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) mode change 100755 => 100644 docker-stacks/03-limesurvey/etc/hooks/before-install.d/20-install-limesurvey-plugins.sh diff --git a/docker-stacks/03-limesurvey/etc/hooks/after-start.d/20-activate-limesurvey-plugin.sh b/docker-stacks/03-limesurvey/etc/hooks/after-start.d/20-activate-limesurvey-plugin.sh index be2dbb6e..d48f416f 100644 --- a/docker-stacks/03-limesurvey/etc/hooks/after-start.d/20-activate-limesurvey-plugin.sh +++ b/docker-stacks/03-limesurvey/etc/hooks/after-start.d/20-activate-limesurvey-plugin.sh @@ -19,7 +19,7 @@ if [[ ! -e "${SIMVA_DATA_HOME}/limesurvey/.initialized" ]]; then DB_PASSWORD=$SIMVA_LIMESURVEY_MYSQL_PASSWORD if [[ ${SIMVA_LIMESURVEY_VERSION%.*} > 5 ]]; then - declare -A plugins=(["LimeSurveyWebhook"]=${SIMVA_LIMESURVEY_WEBHOOK_PLUGIN_VERSION} ["AuthOAuth2"]=${SIMVA_LIMESURVEY_AUTHOAUTH2_PLUGIN_VERSION} ["LimeSurveyXAPITracker"]=${SIMVA_LIMESURVEY_XAPITRACKER_PLUGIN_VERSION}); + declare -A plugins=(["LimeSurveyWebhook"]=${SIMVA_LIMESURVEY_WEBHOOK_PLUGIN_VERSION} ["AuthOAuth2"]=${SIMVA_LIMESURVEY_AUTHOAUTH2_PLUGIN_VERSION} ["LimeSurveyXAPITracker"]=${SIMVA_LIMESURVEY_XAPITRACKER_PLUGIN_VERSION} ["SurveyGuardian"]=${SIMVA_LIMESURVEY_SURVEYGUARDIAN_PLUGIN_VERSION}); for key in "${!plugins[@]}"; do ext_name=$key ext_version=${plugins[$key]} @@ -53,4 +53,12 @@ if [[ ! -e "${SIMVA_DATA_HOME}/limesurvey/.initialized" ]]; then " fi fi + + echo "Inserting plugin $SURVEYGUARDIAN_PLUGIN_NAME into the plugins table..." + "${SIMVA_HOME}/bin/run-command.sh" mysql -u $DB_USER -p"$DB_PASSWORD" -e " + USE $DB_NAME; + INSERT INTO \`plugins\` (name, plugin_type, active, priority, version) + VALUES ('$SURVEYGUARDIAN_PLUGIN_NAME', 'user', 1, 0, '$SURVEYGUARDIAN_PLUGIN_VERSION'); + " + echo "Plugin $SURVEYGUARDIAN_PLUGIN_NAME has been installed and its settings have been added!" fi \ No newline at end of file diff --git a/docker-stacks/03-limesurvey/etc/hooks/before-install.d/20-install-limesurvey-plugins.sh b/docker-stacks/03-limesurvey/etc/hooks/before-install.d/20-install-limesurvey-plugins.sh old mode 100755 new mode 100644 index 10bc0f52..07cf2727 --- a/docker-stacks/03-limesurvey/etc/hooks/before-install.d/20-install-limesurvey-plugins.sh +++ b/docker-stacks/03-limesurvey/etc/hooks/before-install.d/20-install-limesurvey-plugins.sh @@ -8,8 +8,9 @@ if [[ ! -d "${PLUGINS_DIR}" ]]; then fi DEPLOYMENT_DIR="${SIMVA_DATA_HOME}/limesurvey/data/plugins" +UPLOAD_DIR="${SIMVA_DATA_HOME}/limesurvey/data/upload/plugins" -declare -A plugins=(["LimeSurveyWebhook"]=${SIMVA_LIMESURVEY_WEBHOOK_PLUGIN_VERSION} ["AuthOAuth2"]=${SIMVA_LIMESURVEY_AUTHOAUTH2_PLUGIN_VERSION} ["LimeSurveyXAPITracker"]=${SIMVA_LIMESURVEY_XAPITRACKER_PLUGIN_VERSION}); +declare -A plugins=(["LimeSurveyWebhook"]=${SIMVA_LIMESURVEY_WEBHOOK_PLUGIN_VERSION} ["AuthOAuth2"]=${SIMVA_LIMESURVEY_AUTHOAUTH2_PLUGIN_VERSION} ["LimeSurveyXAPITracker"]=${SIMVA_LIMESURVEY_XAPITRACKER_PLUGIN_VERSION} ["SurveyGuardian"]=${SIMVA_LIMESURVEY_SURVEYGUARDIAN_PLUGIN_VERSION}); for key in "${!plugins[@]}"; do ext_name=$key @@ -31,4 +32,18 @@ for key in "${!plugins[@]}"; do tmp_dir=$(mktemp -d) unzip "${PLUGINS_DIR}/${ext_zip}" -d $tmp_dir rsync -avh --delete --itemize-changes ${tmp_dir}/ "${DEPLOYMENT_DIR}/$ext_name" + if [[ $ext_name = "SurveyGuardian" ]]; then + if [[ ! -e ${UPLOAD_DIR}/ ]]; then + mkdir ${UPLOAD_DIR}/ + fi + if [[ ! -e "${UPLOAD_DIR}/$ext_name" ]]; then + mkdir "${UPLOAD_DIR}/$ext_name" + fi + if [[ ! -e "${UPLOAD_DIR}/$ext_name/assets" ]]; then + mkdir "${UPLOAD_DIR}/$ext_name/assets" + fi + rsync -avh --delete --itemize-changes ${tmp_dir}/assets "${UPLOAD_DIR}/$ext_name/assets" + fi done + + diff --git a/docker-stacks/etc/simva.install.d/simva-env.sh b/docker-stacks/etc/simva.install.d/simva-env.sh index f8c19afb..5b2f4028 100644 --- a/docker-stacks/etc/simva.install.d/simva-env.sh +++ b/docker-stacks/etc/simva.install.d/simva-env.sh @@ -84,6 +84,7 @@ export SIMVA_KAFKA_EXTENSIONS_VERSION="1.0.0" export SIMVA_LIMESURVEY_AUTHOAUTH2_PLUGIN_VERSION="1.5.0" export SIMVA_LIMESURVEY_WEBHOOK_PLUGIN_VERSION="1.1.0" export SIMVA_LIMESURVEY_XAPITRACKER_PLUGIN_VERSION="1.0.0" +export SIMVA_LIMESURVEY_SURVEYGUARDIAN_PLUGIN_VERSION="1.0.0" ################################# # OS and Architecture detection # From 26ef9bb10186993c0f7e8f443d98a01656b9437a Mon Sep 17 00:00:00 2001 From: Julio SANTILARIO BERTHILIER Date: Wed, 30 Apr 2025 13:07:20 +0200 Subject: [PATCH 2/3] Fix survey guardian --- .../20-activate-limesurvey-plugin.sh | 22 +++++++++++++------ .../20-install-limesurvey-plugins.sh | 12 +++------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/docker-stacks/03-limesurvey/etc/hooks/after-start.d/20-activate-limesurvey-plugin.sh b/docker-stacks/03-limesurvey/etc/hooks/after-start.d/20-activate-limesurvey-plugin.sh index d48f416f..992e5bd0 100644 --- a/docker-stacks/03-limesurvey/etc/hooks/after-start.d/20-activate-limesurvey-plugin.sh +++ b/docker-stacks/03-limesurvey/etc/hooks/after-start.d/20-activate-limesurvey-plugin.sh @@ -54,11 +54,19 @@ if [[ ! -e "${SIMVA_DATA_HOME}/limesurvey/.initialized" ]]; then fi fi - echo "Inserting plugin $SURVEYGUARDIAN_PLUGIN_NAME into the plugins table..." - "${SIMVA_HOME}/bin/run-command.sh" mysql -u $DB_USER -p"$DB_PASSWORD" -e " - USE $DB_NAME; - INSERT INTO \`plugins\` (name, plugin_type, active, priority, version) - VALUES ('$SURVEYGUARDIAN_PLUGIN_NAME', 'user', 1, 0, '$SURVEYGUARDIAN_PLUGIN_VERSION'); - " - echo "Plugin $SURVEYGUARDIAN_PLUGIN_NAME has been installed and its settings have been added!" + SurveyGuardian=$("${SIMVA_HOME}/bin/run-command.sh" mysql -u $DB_USER -p"$DB_PASSWORD" -e " + USE $DB_NAME; + SELECT id FROM \`plugins\` WHERE name='$SURVEYGUARDIAN_PLUGIN_NAME' AND active=1 and version='$SURVEYGUARDIAN_PLUGIN_VERSION';"); + echo $SurveyGuardian; + if [[ ! $SurveyGuardian == *"id"* ]]; then + echo "Inserting plugin $SURVEYGUARDIAN_PLUGIN_NAME into the plugins table..." + "${SIMVA_HOME}/bin/run-command.sh" mysql -u $DB_USER -p"$DB_PASSWORD" -e " + USE $DB_NAME; + INSERT INTO \`plugins\` (name, plugin_type, active, priority, version) + VALUES ('$SURVEYGUARDIAN_PLUGIN_NAME', 'user', 1, 0, '$SURVEYGUARDIAN_PLUGIN_VERSION'); + " + echo "Plugin $SURVEYGUARDIAN_PLUGIN_NAME has been installed and its settings have been added!" + else + echo "Plugin $SURVEYGUARDIAN_PLUGIN_NAME settings have already been added!" + fi fi \ No newline at end of file diff --git a/docker-stacks/03-limesurvey/etc/hooks/before-install.d/20-install-limesurvey-plugins.sh b/docker-stacks/03-limesurvey/etc/hooks/before-install.d/20-install-limesurvey-plugins.sh index 07cf2727..26316760 100644 --- a/docker-stacks/03-limesurvey/etc/hooks/before-install.d/20-install-limesurvey-plugins.sh +++ b/docker-stacks/03-limesurvey/etc/hooks/before-install.d/20-install-limesurvey-plugins.sh @@ -33,16 +33,10 @@ for key in "${!plugins[@]}"; do unzip "${PLUGINS_DIR}/${ext_zip}" -d $tmp_dir rsync -avh --delete --itemize-changes ${tmp_dir}/ "${DEPLOYMENT_DIR}/$ext_name" if [[ $ext_name = "SurveyGuardian" ]]; then - if [[ ! -e ${UPLOAD_DIR}/ ]]; then - mkdir ${UPLOAD_DIR}/ + if [[ ! -e "${UPLOAD_DIR}/$ext_name/assets/survey-tables/" ]]; then + mkdir -p "${UPLOAD_DIR}/$ext_name/assets/survey-tables/" fi - if [[ ! -e "${UPLOAD_DIR}/$ext_name" ]]; then - mkdir "${UPLOAD_DIR}/$ext_name" - fi - if [[ ! -e "${UPLOAD_DIR}/$ext_name/assets" ]]; then - mkdir "${UPLOAD_DIR}/$ext_name/assets" - fi - rsync -avh --delete --itemize-changes ${tmp_dir}/assets "${UPLOAD_DIR}/$ext_name/assets" + rsync -avh --delete --exclude "${UPLOAD_DIR}/$ext_name/assets/survey-tables" --itemize-changes "${DEPLOYMENT_DIR}/$ext_name/assets" "${UPLOAD_DIR}/$ext_name"; fi done From dbfcecec552a7dc4c0e33c0f2bb6e536857294b6 Mon Sep 17 00:00:00 2001 From: Julio SANTILARIO BERTHILIER Date: Wed, 30 Apr 2025 13:54:01 +0200 Subject: [PATCH 3/3] fix install SurveyGuardian --- .../20-install-limesurvey-plugins.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/docker-stacks/03-limesurvey/etc/hooks/before-install.d/20-install-limesurvey-plugins.sh b/docker-stacks/03-limesurvey/etc/hooks/before-install.d/20-install-limesurvey-plugins.sh index 26316760..46606a76 100644 --- a/docker-stacks/03-limesurvey/etc/hooks/before-install.d/20-install-limesurvey-plugins.sh +++ b/docker-stacks/03-limesurvey/etc/hooks/before-install.d/20-install-limesurvey-plugins.sh @@ -33,10 +33,19 @@ for key in "${!plugins[@]}"; do unzip "${PLUGINS_DIR}/${ext_zip}" -d $tmp_dir rsync -avh --delete --itemize-changes ${tmp_dir}/ "${DEPLOYMENT_DIR}/$ext_name" if [[ $ext_name = "SurveyGuardian" ]]; then - if [[ ! -e "${UPLOAD_DIR}/$ext_name/assets/survey-tables/" ]]; then + if [[ ! -e "${UPLOAD_DIR}/$ext_name/assets/" ]]; then + mkdir -p "${UPLOAD_DIR}/$ext_name/assets/" + fi + if [[ -e "${UPLOAD_DIR}/$ext_name/assets/survey-tables/" ]]; then + mv ${UPLOAD_DIR}/$ext_name/assets/survey-tables/* "${UPLOAD_DIR}/$ext_name/survey-tables/" + fi + + rsync -avh --delete --itemize-changes "${DEPLOYMENT_DIR}/$ext_name/assets" "${UPLOAD_DIR}/$ext_name"; + if [[ -e "${UPLOAD_DIR}/$ext_name/survey-tables/" ]]; then + mv ${UPLOAD_DIR}/$ext_name/survey-tables/* "${UPLOAD_DIR}/$ext_name/assets/survey-tables/" + else mkdir -p "${UPLOAD_DIR}/$ext_name/assets/survey-tables/" fi - rsync -avh --delete --exclude "${UPLOAD_DIR}/$ext_name/assets/survey-tables" --itemize-changes "${DEPLOYMENT_DIR}/$ext_name/assets" "${UPLOAD_DIR}/$ext_name"; fi done