source: freewrt/scripts/instprep.sh@ eab0bcd

Last change on this file since eab0bcd was eab0bcd, checked in by Thorsten Glaser <tg@…>, 19 years ago

these shall not be executable nor use absolute pathnames,
since perl doesn't always live in /usr/bin (e.g. NetBSD®)

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

  • Property mode set to 100644
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.