You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.8 KiB

#!/usr/bin/env miaou-recipe
# CONSTANTS
GLOBAL_CONF=/etc/sympa/sympa/sympa.conf
MESSAGE_PM=/usr/share/sympa/lib/Sympa/Message.pm
LIST_DATA_DIR=/var/lib/sympa/list_data
FOUND=false
# FUNCTIONS
function fix_personalization {
if ! grep -q "^personalization_feature.*on.*$" $GLOBAL_CONF; then
echo 'enabling personalization now'
/opt/miaou-bash/tools/append_or_replace '^personalization_feature.*$' 'personalization_feature on' $GLOBAL_CONF
/opt/miaou-bash/tools/append_or_replace '^personalization.mail_apply_on.*$' 'personalization.mail_apply_on footer' $GLOBAL_CONF
FOUND=true
else
echo 'personalization already enabled globally!'
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
echo 'applying x-original-from patch towards message pm'
/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 'x-original-from already patched!'
fi
if [[ $(grep -n '$data->{sender} = $self->{sender};' /usr/share/sympa/lib/Sympa/Message.pm | cut -d: -f1) -ne 1540 ]]; then
echo 'applying sender + gecos patch towards message pm'
patch /usr/share/sympa/lib/Sympa/Message.pm << EOF
1539a1540,1541
> \$data->{sender} = \$self->{sender};
> \$data->{gecos} = \$self->{gecos};
EOF
FOUND=true
else
echo 'sender + gecos already patched!'
fi
else
echo "file: $MESSAGE_PM not found!" && exit 11
fi
}
function restart_services {
$FOUND && systemctl restart sympa wwsympa.socket || true
}
# MAIN
set -Eue
patch_message_pm
fix_personalization
restart_services