chiark / gitweb /
Clean up properly in postrm.
authorRichard Kettlewell <rjk@greenend.org.uk>
Thu, 5 Jun 2008 11:21:42 +0000 (12:21 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Thu, 5 Jun 2008 11:21:42 +0000 (12:21 +0100)
  For --remove we just remove cached data and infrastructure.
  For --purge we remove everything.

debian/postrm.disorder-server

index 97ed6c4..99488dd 100755 (executable)
 #
 set -e
 
+state=/var/lib/disorder
+
+# For --remove we only delete cachable stuff
+cleanup_remove() {
+  rm -f $state/lock
+  rm -f $state/socket
+  rm -f $state/speaker/socket
+  [ -d $state/speaker ] && rmdir $state/speaker || true
+  rm -f $state/log.*
+  rm -f $state/__db.*
+  rm -f $state/noticed.db
+  rm -f $state/search.db
+  rm -f $state/tags.db
+  rm -f $state/tracks.db
+}
+
+# For --purge we delete everything
+cleanup_purge() {
+  rm -f /etc/disorder/conf.debconf
+  rm -f $state/queue
+  rm -f $state/recent
+  rm -f $state/global.db
+  rm -f $state/prefs.db
+  rm -f $state/schedule.db
+  rm -f $state/users.db
+}
+
 case "$1" in
+remove )
+  cleanup_remove
+  ;;
 purge )
   if [ -e /usr/share/debconf/confmodule ]; then
     . /usr/share/debconf/confmodule
     db_purge
   fi
   update-rc.d disorder remove
-  rm -f /etc/disorder/conf.debconf
-  # TODO - should we delete none/some/all of the contents of /var/lib/disorder?
+  cleanup_remove
+  cleanup_purge
   ;;
 esac