Initialize Tizen 2.3
[framework/web/wrt-commons.git] / etc / wrt_commons_reset_db.sh
1 #!/bin/sh
2 # Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 #
4 #    Licensed under the Apache License, Version 2.0 (the "License");
5 #    you may not use this file except in compliance with the License.
6 #    You may obtain a copy of the License at
7 #
8 #        http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #    Unless required by applicable law or agreed to in writing, software
11 #    distributed under the License is distributed on an "AS IS" BASIS,
12 #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #    See the License for the specific language governing permissions and
14 #    limitations under the License.
15 #
16
17 /bin/rm -rf /opt/share/widget/system/*
18 uninstall_widgets=1
19 if [ "$1" == "--old" ]
20 then
21     /bin/echo "Uninstalling turned off"
22     uninstall_widgets=0
23 fi
24 #Removing of widget desktop icons
25 WIDGET_EXEC_PATH=/opt/usr/apps/
26 WIDGET_PRELOAD_EXEC_PATH=/usr/apps/
27 WIDGET_DESKTOP_PATH=/opt/share/applications/
28 SMACK_RULES_PATH=/etc/smack/accesses.d/
29 WRT_DB=/opt/dbspace/.wrt.db
30 PKGMGR_DB=/opt/dbspace/.pkgmgr_parser.db
31
32 if [ -f ${WRT_DB} ]
33 then
34     PKG_NAME_SET=$(/usr/bin/sqlite3 $WRT_DB 'select tizen_appid from WidgetInfo;')
35     for appid in $PKG_NAME_SET
36     do
37         if [ $uninstall_widgets -eq 1 ]
38         then
39             wrt-installer -un $appid 1>/dev/null 2>&1
40         fi
41         pkgId=`echo "$appid" | cut -f1 -d"."`
42         /usr/bin/sqlite3 $PKGMGR_DB "delete from package_info where package=\"$pkgId\""
43         /usr/bin/sqlite3 $PKGMGR_DB "delete from package_app_info where app_id=\"$appid\""
44         /bin/rm -rf ${WIDGET_EXEC_PATH}${pkgId}
45         /bin/rm -rf ${WIDGET_PRELOAD_EXEC_PATH}${pkgId}
46         widget_desktop_file="${WIDGET_DESKTOP_PATH}${appid}.desktop";
47         if [ -f ${widget_desktop_file} ]; then
48             /bin/rm -f $widget_desktop_file;
49         fi
50         widget_smack_rule="${SMACK_RULES_PATH}${pkgId}"
51         if [ -f ${widget_smack_rule} ]; then
52             /bin/rm -f $widget_smack_rule;
53         fi
54     done
55 else
56     echo "${WRT_DB} doesn't exist"
57 fi
58
59 /usr/bin/wrt_commons_create_clean_db.sh
60
61 #update plugins
62 if [ -x /usr/bin/wrt-installer ]
63 then
64     /usr/bin/wrt-installer -p
65 fi