xvm-iscsi-config: don't restart on upgrade, only first install
[invirt/packages/xvm-iscsi-config.git] / debian / xvm-iscsi-config.postinst
index 7c743da..e7e9faf 100755 (executable)
@@ -20,6 +20,10 @@ set -e
 # for details, see http://www.debian.org/doc/debian-policy/ or
 # the debian-policy package
 
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
 
 case "$1" in
     configure)
@@ -29,6 +33,7 @@ case "$1" in
         USERNAME="$RET"
         db_get xvm-iscsi-config/password
         PASSWORD="$RET"
+        db_stop
         
         cat >/etc/invirt/conf.d/iscsi <<EOF
 iscsi:
@@ -36,9 +41,22 @@ iscsi:
  username: $USERNAME
  password: $PASSWORD
 EOF
-        invoke-rc.d xvm-iscsi-config restart
-        invoke-rc.d open-iscsi restart
-        iscsiadm -m discovery -t st -p $(invirt-getconf iscsi.address):3260
+        if [ -z "$2" ]; then
+            invoke-rc.d xvm-iscsi-config restart
+            invoke-rc.d open-iscsi restart
+            iscsiadm -m discovery -t st -p $(invirt-getconf iscsi.address):3260
+        else
+            # Don't disrupt an existing installation.
+            cat <<EOF
+xvm-iscsi-config: If the configuration has changed, restart iscsi:
+  /etc/init.d/xvm-iscsi-config restart
+  /etc/init.d/open-iscsi restart
+  iscsiadm -m discovery -t st -p $(invirt-getconf iscsi.address):3260
+  lvchange -a ln /dev/xenvg && lvchange -a y /dev/xenvg
+This will leave VMs unable to access their disks, so migrate them first.
+
+EOF
+        fi
     ;;
 
     abort-upgrade|abort-remove|abort-deconfigure)
@@ -50,9 +68,4 @@ EOF
     ;;
 esac
 
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
 exit 0