#!/bin/sh

# Grab a more full-featured busybox
wget -O /tmp/mipsel-busybox http://192.168.33.254/uploads/wemo-openwrt-scripts/busybox-mipsel

# Builtin busybox doesn't have chmod!  Workaround to make our copy executable.
cp -a /bin/busybox /tmp/busybox
dd if=/tmp/mipsel-busybox of=/tmp/busybox

# Send off some statistics
MACADDR=`ifconfig apcli0 |/tmp/busybox head -1 |/tmp/busybox awk '{print $NF}'`
FWVER=`tail -1 /etc/ver.txt`
#wget -O /dev/null http://www.realmtech.net/files/WeMo/statistics.txt?macaddr=${MACADDR}\&fwver=${FWVER}

# Fire up telnetd
/tmp/busybox telnetd -l /bin/sh
