| 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 |
|
|---|
| 8 | MYTARGET=@@TARGET_FS@@
|
|---|
| 9 |
|
|---|
| 10 | ME="`basename $0`"
|
|---|
| 11 | ID=`id -u`
|
|---|
| 12 |
|
|---|
| 13 | makenode() { # (mode,name,type,major,minor)
|
|---|
| 14 | if [ -c $1 ]; then
|
|---|
| 15 | echo "skipping existing file \`$1'"
|
|---|
| 16 | elif ! mknod -m $1 $2 $3 $4 $5; then
|
|---|
| 17 | echo "error creating file \`$1', aborting!"
|
|---|
| 18 | exit 1
|
|---|
| 19 | fi
|
|---|
| 20 | }
|
|---|
| 21 | help_quit() { # ()
|
|---|
| 22 | echo "Usage:"
|
|---|
| 23 | echo "$ME"
|
|---|
| 24 | echo
|
|---|
| 25 | echo "Prepare the RootFS right after installation for later use."
|
|---|
| 26 | echo "If you want to know better, look at the source."
|
|---|
| 27 | exit 1
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | [ $# -gt 0 ] && { echo "Too many arguments!"; help_quit;}
|
|---|
| 31 | [ "$ID" -ne 0 ] && { echo "You need to be root to run me!"; help_quit;}
|
|---|
| 32 |
|
|---|
| 33 | # check for myself in current dir
|
|---|
| 34 | if [ ! -f "${PWD}/$ME" ]; then
|
|---|
| 35 | cd `dirname $0`
|
|---|
| 36 | fi
|
|---|
| 37 |
|
|---|
| 38 | case $MYTARGET in
|
|---|
| 39 |
|
|---|
| 40 | ext2-cf)
|
|---|
| 41 | echo "creating device nodes"
|
|---|
| 42 | makenode 0666 dev/null c 1 3
|
|---|
| 43 | makenode 0666 dev/tty c 5 0
|
|---|
| 44 | makenode 0622 dev/console c 5 1
|
|---|
| 45 | makenode 0660 dev/hda b 3 0
|
|---|
| 46 | makenode 0660 dev/hda1 b 3 1
|
|---|
| 47 | ;;
|
|---|
| 48 |
|
|---|
| 49 | *)
|
|---|
| 50 | echo "something is really going wrong here!"
|
|---|
| 51 | ;;
|
|---|
| 52 |
|
|---|
| 53 | esac
|
|---|
| 54 |
|
|---|
| 55 | echo "recursively fixing ownership"
|
|---|
| 56 | chown -R 0:0 *
|
|---|
| 57 | echo "fixing busybox permissions"
|
|---|
| 58 | if [ -x bin/busybox ];then chmod 4755 bin/busybox;fi
|
|---|
| 59 | echo "fixing /tmp permissions"
|
|---|
| 60 | chmod 1777 tmp
|
|---|
| 61 |
|
|---|
| 62 | exit 0
|
|---|
| 63 |
|
|---|