]> git.donarmstrong.com Git - roundcube.git/commitdiff
Upgrade only if the user asked for upgrade in debconf
authorVincent Bernat <bernat@luffy.cx>
Fri, 25 May 2007 18:31:55 +0000 (18:31 +0000)
committerJérémy Bobbio <lunar@debian.org>
Sat, 18 Jun 2011 16:27:23 +0000 (18:27 +0200)
debian/postinst

index 3b09dcc46e68a99a2413317fc86e2d2abe35cc7b..80b0827a4ef5e0641a2f7f43a09e5a09d9991b10 100644 (file)
@@ -25,16 +25,17 @@ case "$1" in
        # dbconfig-common but for sqlite, there is no way to add a
        # column to a table. Therefore, we dump here the table and add
        # the column.
-       case "$dbc_dbtype" in
-           sqlite)
-               db="${dbc_basepath}/${dbc_dbname}"
+       [ "$dbc_upgrade" = "true" ] && {
+           case "$dbc_dbtype" in
+               sqlite)
+                   db="${dbc_basepath}/${dbc_dbname}"
                # OK, we need to check if the table contains html_signature
-               if ! sqlite "$db" '.schema identities' | grep -q html_signature; then
-                   # We need to add it
-                   echo -n "Need to upgrade 'identities' table in $db... "
-                   upgrade_tmp=$(mktemp -t roundcube.sqlite.XXXXXXXXXX)
-                   (
-                       cat <<EOF
+                   if ! sqlite "$db" '.schema identities' | grep -q html_signature; then
+                       # We need to add it
+                       echo -n "Need to upgrade 'identities' table in $db... "
+                       upgrade_tmp=$(mktemp -t roundcube.sqlite.XXXXXXXXXX)
+                       (
+                           cat <<EOF
 BEGIN TRANSACTION;
 DROP TABLE identities;
 CREATE TABLE identities (
@@ -54,21 +55,22 @@ CREATE TABLE identities (
 CREATE INDEX ix_identities_user_id ON identities(user_id);
 
 EOF
-                       # We dump and keep only inserts
-                       sqlite "$db" '.dump identities' | \
-                           awk '/^INSERT INTO/ {start = 1} {if (start == 1) print}' | \
-                           head -n -2 | \
-                           sed 's/^\(INSERT INTO identities \)/\1(identity_id, user_id, del, standard, name, organization, email, "reply-to", bcc, signature) /'
-                       echo 'COMMIT;' ) > $upgrade_tmp
-                   sqlite "$db" < $upgrade_tmp
-                   rm $upgrade_tmp
-                   echo "OK"
-               fi
-               ;;
-           *)
-               # Do nothing
-               ;;
-       esac
+                           # We dump and keep only inserts
+                           sqlite "$db" '.dump identities' | \
+                               awk '/^INSERT INTO/ {start = 1} {if (start == 1) print}' | \
+                               head -n -2 | \
+                               sed 's/^\(INSERT INTO identities \)/\1(identity_id, user_id, del, standard, name, organization, email, "reply-to", bcc, signature) /'
+                           echo 'COMMIT;' ) > $upgrade_tmp
+                       sqlite "$db" < $upgrade_tmp
+                       rm $upgrade_tmp
+                       echo "OK"
+                   fi
+                   ;;
+               *)
+                   # Do nothing
+                   ;;
+           esac
+       }
 
        CONFFILE=/etc/roundcube/main.inc.php
        touch $CONFFILE.ucftmp