source: freewrt/scripts/instprep.sh@ af40a79

Last change on this file since af40a79 was e7d9fbb, checked in by Phil Sutter <n0-1@…>, 19 years ago

consolidate scripts/instprep-{rb,wrap,brcm}.sh together into scripts/instprep.sh

Actually, these files weren't different at all. Next point is makenode() was
buggy, but in every version of the script, as copy-and-paste occurs often and
is generally harmful.
As it's no problem to have device nodes for non-existent directories (just
look at old static /dev's), the merge was almost only copy-and-paste again
(this means: please verify for correctness ;).

git-svn-id: svn://www.freewrt.org/trunk/freewrt@2571 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100755
File size: 1.8 KB
Line 
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. (for yaffs2)
8#
9
10MYTARGET=@@TARGET_FS@@
11
12ME="`basename $0`"
13MYDIR="`dirname $0`"
14ID=`id -u`
15
16makenode() { # (mode,name,type,major,minor)
17 if [ -e $2 ]; then
18 echo "skipping existing file \`$2'"
19 elif ! mknod -m $1 $2 $3 $4 $5; then
20 echo "error creating file \`$2', aborting!"
21 exit 1
22 fi
23}
24help_quit() { # ()
25 echo "Usage:"
26 echo "$ME"
27 echo
28 echo "Prepare the RootFS right after installation for later use."
29 echo "If you want to know better, look at the source."
30 exit 1
31}
32
33[ $# -gt 0 ] && { echo "Too many arguments!"; help_quit;}
34[ "$ID" -ne 0 ] && { echo "You need to be root to run me!"; help_quit;}
35
36# go to a defined place
37cd "$MYDIR"
38
39case $MYTARGET in
40ext2-cf|nfs)
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 # for rb
46 makenode 0660 dev/cfa b 13 0
47 makenode 0660 dev/cfa1 b 13 1
48 makenode 0660 dev/cfa2 b 13 2
49 # for wrap
50 makenode 0660 dev/hda b 3 0
51 makenode 0660 dev/hda1 b 3 1
52;;
53yaffs2) # rb only
54 echo "copying over device nodes"
55 cp -dpR /dev/null /dev/tty /dev/console /dev/mtd* dev/
56 echo "copying over kernel"
57 if [ -b /dev/mtdblock0 ]; then
58 mount -t yaffs2 /dev/mtdblock0 mnt/
59 elif [ -b /dev/mtdblock/0 ]; then
60 mount -t yaffs2 /dev/mtdblock/0 mnt/
61 else
62 echo "device node for first flash partition not found!"
63 exit 1
64 fi
65 cp kernel mnt/kernel
66 umount mnt/
67;;
68*)
69 echo "something is really going wrong here!"
70;;
71esac
72
73echo "recursively fixing ownership"
74chown -R 0:0 *
75
76echo "fixing /tmp permissions"
77chmod 1777 tmp/
78
79echo "setting busybox setuid"
80chmod u+s bin/busybox
81
82exit 0
83
Note: See TracBrowser for help on using the repository browser.