summaryrefslogtreecommitdiff
path: root/install_widgets.sh
blob: a2f0c0fef732bbafefba7dd3c3f17c29d350d704 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh

. /etc/tizen-platform.conf

function info() {
	local ts=$(date +%Y%m%d.%H%M%S)
	echo $ts "$@" >&2
}

function do_install() {
	info "------------- wrt_widgets install start --------------"

	local wgtdir=${TZ_SYS_SHARE}/widget_demo
	if [ -n "$(ls $wgtdir/*.wgt 2> /dev/null)" ]; then
		local nbinstall=0
		for wgt in $(grep "^$USER" $wgtdir/install.conf | cut -f2 -d':'); do
			info "installing $wgt" 
			local try=1
			local ok=0
			while [ $try -le 3 ]; do
				pkgcmd -i -q -t wgt -p $wgtdir/$wgt && { ok=1; break; }
				try=$((try+1))
				sleep 3
			done
			[ $ok -eq 1 ] && {
				info "$wgt installed successfully" 
				nbinstall=$((nbinstall+1))
			} || info "failed to install $wgt" 
		done

		# signal tz-launcher that new apps were installed
		info "$nbinstall applications installed" 
		if [ $nbinstall -gt 0 ]; then
			info "sending restart signal to tz-launcher"
			pkill -U $UID -USR1 tz-launcher
		fi
	else
	   info "$wgtdir doesn't contains any widgets (.wgt)" 
	fi

	info "------------- wrt_widgets install end --------------"
}

do_install >>~/.applications/install.log 2>&1 

touch ~/.applications/install_done

# never fail
exit 0