diff --git a/tasks/postorius-hyperkitty.yml b/tasks/postorius-hyperkitty.yml index 39b871e..c14146b 100644 --- a/tasks/postorius-hyperkitty.yml +++ b/tasks/postorius-hyperkitty.yml @@ -132,3 +132,10 @@ disabled: no tags: [ 'mailman', 'postorius', 'hyperkitty', 'mailman_conf', 'postorius_cron' ] + +- name: Install a script that must be run after an update of the mailman suite + block: + - name: Install a script that should be run after an update of the mailman suite + template: src=mailman-postupdate.sh.j2 dest={{ mailman_bindir }}/mailman-postupdate owner={{ mailman_user }} group={{ mailman_user }} mode='0750' + tags: [ 'mailman', 'postorius', 'hyperkitty', 'mailman_upgrade', 'postorius_upgrade' ] + diff --git a/templates/mailman-postupdate.sh.j2 b/templates/mailman-postupdate.sh.j2 new file mode 100644 index 0000000..5fb32eb --- /dev/null +++ b/templates/mailman-postupdate.sh.j2 @@ -0,0 +1,35 @@ +#!/bin/bash + +running_user=$( id -un ) +if [ "$running_user" != "{{ mailman_user }}" ] ; then + logger "mailman-postupdate: must be run by the mailman user" + echo "mailman-postupdate must be run by the mailman user" + exit 1 +fi + +set -e +postorius_dir="{{ mailman_postorius_dir }}" +postorius_executable="{{ mailman_postorius_dir }}/manage.py" + +set -x + +if [ "$DEBUG" == "False" ]; then + mkdir -p "$postorius_dir/static" || : + "$postorius_executable" collectstatic --clear --noinput --verbosity 0 + "$postorius_executable" compress + "$postorius_executable" compilemessages +fi + +syncdb_cmd="$postorius_executable migrate" +if [[ ! -t 1 ]]; then + # stdout is not a terminal + syncdb_cmd="$syncdb_cmd --noinput" +fi +$syncdb_cmd +echo 'Do you want to rebuild the search index? This takes a long time.' +echo 'Type "Yes" to continue; anything else to quit.' +read -p "> " response +if [ "x$response" != "xYes" ] ; then + exit +fi +"$postorius_executable" update_index