Add a script that manages the post upgrade process

This commit is contained in:
Andrea Dell'Amico 2020-12-31 18:05:59 +01:00
parent f3d889d180
commit a0b6e27147
2 changed files with 42 additions and 0 deletions

View File

@ -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' ]

View File

@ -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