#!/bin/sh

RCS=/etc/init.d/rcS
MENU=/usr/lib/enigma2/python/AAF/Menu/aafmain.cfg
TMP=/tmp/tmpfile~

FILES="/lib/modules/zd1211b.ko /lib/modules/zd1211.ko \
/etc/wpa_supplicant.conf.clear /etc/wpa_supplicant.conf.wep /etc/wpa_supplicant.conf.wpa \
/etc/wpa_supplicant.conf.wpa2 /etc/wlan_mode \
/etc/init.d/wlan.sh /etc/init.d/wlan-heartbeat.sh \
/var/run/wpa_supplicant.pid /var/run/udhcpc-wlan.pid \
/usr/bin/ifrename /usr/bin/iwconfig /usr/bin/iwevent /usr/bin/iwgetid /usr/bin/iwlist /usr/bin/iwpriv /usr/bin/iwspy \
/usr/bin/wpa_cli /usr/bin/wpa_supplicant /usr/lib/libiw.so.29 \
/var/etc/uninst/WLan-Uninstall.sh"

DIRS="/var/run/wpa_supplicant.socket /usr/share/udhcpc \
/usr/lib/enigma2/python/AAF/Menu/Wlan"

for i in $FILES; do
   rm -f $i
done

for i in $DIRS; do
   rm -Rf $i
done

LN=`grep -n "# ------------------ AAF WLAN Plugin ----- begin ----------" $RCS | cut -d":" -f1`
if [ ! -z $LN ]; then
   CNT=6
   while [ $CNT -gt 0 ]; do
      sed -e $LN'd' $RCS > $TMP
      mv -f $TMP $RCS
      CNT=`expr $CNT - 1`
   done
fi
rm -f $TMP
chmod 755 $RCS

LN=`grep -n "M:Wlan/wlan:WLan-Settings" $MENU | cut -d":" -f1`
if [ ! -z $LN ]; then
   sed -e $LN'd' $MENU > $TMP
   mv -f $TMP $MENU
fi
rm -f $TMP

sync
