X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=debian%2Fpostinst;h=1f77371fe89b197ea650d5f5fdff40dc8eee8237;hb=5c9cb61bd99bcc06acd6d775ce2ab28175f9fe09;hp=c53e5f089b8f696d5c52628dbf0811fba6cdfcd0;hpb=e90ef71b190bd6b5802dfc42357c6c8dade3a5fa;p=squirrelmail-cn.git diff --git a/debian/postinst b/debian/postinst index c53e5f0..1f77371 100644 --- a/debian/postinst +++ b/debian/postinst @@ -31,7 +31,7 @@ FQDN=`hostname --fqdn` . /usr/share/carnet-tools/functions.sh unset CP_ECHO_RETURN -mv_old_backups() { +mv_old_backups () { # Clean up /etc, nove old jun^H^H^Hbackups where they belong glob="$1.old.*-*-*.*:*:*" @@ -51,7 +51,7 @@ mv_old_backups() { # Recursively walks /etc/apache2/apache2.conf for Include directives. # Returns all configfiles so defined. # -function listconffiles () { +listconffiles () { local i incs @@ -63,8 +63,22 @@ function listconffiles () { fi } +# genlocales () +# +# Update/generate localisation files from templates if locales-all +# is not installed. +# +genlocales () { -reload="" + if [ -f /usr/lib/locales-all/supported.tar.lzma ] ; then + cp_echo "CN: locales-all installed, skipping locales generation." + else + /usr/sbin/locale-gen + fi +} + + +need_restart=0 DATE=`date +%Y-%m-%d.%H:%M:%S` CONFDIR=/etc/squirrelmail CONF=$CONFDIR/apache.conf @@ -115,7 +129,7 @@ if [ -f "$CONF" ]; then if ! cmp -s "$CONF" "/var/backups/$backup_name.bak"; then echo "." cp_echo "CN: Updated Apache2 configuration for Squirrelmail." - reload="reload" + need_restart=1 else echo "... no changes." fi @@ -139,7 +153,7 @@ apache2squirrel=`ls -l /etc/apache2/conf.d/ | grep "$CONF"` || true if [ -z "$apache2listconf" -a -z "$apache2squirrel" ]; then ln -s "$CONF" /etc/apache2/conf.d/squirrelmail-cn.conf - reload=reload + need_restart=1 fi @@ -196,107 +210,51 @@ fi # Would there be any changes, perhaps? # if cp_check_and_sed '.' "$seddef" "$CONF"; then - changed=1 -fi - -if grep -q x62 "$CONF"; then - really_old_config=1 + need_restart=1 fi +# Check /etc/hostname and /etc/mailname, because +# $domain = trim(implode('', file('/etc/'.(file_exists('/etc/mailname')?'mail':'host').'name'))); # -# MORE FIXES... -# +nodots= +nomailname= +grep -q '\.' /etc/hostname || nodots=1 +[ -e /etc/mailname ] || nomailname=1 -# Global $config_version; -# -if ! egrep -q '^[ ]*global[ ]+\$config_version' "$CONF"; then - really_old_config=1 - #echo "CN: Adding \"global \$config_version;\" to config.php." - perl -p -e 'print "global \$config_version;\n" if (/^\s*\$config_version/);' \ - "$CONF" > "$CONF.tmp" - cp_mv "$CONF.tmp" "$CONF" -fi - -# This was missing on some machines -# -if ! egrep -q '^[ ]*\$allow_thread_sort' $CONF; then - to_add='\$allow_thread_sort = false;\n' - cp_echo "CN: Adding \"\$allow_thread_sort\"." - perl -p -e 'if (! $a && /^\s*\$edit_name/) { - $_ .= "'"$to_add"'"; $a = 1; } - elsif (! $a && /^\?>/) { - $_ = "'"$to_add"'" . $_; $a = 1; }' \ - $CONF > "$CONF.tmp" - cp_mv "$CONF.tmp" "$CONF" -fi -# Shouldn't use /etc/hostname, especially if it contains only the host part -# replace -# $domain = implode('', file('/etc/hostname')); -# with -# $domain = trim(implode('',file('/etc/'.(file_exists('/etc/mailname')?'mail':'host').'name'))); +# Check for hr_HR locale. # -if egrep -q "^[[:blank:]]*\\\$domain[[:blank:]]*=[[:blank:]]*implode\\('',[[:blank:]]*file\\('/etc/hostname'\\)\\);" $CONF; then - nodots= - nomailname= - grep -q '\.' /etc/hostname || nodots=1 - [ -e /etc/mailname ] || nomailname=1 - if cp_check_and_sed "^[[:blank:]]*\\\$domain[[:blank:]]*=[[:blank:]]*implode\\('',[[:blank:]]*file\\('/etc/hostname'\\)\\);" \ - "s|^[ \t]*\\\$domain[ \t]*=[ \t]*implode('',[ \t]*file('/etc/hostname'));|\$domain = trim(implode('',file('/etc/'.(file_exists('/etc/mailname')?'mail':'host').'name')));|" \ - $CONF; then - cp_echo "CN: config.php updated to use either /etc/mailname or /etc/hostname" - fi -fi - - -# Generate hr_HR locale if needed. -# -if ! egrep -q '^hr_HR ISO-8859-2\b' /etc/locale.gen; then - if [ -f /etc/locale.gen ]; then - echo "hr_HR ISO-8859-2" >> /etc/locale.gen - cp_echo "CN: Added hr_HR locale to /etc/locale.gen." - else - echo "hr_HR ISO-8859-2" > /etc/locale.gen - cp_echo "CN: /etc/locale.gen created." - fi - dpkg-reconfigure -f noninteractive locales +if [ -f /etc/locale.gen ]; then + if ! egrep -q '^hr_HR ISO-8859-2\b' /etc/locale.gen; then + echo "hr_HR ISO-8859-2" >> /etc/locale.gen + cp_echo "CN: Added hr_HR locale to /etc/locale.gen." + genlocales + need_restart=1 + fi +else + echo "hr_HR ISO-8859-2" > /etc/locale.gen + cp_echo "CN: /etc/locale.gen created." + genlocales + need_restart=1 fi -# Check Apache2 web server for restart/reload. +# Check Apache2 web server for restart. # -if [ -n "$reload" ]; then +if [ $need_restart -eq 1 ]; then # Restart Apache2 web server. if [ -x "/etc/init.d/apache2" ]; then if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then - invoke-rc.d apache2 "$reload" || exit $? + invoke-rc.d apache2 restart || exit $? else - /etc/init.d/apache2 "$reload" || exit $? + /etc/init.d/apache2 restart || exit $? fi fi fi -# Warn user of really old config file -# -if [ "$really_old_config" ]; then - echo - echo "CN: You have a really old config file." - cp_echo -m "CN: Old \"$CONF\" detected during installation." - cp_echo "CN The known bad options were fixed, but it is _strongly_ recommended that" - cp_echo "CN you either copy over the new template, and reconfigure this package" - cp_echo - cp_echo " cp $TMPL $CONF" - cp_echo " dpkg-reconfigure squirrelmail-cn" - cp_echo - cp_echo "CN or use squirrelmail-configure (conf.pl) to generate a fresh" - cp_echo " ${CONF} file." - echo -fi - - # Mailname info... # if [ "$nodots" -o "$nomailname" ]; then