From 476dbd06b8aaae8c48918d9dfddc93ef2e0446bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sara=20Aim=C3=A9e=20Smiseth?= <51710585+SaraSmiseth@users.noreply.github.com> Date: Sat, 27 Jun 2020 19:47:57 +0200 Subject: [PATCH] Refactor module install scripts to remove duplicate code. Fixes #6. --- Dockerfile | 4 +-- docker-prosody-module-copy.bash | 41 ------------------------------ docker-prosody-module-install.bash | 9 ++++--- 3 files changed, 7 insertions(+), 47 deletions(-) delete mode 100755 docker-prosody-module-copy.bash diff --git a/Dockerfile b/Dockerfile index f1b446e..0218fde 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,9 +77,7 @@ RUN docker-prosody-module-install.bash \ e2e_policy `# require end-2-end encryption` \ filter_chatstates `# disable "X is typing" type messages` \ smacks `# stream management (XEP-0198)` \ - throttle_presence `# presence throttling in CSI` - -RUN docker-prosody-module-copy.bash \ + throttle_presence `# presence throttling in CSI` \ http_upload `# file sharing (XEP-0363)` \ vcard_muc `# XEP-0153: vCard-Based Avatar (MUC)` diff --git a/docker-prosody-module-copy.bash b/docker-prosody-module-copy.bash deleted file mode 100755 index 954edeb..0000000 --- a/docker-prosody-module-copy.bash +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -set -e - -source="/usr/src/prosody-modules" -target="/usr/local/lib/prosody/custom-modules" - -cd ${source} - -usage() { - echo "usage: $0 ext-name [ext-name ...]" - echo " ie: $0 carbons e2e_policy proxy65" - echo - echo 'Possible values for ext-name:' - find . -mindepth 1 -maxdepth 1 -type d | sort | sed s/\.\\/mod_//g | xargs -} - -exts= -for ext; do - if [ -z "mod_$ext" ]; then - continue - fi - if [ ! -d "mod_$ext" ]; then - echo >&2 "error: $PWD/mod_$ext does not exist" - echo >&2 - usage >&2 - exit 1 - fi - exts="$exts $ext" -done - -if [ -z "$exts" ]; then - usage >&2 - exit 1 -fi - -for ext in $exts; do - echo "Installing mod_${ext}" - - echo " - copying to ${target}" - cp -r "${source}/mod_${ext}" "${target}/" -done diff --git a/docker-prosody-module-install.bash b/docker-prosody-module-install.bash index 337c8c7..3bd54b5 100755 --- a/docker-prosody-module-install.bash +++ b/docker-prosody-module-install.bash @@ -40,7 +40,10 @@ for ext in $exts; do echo " - copying to ${target}" cp -r "${source}/mod_${ext}" "${target}/" - echo " - enabling within ${config}" - new_config=$(cat "${config}" | module="${ext}" perl -0pe 's/(modules_enabled[ ]*=[ ]*{[^}]*)};/$1\n\t"$ENV{module}";\n};/') - echo "${new_config}" > "${config}" + # Skip this if the modules should not be added to modules_enabled. + if [ "$ext" != "http_upload" ] && [ "$ext" != "vcard_muc" ] ; then + echo " - enabling within ${config}" + new_config=$(cat "${config}" | module="${ext}" perl -0pe 's/(modules_enabled[ ]*=[ ]*{[^}]*)};/$1\n\t"$ENV{module}";\n};/') + echo "${new_config}" > "${config}" + fi done