Bug 10942: (follow-up) make AUTOMATIC_TRANSLATIONS_UPDATE default to yes
[koha.git] / debian / koha-common.postinst
1 #!/bin/sh
2
3 set -e
4
5 # Default to "yes"
6 AUTOMATIC_TRANSLATIONS_UPDATE="yes"
7
8 . /usr/share/debconf/confmodule
9
10 # Read configuration variable file if it is present
11 if [ -r /etc/koha/koha-common.conf ]; then
12     . /etc/koha/koha-common.conf
13 fi
14
15 conf=/etc/mysql/koha-common.cnf
16 if [ ! -e "$conf" ] && [ ! -L "$conf" ]
17 then
18     ln -s debian.cnf "$conf"
19 fi
20
21 #DEBHELPER#
22
23 koha-upgrade-schema $(koha-list)
24
25 if [ "$AUTOMATIC_TRANSLATIONS_UPDATE" = "yes" ]; then
26     for lang in $(koha-translate --list | grep -v -x "en"); do
27         if koha-translate --update $lang; then
28             echo "Updated the $lang translations."
29         else
30             cat <<EOF
31 ERROR: an error was found when updating '$lang' translations. Please manually
32 run 'koha-translate --update $lang'. Run man koha-translate for more options.
33 EOF
34         fi
35     done
36 else
37     # no auto-update, check update needed and warn if needed
38     if koha-translate --list | grep -v -q -x "en"; then
39         # translations installed, update needed
40         cat <<EOF
41 Warning: template translations are not set to be automatically updated.
42 Please manually run 'koha-translate --update lang_code' to update them.
43
44 You can run 'koha-translate --list' to get a list of the installed translations codes.
45 EOF
46     fi
47 fi
48
49 db_stop
50
51 exit 0