1#!/bin/sh
2
3cd "$(dirname "$0")"
4
5test "$1" = "-t" || exec Terminal -t "My Update" "$0" -t "$@" && shift
6
7notice () {
8	notify --type information \
9		--icon /boot/system/apps/HaikuDepot \
10		--title "Update" \
11		"$@"
12	echo "$@"
13}
14
15if [ "$1" != "-2" ]; then
16
17	notice "Closing Deskbar..."
18	notice "Checking for updates..."
19	quit application/x-vnd.Be-TSKB
20	sync
21	hrev_current="$(uname -v | cut -d' ' -f1)"
22	pkgman update
23	pkgman_err=$?
24	sync
25	if [ $pkgman_err -gt 0 -o "$(ls /system/packages/*_hrev*-* | grep -v $hrev_current)" = "" ]; then
26		open /system/Deskbar < /dev/null > /dev/null 2>&1 &
27		notice "Restarting Deskbar..."
28		#notice "Nothing to do"
29		read -p "Press a key..."
30		exit $pkgman_err
31	fi
32	makebootable /boot
33	sync
34	notice "Restarting Deskbar..."
35	/system/Deskbar < /dev/null > /dev/null 2>&1 &
36	notice "You should reboot now..."
37	shutdown -r -a
38	sleep 5
39	#read
40	exit 0
41fi
42
43rm $(finddir B_USER_SETTINGS_DIRECTORY)/boot/launch/myupdate2.sh
44
45