| 1 | #!/bin/sh
|
|---|
| 2 | #
|
|---|
| 3 | # Prepare the RootFS for later use. Depending on
|
|---|
| 4 | # the chosen target device type, do some of the following:
|
|---|
| 5 | # * Create initial set of device nodes.
|
|---|
| 6 | # * Recursively change owner to root.
|
|---|
| 7 | # * Copy kernel to flash.
|
|---|
| 8 | #
|
|---|
| 9 |
|
|---|
| 10 | MYTARGET=@@TARGET_FS@@
|
|---|
| 11 |
|
|---|
| 12 | ME="`basename $0`"
|
|---|
| 13 | ID=`id -u`
|
|---|
| 14 |
|
|---|
| 15 | makenode() { # (name,type,major,minor)
|
|---|
| 16 | if [ -c $1 ]; then
|
|---|
| 17 | echo "skipping existing file \`$1'"
|
|---|
| 18 | elif ! mknod $1 $2 $3 $4; then
|
|---|
| 19 | echo "error creating file \`$1', aborting!"
|
|---|
| 20 | exit 1
|
|---|
| 21 | fi
|
|---|
| 22 | }
|
|---|
| 23 | help_quit() { # ()
|
|---|
| 24 | echo "Usage:"
|
|---|
| 25 | echo "$ME"
|
|---|
| 26 | echo
|
|---|
| 27 | echo "Prepare the RootFS right after installation for later use."
|
|---|
| 28 | echo "If you want to know better, look at the source."
|
|---|
| 29 | exit 1
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | [ $# -gt 0 ] && { echo "Too many arguments!"; help_quit;}
|
|---|
| 33 | [ "$ID" -ne 0 ] && { echo "You need to be root to run me!"; help_quit;}
|
|---|
| 34 |
|
|---|
| 35 | # check for myself in current dir
|
|---|
| 36 | if [ ! -f "${PWD}/$ME" ]; then
|
|---|
| 37 | cd `dirname $0`
|
|---|
| 38 | fi
|
|---|
| 39 |
|
|---|
| 40 | case $MYTARGET in
|
|---|
| 41 |
|
|---|
| 42 | ext2-cf|nfs)
|
|---|
| 43 | echo "creating device nodes"
|
|---|
| 44 | makenode dev/null c 1 3
|
|---|
| 45 | makenode dev/tty c 5 0
|
|---|
| 46 | makenode dev/console c 5 1
|
|---|
| 47 | makenode dev/cfa b 13 0
|
|---|
| 48 | makenode dev/cfa1 b 13 1
|
|---|
| 49 | makenode dev/cfa2 b 13 2
|
|---|
| 50 | ;;
|
|---|
| 51 |
|
|---|
| 52 | yaffs2)
|
|---|
| 53 | echo "copying over device nodes"
|
|---|
| 54 | cp -dpR /dev/null /dev/tty /dev/console /dev/mtd* dev/
|
|---|
| 55 | echo "copying over kernel"
|
|---|
| 56 | if [ -b /dev/mtdblock0 ]; then
|
|---|
| 57 | mount -t yaffs2 /dev/mtdblock0 mnt/
|
|---|
| 58 | elif [ -b /dev/mtdblock/0 ]; then
|
|---|
| 59 | mount -t yaffs2 /dev/mtdblock/0 mnt/
|
|---|
| 60 | else
|
|---|
| 61 | echo "device node for first flash partition not found!"
|
|---|
| 62 | exit 1
|
|---|
| 63 | fi
|
|---|
| 64 | cp kernel mnt/kernel
|
|---|
| 65 | umount mnt/
|
|---|
| 66 | ;;
|
|---|
| 67 |
|
|---|
| 68 | *)
|
|---|
| 69 | echo "something is really going wrong here!"
|
|---|
| 70 | ;;
|
|---|
| 71 |
|
|---|
| 72 | esac
|
|---|
| 73 |
|
|---|
| 74 | echo "recursively fixing ownership"
|
|---|
| 75 | chown -R root:root *
|
|---|
| 76 |
|
|---|
| 77 | exit 0
|
|---|
| 78 |
|
|---|