#!/bin/sh


mkdir /run/media -p
mount --bind /ubi/etc /etc
mount --bind /ubi/local /usr/local
mount --bind /run/media /media

if [ -f /ubi/reset.tar.gz ]; then
	rm -rf /ubi/reset
	gzip -d  /ubi/reset.tar.gz -c | tar -x -C /ubi
	rm -rf /ubi/reset.tar.gz
fi

# Start all init scripts in /etc/init.d
# executing them in numerical order.
#
for i in /etc/init.d/S??* ;do

     # Ignore dangling symlinks (if any).
     [ ! -f "$i" ] && continue

     if [ "$i" == "/etc/init.d/S50telnet" ]; then
	     continue
     fi

     if [ "$i" == "/etc/init.d/S70vsftpd" ]; then
	     continue
     fi

     case "$i" in
	*.sh)
	    # Source shell script for speed.
	    (
		trap - INT QUIT TSTP
		set start
		. $i
	    )
	    ;;
	*)
	    # No sh extension, so fork subprocess.
	    $i start
	    ;;
    esac
done

