Version 0.7-0
[vicar] / qtc_packaging / debian_fremantle / postinst
1 #!/bin/sh
2 # postinst script for vicar
3 #
4 # see: dh_installdeb(1)
5
6 set -e
7
8 # summary of how this script can be called:
9 #        * <postinst> `configure' <most-recently-configured-version>
10 #        * <old-postinst> `abort-upgrade' <new version>
11 #        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
12 #          <new-version>
13 #        * <postinst> `abort-remove'
14 #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
15 #          <failed-install-package> <version> `removing'
16 #          <conflicting-package> <version>
17 # for details, see http://www.debian.org/doc/debian-policy/ or
18 # the debian-policy package
19
20
21 case "$1" in
22     configure)
23
24         eval $(dbus-launch --sh-syntax)
25         export DBUS_SESSION_BUS_ADDRESS
26         export DBUS_SESSION_BUS_PID
27
28         # Kill any running instances of the daemon (only used on Linux based systems)
29         killall -q vicar-daemon || true
30         killall -q vicar-telepathy || true
31
32         echo "Checking for log folder ..."
33         [[ ! -d /var/log/vicar ]] && mkdir /var/log/vicar
34
35         echo "Checking for log file ..."
36         [[ ! -e /var/log/vicar/vicar.log ]] && touch /var/log/vicar/vicar.log && chown -R user:users /var/log/vicar
37
38         echo "Starting Vicar daemon ..."
39         [[ -x /opt/vicar/bin/vicar-daemon ]] && su - user -c "exec /opt/vicar/bin/vicar-daemon& >/dev/null"
40
41         echo "Starting Vicar-Telepathy ..."
42         [[ -x /opt/vicar/bin/vicar-telepathy ]] && su - user -c "exec /opt/vicar/bin/vicar-telepathy& >/dev/null"
43
44         echo "Creating Vicar Telepathy account ..."
45         [[ -x /opt/vicar/bin/vicar-utils ]] && su - user -c "exec /opt/vicar/bin/vicar-utils INSTALL"
46
47         echo "Updating permissions on Vicar DB file ..."
48         [[ -e /home/user/vicar.db.sqlite ]] && chown user:users /home/user/vicar.db.sqlite
49
50         echo "Creating Vicar Profiles database ..."
51         [[ -x /opt/vicar/bin/vicar-utils ]] && su - user -c "exec /opt/vicar/bin/vicar-utils CREATEDB"
52
53     ;;
54
55     abort-upgrade|abort-remove|abort-deconfigure)
56     ;;
57
58     *)
59         echo "postinst called with unknown argument \`$1'" >&2
60         exit 1
61     ;;
62 esac
63
64 # dh_installdeb will replace this with shell code automatically
65 # generated by other debhelper scripts.
66
67 #DEBHELPER#
68
69 exit 0
70
71