grep test postinst
[carnet-upgrade.git] / debian / postinst
index 6515061..ebdc8c4 100644 (file)
@@ -1,50 +1,54 @@
 #!/bin/sh
-# postinst script for carnet-upgrade
-#
-# see: dh_installdeb(1)
 
 set -e
 
-# summary of how this script can be called:
-#        * <postinst> `configure' <most-recently-configured-version>
-#        * <old-postinst> `abort-upgrade' <new version>
-#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
-#          <new-version>
-#        * <postinst> `abort-remove'
-#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
-#          <failed-install-package> <version> `removing'
-#          <conflicting-package> <version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
+[ "$1" = "configure" ] || exit 0
+[ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
 
+# Load debconf
+. /usr/share/debconf/confmodule
+db_version 2.0
 
-case "$1" in
-    configure)
-    ;;
-
-    abort-upgrade|abort-remove|abort-deconfigure)
-    ;;
-
-    *)
-        echo "postinst called with unknown argument \`$1'" >&2
-        exit 1
-    ;;
-esac
+# Load CARNET Tools
+. /usr/share/carnet-tools/functions.sh
 
 # clear old cached values
-if [ "$1" = "configure" ] && dpkg --compare-versions "$2" lt 4.0; then
-    if [ -e /usr/share/debconf/confmodule ]; then
-        . /usr/share/debconf/confmodule
-        db_set carnet-upgrade/debconf-priority ""
-        db_set carnet-upgrade/check-services   ""
-    fi    
+if dpkg --compare-versions "$2" lt 6.0; then
+    export CN_POSTINST=1
 fi
 
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
+# perl se buni ako nema postavljen defaultni locale
+# stavit cemo en_US.UTF-8
+
+if ! grep -q "^en_US.UTF-8 UTF-8" /etc/locale.gen; then
+       # generirat cemo najpotrebnije locale (HR, EN, te HR.UTF i EN.UTF8)
+       cp_check_and_sed '# en_US.UTF-8 UTF-8' \
+       's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' \
+       /etc/locale.gen || true
+                                  
+       cp_check_and_sed '# en_US ISO-8859-1' \
+       's/# en_US ISO-8859-1/en_US ISO-8859-1/g' \
+       /etc/locale.gen || true
+
+       cp_check_and_sed '# hr_HR ISO-8859-2' \
+       's/# hr_HR ISO-8859-2/hr_HR ISO-8859-2/g' \
+       /etc/locale.gen || true
+                                                                                                      
+       cp_check_and_sed '# hr_HR.UTF-8 UTF-8' \
+       's/# hr_HR.UTF-8 UTF-8/hr_HR.UTF-8 UTF-8/g' \
+       /etc/locale.gen || true
+
+       locale-gen      
+fi
 
+# Ako ima već neki default ne diramo ga
+if [ -f /etc/default/locale ]; then
+       if [ ! $(grep -q "^LANG" /etc/default/locale) ]; then
+               cat > /etc/default/locale <<EOF
+LANG=en_US.UTF-8
+LANGUAGE="en_US:en"
+EOF
+       fi
+       update-locale
+fi
 #DEBHELPER#
-
-exit 0
-
-