2010-08-21, 22:37
I was trying to explain what function f_AgtB(){ } is the scrit auto update so you know what it does if you read all code under that version-check is how the script knows theres an update or not.
and the rest are just script dependencies.
I now added a comment that explains this just before function f_AgtB(){ } on script shows now on script is as below.
This is posted so you understand what this function does exactly.
it is fairly clear what that does. I didnt actually code that, this was andy back when he was main developer, again it works so why mess with it
and the rest are just script dependencies.
I now added a comment that explains this just before function f_AgtB(){ } on script shows now on script is as below.
This is posted so you understand what this function does exactly.
Code:
# f_AgtB is the script auto-update function it
# enables script to receive remote updates at every run
# also offers changelog review
function f_AgtB(){
cd $APPLOC
wget -nc -q http://dl.dropbox.com/u/4325533/XCI/version-check >> ~/setup/logs/xci-script-upgrade.log
if [ "$BETA" != "true" ]; then
a=$(grep "VERSION" version-check | awk -F\" '{print $(NF-1)}')
elif [ "$BETA" = "true" ]; then
a=$(grep "BETAVER" version-check | awk -F\" '{print $(NF-1)}')
fi
b=$VERSION
if [ "${a}" != "" -a "${b}" != "" ]
then
len_a=${#a}
len_b=${#b}
if [ $len_a -gt $len_b ]
then
b=${b}`f_add_zeros $(( $len_a - $len_b ))`
else
a=${a}`f_add_zeros $(( $len_b - $len_a ))`
fi
a=`echo $a | sed 's/\.//'`
b=`echo $b | sed 's/\.//'`
if [ $a -gt $b ]
then
echo 1
else
echo 0
fi
fi
}
function f_add_zeros(){
i=0
while [ $i -lt $1 ]
do
out=${out}0
((i++))
done
echo $out
}
function Update_Check(){
while [ `f_AgtB $a $b` == 1 ] ; do
if [ "$BETA" != "true" ]; then
NEWVERSION=$(grep "VERSION" version-check | awk -F\" '{print $(NF-1)}')
NEWINFOTEXT=$(grep "INFOTEXT" version-check | awk -F\" '{print $(NF-1)}')
elif [ "$BETA" = "true" ]; then
NEWVERSION=$(grep "BETAVER" version-check | awk -F\" '{print $(NF-1)}')
NEWINFOTEXT=$(grep "BETAINFOTEXT" version-check | awk -F\" '{print $(NF-1)}')
fi
dialog --colors --yes-label " Yes Please " --no-label "Not Now" --help-button --help-label "XCI Changelog" --title "\Z1[ INFORMATION ]\Zn" --yesno "\nXCI Version \Z1$NEWVERSION\Zn is now available to download.\nWould you like to download it now or later?" 8 53
case $? in
0)
dialog --colors --title "\Z1[ UPDATING ]\Zn" --infobox " Please wait..." 3 25
rm -f xbmc-installer.sh >> ~/setup/logs/xci-script-upgrade.log
rm -f xci.sh >> ~/setup/logs/xci-script-upgrade.log
if [ "$BETA" != "true" ]; then
wget -nc -q http://dl.dropbox.com/u/4325533/XCI/xci.sh >> ~/setup/logs/xci-script-upgrade.log
elif [ "$BETA" = "true" ]; then
wget -nc -q http://dl.dropbox.com/u/4325533/XCI/Beta/xci.sh >> ~/setup/logs/xci-script-upgrade.log
fi
chmod +x xci.sh
ln -s xci.sh xbmc-installer.sh
sudo ./xci.sh
exit 1;;
1)
break;;