
# Make tmp
if [ ! -d /tmp ]; then 
    mount -o rw,remount / && mkdir /tmp && mount -o rw,remount /
fi
if [ ! -f /tmp/.mounted ] ; then 
    mount -t tmpfs none /tmp && touch /tmp/.mounted
fi

# Start dropbear
if [ ! -f /tmp/dropbear.pid ] ; then
    dropbear -s -P /tmp/dropbear.pid;
fi

# setup posix shared memory
if [ ! -d /dev/shm ] ; then mkdir /dev/shm ; fi
chmod 1777 /dev/shm
mount -t tmpfs none /dev/shm/

# configure debian chroot
if [ -d /sd-ext/debian/proc ] && [ ! -d /sd-ext/debian/proc/1 ] ; then
   mount -o bind /proc /sd-ext/debian/proc
fi
if [ -d /sd-ext/debian/dev/.udev ] ; then
   mount -o bind /dev /sd-ext/debian/dev
   mount -o bind /dev/pts /sd-ext/debian/dev/pts
   mount -o bind /dev/shm /sd-ext/debian/dev/shm
fi

# start debian ssh
chroot /sd-ext/debian service ssh start

# mount sd in debian
if [ -d /mnt/sdcard/Android ] && [ -d /sd-ext/debian/mnt/sdcard/ ] && [ ! -d /sd-ext/debian/mnt/sdcard/Android ] ; 
then
   mount -o bind /mnt/sdcard /sd-ext/debian/mnt/sdcard
fi


