summaryrefslogtreecommitdiff
path: root/install_widgets.sh
blob: 239087384b39bc13d6afe63d3c04719001facd65 (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
				flock -w 30 -e /tmp/pkgcmd_lock pkgcmd -i -q -t wgt -p $wgtdir/$wgt && { ok=1; break; }
				try=$((try+1))
				sleep 1
			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 -USR1 -U $UID 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