#!/bin/sh # # Version 1.0 - by Mick Hellstrom (2005) exec > /dev/tty0 2>&1 setup() { count=0 #################### echo -n "#### 1. Checking MMC: " while [ ! -f /media/card/loopfs.boot ] do sleep 1 echo -n "#" let "count += 1" if [ "$count" = "16" ] then echo "" echo "No MMC found - continuing with normal boot." exit fi done echo "" echo "Found MMC!" FILE="`cat /media/card/loopfs.boot`" if [ ! -f $FILE ] then echo "Ooops - loopfs file $FILE is missing." exit fi echo "Using loopfs: $FILE" #################### echo "#### 2. FSCK filesystem:" e2fsck -p $FILE #################### echo "#### 3. Setting up loopback FS:" modprobe loop losetup /dev/loop/0 $FILE #################### echo "#### 4. Mounting:" mount -o noatime /dev/loop/0 /mnt/loop #################### echo "#### 5. Ballet:" cd /mnt/loop if [ ! -h dev ] then mv dev dev-OLD ln -s /mnt/realroot/dev fi if [ ! -h proc ] then mv proc proc-OLD ln -s /mnt/realroot/proc fi if [ ! -h tmp ] then mv tmp tmp-OLD ln -s /mnt/realroot/tmp fi if [ ! -h var ] then mv var var-OLD ln -s /mnt/realroot/var fi if [ ! -h root ] then mv root root-OLD ln -s /mnt/realroot/home/root fi if [ ! -f MMC ] then touch MMC fi if grep '^root:.:' etc/passwd; then # No root password! Use current root password. mv etc/passwd etc/passwd-SAVED grep '^root' /etc/passwd > etc/passwd grep -v '^root' etc/passwd-SAVED > etc/passwd fi if [ ! -d mnt/realroot ] then mkdir -p mnt/realroot fi pivot_root . mnt/realroot #################### echo "#### 6. Tidying up:" killall Xfbdev #################### echo "#### 7. Handover:" # if [ -x /sbin/unconfigured.sh ] # then # /sbin/unconfigured.sh # fi # # if [ -x /sbin/setup.sh ] # then # /sbin/setup.sh # fi } case $1 in 'start') setup ;; 'stop') killall sshd apmd portmap cd /mnt/realroot pivot_root . /mnt/realroot ;; *) setup ;; esac