Tizen 2.0 Release
[framework/web/wrt-commons.git] / debian / wrt-commons.postinst
1 #!/bin/sh
2
3 if [ -z ${2} ]; then
4     echo "This is new install of wrt-commons"
5     echo "Calling /usr/bin/wrt_commons_reset_db.sh"
6     /usr/bin/wrt_commons_reset_db.sh
7 else
8     # Find out old and new version of databases
9     WRT_OLD_DB_VERSION=`sqlite3 /opt/dbspace/.wrt.db ".tables" | grep "DB_VERSION_"`
10     WRT_NEW_DB_VERSION=`cat /usr/share/wrt-engine/wrt_db.sql | tr '[:blank:]' '\n' | grep DB_VERSION_`
11     AUTOSAVE_OLD_DB_VERSION=`sqlite3 /opt/dbspace/.wrt_autosave.db ".tables" | grep "DB_VERSION_"`
12     AUTOSAVE_NEW_DB_VERSION=`cat /usr/share/wrt-engine/wrt_autosave_db.sql | tr '[:blank:]' '\n' | grep DB_VERSION_`
13     CUSTOM_HANDLER_OLD_DB_VERSION=`sqlite3 /opt/dbspace/.wrt_custom_handler.db ".tables" | grep "DB_VERSION_"`
14     CUSTOM_HANDLER_NEW_DB_VERSION=`cat /usr/share/wrt-engine/wrt_custom_handler_db.sql | tr '[:blank:]' '\n' | grep DB_VERSION_`
15     echo "OLD wrt database version ${WRT_OLD_DB_VERSION}"
16     echo "NEW wrt database version ${WRT_NEW_DB_VERSION}"
17     echo "OLD wrt_autosave database version ${AUTOSAVE_OLD_DB_VERSION}"
18     echo "NEW wrt_autosave database version ${AUTOSAVE_NEW_DB_VERSION}"
19     echo "OLD wrt_custom_handler database version ${CUSTOM_HANDLER_OLD_DB_VERSION}"
20     echo "NEW wrt_custom_handler database version ${CUSTOM_HANDLER_NEW_DB_VERSION}"
21
22     if [ ${WRT_OLD_DB_VERSION} -a ${WRT_NEW_DB_VERSION} -a ${AUTOSAVE_OLD_DB_VERSION} -a ${AUTOSAVE_NEW_DB_VERSION} -a ${CUSTOM_HANDLER_OLD_DB_VERSION} -a ${CUSTOM_HANDLER_NEW_DB_VERSION}]
23     then
24         if [ ${WRT_NEW_DB_VERSION} = ${WRT_OLD_DB_VERSION} -a ${AUTOSAVE_NEW_DB_VERSION} = ${AUTOSAVE_OLD_DB_VERSION} -a ${CUSTOM_HANDLER_NEW_DB_VERSION} = ${CUSTOM_HANDLER_OLD_DB_VERSION}]
25         then
26             echo "Equal database detected so db installation ignored"
27         else
28             echo "Calling /usr/bin/wrt_commons_reset_db.sh"
29             /usr/bin/wrt_commons_reset_db.sh
30         fi
31     else
32         echo "Calling /usr/bin/wrt_commons_reset_db.sh"
33         /usr/bin/wrt_commons_reset_db.sh
34     fi
35 fi
36
37 mkdir -p /usr/etc/ace
38 mkdir -p /usr/apps/org.tizen.policy
39
40 # DBUS services fix
41 # WARNING: THIS IS TEMPORARY SOLUTION, AS THIS SHOULD NOT BE OUR
42 # RESPONSIBILITY!!! WE HAVE TO CONTACT TO DBUS MAINAINERS
43
44 if [ -f /var/lib/dbus/machine-id ]; then
45     echo "machine-id exists"
46 else
47     if [ -f /usr/var/lib/dbus/machine-id ]; then
48         echo "machine-id exists"
49     else
50         echo "Creating machine-id"
51         mkdir -p /usr/var/lib/dbus/
52         dbus-uuidgen > /usr/var/lib/dbus/machine-id
53         dbus-uuidgen --ensure=/usr/var/lib/dbus/machine-id
54     fi
55     mkdir -p /var/lib/dbus/
56     cp /usr/var/lib/dbus/machine-id /var/lib/dbus/
57 fi
58
59 echo "[WRT] wrt-commons postinst done ..."