chiark / gitweb /
debian/tripe-peer-services.postinst: Retire the old `watch' service.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 13 Jul 2013 15:34:40 +0000 (16:34 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 14 Jan 2014 20:31:48 +0000 (20:31 +0000)
Stop the service, if necessary, and clear away its symbolic link.

debian/tripe-peer-services.postinst

index db937debbe1dc6750833d599e06aa575ce3607d0..1a4754c5a1c030520441b2a99db6c4f3c032a592 100644 (file)
@@ -95,6 +95,46 @@ restart_services () {
   echo "."
 }
 
+retire_service () {
+  name=$1 version=$2
+
+  ## If the service is currently running, then ask it to stop.
+  if tripectl >/dev/null 2>&1 svcensure $name && \
+     ! tripectl >/dev/null 2>&1 svcensure $name $version~
+  then
+    tripectl svcsubmit $name quit
+  fi
+
+  ## Remove the symbolic link if it's there.
+  if [ -L /etc/tripe/services/$name ]; then
+    case $(readlink /etc/tripe/services/$name) in
+      /usr/lib/tripe/services/$name)
+       rm /etc/tripe/services/$name
+       ;;
+    esac
+  fi
+}
+
+case "$1" in
+  configure)
+    v=$2
+
+    ## Apply upgrades iteratively until we catch up with reality.
+    while :; do
+
+      ## Here, we killed the `watch' service.
+      if dpkg --compare-versions "$v" lt-nl 1.0.0pre14~; then
+       retire_service watch 1.0.0pre14
+       v=1.0.0pre14
+
+      ## No more updates to apply.
+      else
+       break
+      fi
+    done
+    ;;
+esac
+
 restart_services conntrack connect
 
 #DEBHELPER#