#!/opt/bin/busybox sh

bb_fc=`/opt/bin/busybox readlink -f /opt/bin/busybox`
for file in /opt/bin/*; do
    if [ -L $file  -a "`/opt/bin/busybox readlink -f $file`" = $bb_fc ]; then
       /opt/bin/busybox rm -f $file
    fi
done

for file in /opt/sbin/*; do
    if [ -L $file  -a "`/opt/bin/busybox readlink -f $file`" = $bb_fc ]; then
       /opt/bin/busybox rm -f $file
    fi
done

cd /opt
for applet in $(/opt/bin/busybox cat share/busybox_applets.lst.dist)
do
    if [ ! -e $applet ]
    then
       /opt/bin/busybox ln -s /opt/bin/busybox $applet
    else
       echo "Warning: '/opt/$applet' is already exists, skipping."
    fi
done
