Initial commit of the Debian packaging for Diablo.
[browser-switch] / debian / postrm
1 #!/bin/sh
2 # postrm script for browser-proxy
3 #
4 # see: dh_installdeb(1)
5
6 set -e
7
8 # summary of how this script can be called:
9 #        * <postrm> `remove'
10 #        * <postrm> `purge'
11 #        * <old-postrm> `upgrade' <new-version>
12 #        * <new-postrm> `failed-upgrade' <old-version>
13 #        * <new-postrm> `abort-install'
14 #        * <new-postrm> `abort-install' <old-version>
15 #        * <new-postrm> `abort-upgrade' <old-version>
16 #        * <disappearer's-postrm> `disappear' <overwriter>
17 #          <overwriter-version>
18 # for details, see http://www.debian.org/doc/debian-policy/ or
19 # the debian-policy package
20
21 kill_old_proxies() {
22         # This would be so much nicer with pgrep/pkill ...
23         proxy_pids=`busybox ps | fgrep "python /usr/bin/browser-proxy" | fgrep -v grep | awk '{ print $1 }'`
24         if [ ! -z "$proxy_pids" ]; then
25                 kill $proxy_pids
26         fi
27 }
28
29 case "$1" in
30     remove)
31         dpkg-divert --remove --package browser-proxy --rename \
32             --divert /usr/bin/browser.tablet-browser-ui \
33             /usr/bin/browser
34         dpkg-divert --remove --package browser-proxy --rename \
35             --divert /usr/share/dbus-1/services/com.nokia.osso_browser.tablet-browser-ui \
36             /usr/share/dbus-1/services/com.nokia.osso_browser.service
37         # Try to make dbus-daemon pick up the change in services file
38         kill -HUP `pidof dbus-daemon`
39
40         # Kill off any running browser-proxy to make sure that the default
41         # browser gets launched
42         kill_old_proxies
43         ;;
44     upgrade|disappear)
45         # Kill off any running browser-proxy to make sure that the new version
46         # gets launched the next time a D-Bus request is made
47         kill_old_proxies
48         ;;
49     purge|failed-upgrade|abort-install|abort-upgrade)
50     ;;
51
52     *)
53         echo "postrm called with unknown argument \`$1'" >&2
54         exit 1
55     ;;
56 esac
57
58 # dh_installdeb will replace this with shell code automatically
59 # generated by other debhelper scripts.
60
61 #DEBHELPER#
62
63 exit 0
64
65