summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/linhes_update2.sh
blob: 5c05c991199d0bba0538df9d3160e13233bf02ea (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
51
#!/bin/bash
#Called from LinHES Service Menu Updates Available Menu

if [[ "$1" = "install" ]]
then
    msg_client.py --msg "Updating...|middle" --timeout 600 --tag "Updating"
	sudo pacman -Su --force --noconfirm
    msg_client.py --clear --tag "Updating"
    msg_client.py --kill
    msg_client.py --msg "Updates complete.\nReturning to Main Menu.|middle"
	if grep linux /tmp/to_be_upgraded || grep nvidia /tmp/to_be_upgraded
	then
        msg_client.py --msg "Updates require a reboot.|middle"
	fi
else
    msg_client.py --msg "Updates canceled.|middle"
fi

sudo rm -fr /tmp/to_be_upgraded

if grep -q Updates\ Available /usr/share/mythtv/themes/defaultmenu/linhes.xml
then
	mv /usr/share/mythtv/themes/defaultmenu/linhes.xml /tmp/linhes.xml.tmp
	sed -e '/\#UpdatesAv/,/\#UpdatesAv/d' < /tmp/linhes.xml.tmp > /usr/share/mythtv/themes/defaultmenu/linhes.xml
	mv /usr/share/mythtv/themes/defaultmenu/linhes.xml /tmp
	grep -v -e /mythmenu /tmp/linhes.xml > /tmp/linhes.xml.tmp
	echo "<!--#Check for updates-->" >> /tmp/linhes.xml.tmp
	echo "   <button>" >> /tmp/linhes.xml.tmp
	echo "     <type>UPGRADE</type>" >> /tmp/linhes.xml.tmp
	echo "     <text>Update LinHES</text>" >> /tmp/linhes.xml.tmp
	echo "     <description>Update the LinHES system</description>" >> /tmp/linhes.xml.tmp
	echo "     <action>MENU update.xml</action>" >> /tmp/linhes.xml.tmp
	echo "   </button>" >> /tmp/linhes.xml.tmp
	echo "<!--#Check for updates-->" >> /tmp/linhes.xml.tmp
	echo "" >> /tmp/linhes.xml.tmp
	echo "</mythmenu>" >> /tmp/linhes.xml.tmp
	mv /tmp/linhes.xml.tmp /usr/share/mythtv/themes/defaultmenu/linhes.xml
fi

#hide LinHES update message on main menu
sudo sed -i '/LinHES UPDATE MESSAGE/c\        <!--LinHES UPDATE MESSAGE' /usr/share/mythtv/themes/LinHES/menu-ui.xml

#reload theme
#check if started from mythfrontend-start and if so just kill mfe
#otherwise reload mfe
if [[ `pgrep -fx "/bin/bash /usr/LH/bin/mythfrontend-start"` ]]
then
    killall mythfrontend
else
    pkill -USR1 mythfrontend
fi