|
|
|
@ -0,0 +1,46 @@ |
|
|
|
#!/usr/bin/env miaou-recipe |
|
|
|
|
|
|
|
# CONSTANTS |
|
|
|
|
|
|
|
GLOBAL_CONF=/etc/sympa/sympa/sympa.conf |
|
|
|
LIST_DATA_DIR=/var/lib/sympa/list_data |
|
|
|
FOUND=false |
|
|
|
|
|
|
|
# FUNCTIONS |
|
|
|
|
|
|
|
function fix_external_origin { |
|
|
|
if ! grep -q "^allowed_external_origin.*\*$" $GLOBAL_CONF; then |
|
|
|
/opt/miaou-bash/tools/append_or_replace '^allowed_external_origin.*$' 'allowed_external_origin *' $GLOBAL_CONF |
|
|
|
|
|
|
|
echo 'allowed_external_origin now enabled' |
|
|
|
FOUND=true |
|
|
|
else |
|
|
|
echo 'allowed_external_origin already enabled globally!' |
|
|
|
fi |
|
|
|
config_files=$(find $LIST_DATA_DIR -name "config" -type f) |
|
|
|
for i in $config_files; do |
|
|
|
if grep -q ^allowed_external_origin $i; then |
|
|
|
FOUND=true |
|
|
|
echo "found problematic configuration in $i" |
|
|
|
remove_section_from_file $i allowed_external_origin |
|
|
|
fi |
|
|
|
done |
|
|
|
} |
|
|
|
|
|
|
|
function remove_section_from_file { |
|
|
|
local file=$1 |
|
|
|
local section=$2 |
|
|
|
awk "/^$section/{found=1} !found{print} /^$/{found=0}" $file > $file.new |
|
|
|
mv $file.new $file |
|
|
|
chown sympa:sympa $file |
|
|
|
} |
|
|
|
|
|
|
|
function restart_services { |
|
|
|
$FOUND && systemctl restart sympa wwsympa.socket || true |
|
|
|
} |
|
|
|
|
|
|
|
# MAIN |
|
|
|
|
|
|
|
set -Eue |
|
|
|
fix_external_origin |
|
|
|
restart_services |