diff --git a/dapostinstall.sh b/dapostinstall.sh index 54fd3f5..9cb54d9 100755 --- a/dapostinstall.sh +++ b/dapostinstall.sh @@ -19,6 +19,14 @@ REDIS_VERSION=8 HOSTNAME_SSL=1 SETUP_TXT="$DADIR/conf/setup.txt" PLUGIN_ARCHIVE_DIR="$DAPOSTINSTALL_DIR/plugins" + +# PLUGINY +# Nazwa zmiennej odpowiada nazwie paczki: borg-restore.tar.gz -> PLUGIN_BORG_RESTORE. +PLUGIN_BORG_RESTORE=1 +PLUGIN_DB_MANAGER=1 +PLUGIN_IMAPSYNC=1 +PLUGIN_REDIS_MANAGER=1 + BRANDING_DIR="$DAPOSTINSTALL_DIR/branding" DA_TEMPLATES_ARCHIVE="$BRANDING_DIR/da_templates.tar" DA_BRANDING_ARCHIVE="$BRANDING_DIR/da-branding-hitme.tar.gz" @@ -68,13 +76,41 @@ build_php_extension() { da build "$extension" } +plugin_config_var() { + local plugin_name="$1" + local var_name + + var_name="${plugin_name//-/_}" + var_name="PLUGIN_${var_name^^}" + printf '%s\n' "$var_name" +} + +is_plugin_enabled() { + local plugin_name="$1" + local var_name + local enabled + + var_name="$(plugin_config_var "$plugin_name")" + enabled="${!var_name:-1}" + + [[ "$enabled" != "0" ]] +} + install_local_plugin_archive() { local archive="$1" local plugin_name + local plugin_config local plugin_dir local install_script plugin_name="$(basename "$archive" .tar.gz)" + plugin_config="$(plugin_config_var "$plugin_name")" + + if ! is_plugin_enabled "$plugin_name"; then + echo "$plugin_config=0 - pomijam instalacje pluginu $plugin_name" + return 0 + fi + plugin_dir="$DADIR/plugins/$plugin_name" echo "Instalacja pluginu $plugin_name" diff --git a/tests/quality_checks.sh b/tests/quality_checks.sh index a14bc39..ba334e7 100644 --- a/tests/quality_checks.sh +++ b/tests/quality_checks.sh @@ -105,6 +105,10 @@ assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^SSH_PORT=10022$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^REDIS_VERSION=8$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^HOSTNAME_SSL=1$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^PLUGIN_ARCHIVE_DIR="\$DAPOSTINSTALL_DIR/plugins"$' +assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^PLUGIN_BORG_RESTORE=1$' +assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^PLUGIN_DB_MANAGER=1$' +assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^PLUGIN_IMAPSYNC=1$' +assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^PLUGIN_REDIS_MANAGER=1$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^BRANDING_DIR="\$DAPOSTINSTALL_DIR/branding"$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^DA_TEMPLATES_ARCHIVE="\$BRANDING_DIR/da_templates\.tar"$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^DA_BRANDING_ARCHIVE="\$BRANDING_DIR/da-branding-hitme\.tar\.gz"$' @@ -196,10 +200,13 @@ assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'Nie udalo sie wystawic certyf assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'request_single "\$da_hostname" 4096' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'request_single `hostname`' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'Skorka evolution zostala ustawiona jako domyslna' +assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^is_plugin_enabled\(\) \{$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^install_local_plugin_archive\(\) \{$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'local found=0' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'for archive in "\$PLUGIN_ARCHIVE_DIR"/\*\.tar\.gz; do' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'found=1' +assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'if ! is_plugin_enabled "\$plugin_name"; then' +assert_file_contains "$ROOT_DIR/dapostinstall.sh" '\$plugin_config=0 - pomijam instalacje pluginu' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'Brak paczek pluginów w \$PLUGIN_ARCHIVE_DIR' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'plugin_name="\$\(basename "\$archive" \.tar\.gz\)"' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'mkdir -p "\$plugin_dir"'