Browse Source

patch_message_pm

main
pvincent 7 days ago
parent
commit
524fe7f890
  1. 34
      sympa/recipe/sympa_fix_personalization.recipe

34
sympa/recipe/sympa_fix_personalization.recipe

@ -3,6 +3,7 @@
# CONSTANTS # CONSTANTS
GLOBAL_CONF=/etc/sympa/sympa/sympa.conf GLOBAL_CONF=/etc/sympa/sympa/sympa.conf
MESSAGE_PM=/usr/share/sympa/lib/Sympa/Message.pm
LIST_DATA_DIR=/var/lib/sympa/list_data LIST_DATA_DIR=/var/lib/sympa/list_data
FOUND=false FOUND=false
@ -19,6 +20,38 @@ function fix_personalization {
fi fi
} }
function patch_message_pm {
if [[ -f $MESSAGE_PM ]]; then
if grep -q '^.*qw/subject x-originating-ip message-id date x-original-to x-original-from.*$' "$MESSAGE_PM"; then
/opt/miaou-bash/tools/append_or_replace '^.*qw/subject x-originating-ip message-id date x-original-to.*$' ' qw/subject x-originating-ip message-id date x-original-to x-original-from from to thread-topic content-type/' "$MESSAGE_PM"
FOUND=true
else
echo 'already patched!'
fi
message=$(prepend_2lines_of_text_before_existing_line "$MESSAGE_PM" '$data->{sender} = $self->{sender};' '$data->{gecos} = $self->{gecos};' '$data->{subject} = $self->{decoded_subject};')
[[ $message =~ 'do prepend']] && FOUND=true || true
else
echo "file: $MESSAGE_PM not found!" && exit 11
fi
}
## arg1=file, arg2=text, arg3='existing_line'
function prepend_2lines_of_text_before_existing_line {
local file="$1"
local line1="$2"
local line2="$3"
local existing="$4"
[[ ! -f $file ]] && echo "file: $file not found!" && exit 20
if ! grep "^$existing$" $file -B2 | grep -qz "$line1.*$line2.*$existing"; then
echo 'do prepend'
sed -i "/^$existing$/s/^/$line1\n$line2\n/" $file
else
echo 'already done!'
fi
}
function restart_services { function restart_services {
$FOUND && systemctl restart sympa wwsympa.socket || true $FOUND && systemctl restart sympa wwsympa.socket || true
} }
@ -26,5 +59,6 @@ function restart_services {
# MAIN # MAIN
set -Eue set -Eue
patch_message_pm
fix_personalization fix_personalization
restart_services restart_services
Loading…
Cancel
Save