Revert "Fixed preinstall widget wasn't installed after factory reset"
[platform/framework/web/wrt-installer.git] / etc / wrt_preinstall_widgets.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 _working_dir="/opt/media/Downloads/.preinstallWidgets"
18 _widget_temp="/opt/apps/widget/*";
19
20 install_widgets() {
21         _wgt_list=`find $_working_dir -name '*.wgt'`
22         for list in $_wgt_list
23         do
24                 echo "Install $list"
25                 wrt-installer -i $list 
26         done
27
28         rm -rf $_working_dir
29 }
30
31 restore_widget() {
32 #Remove temporary directory during widget installation
33 for file in $_widget_temp; do
34     if [[ -d $file  &&  ${file#*temp_[0-9]*} != $file ]]; then
35         rm -rf $file
36     fi
37 done
38
39
40 #Reinstall widget during booting
41 _temp_widget_path=/opt/apps/widget/temp_info
42
43 FILE_LIST=`ls $_temp_widget_path`
44
45 if [ -n "$FILE_LIST" ]; then
46     echo "There are widgets to need reinstall."
47     for widget in $FILE_LIST; do
48         FILE_NAME=$_temp_widget_path/$widget
49         line=`cat $FILE_NAME`
50         echo "----------------------------------------------------------------"
51         echo "UnInstalling widget : $line ..."
52         wrt-installer -up $line
53         echo "Installing widget : $line ..."
54         wrt-installer -i $line
55     done
56 else
57     echo "There is no reinstall widget."
58 fi
59 }
60
61 if [ ! -d $_working_dir ]; then
62         echo "There is no preinstall widget directory - $_working_dir"
63     restore_widget
64         exit 1
65 fi
66
67 install_widgets