#!/bin/ash 
#
#  script to remove and reinstall opie
#
# it's free so do not sell it
# (c) patrick s. vogt <tille@handhelds.org>

IPKG_REMOVE="ipkg remove"
IPKG_INSTALL="ipkg install"

echo "Upating opie"
pack=`ipkg status | grep Package | grep -i opie | grep -v update | sed  "s/Package://"`

echo "Stopping Opie"
/etc/init.d/opie stop || /etc/init.d/qpe stop

echo "start" > /tmp/update.log

for p in  $pack; do
echo "rem.  $p" >> /tmp/update.log
$IPKG_REMOVE $p
done
$IPKG_REMOVE qpe-pics
$IPKG_REMOVE ipaqalarm
$IPKG_REMOVE qpe2schedule
$IPKG_REMOVE uschedule

#might help
sync


echo "Updating"
`ipkg update`

for p in  $pack; do
echo "inst. $p" >> /tmp/update.log
$IPKG_INSTALL $p
done
$IPKG_INSTALL opie-pics
$IPKG_INSTALL opiealarm

ipkg remove opie-update

echo "Starting Opie"
/etc/init.d/opie start ||  /etc/init.d/qpe start