source: freewrt/scripts/instprep-rb.sh@ 655dec8

Last change on this file since 655dec8 was 6d90218, checked in by Waldemar Brodkorb <wbx@…>, 19 years ago

set busybox setuid bit

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

  • Property mode set to 100755
File size: 1.7 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.
8#
9
10MYTARGET=@@TARGET_FS@@
11
12ME="`basename $0`"
13ID=`id -u`
14
15makenode() { # (mode,name,type,major,minor)
16 if [ -c $1 ]; then
17 echo "skipping existing file \`$1'"
18 elif ! mknod -m $1 $2 $3 $4 $5; then
19 echo "error creating file \`$1', aborting!"
20 exit 1
21 fi
22}
23help_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
36if [ ! -f "${PWD}/$ME" ]; then
37 cd `dirname $0`
38fi
39
40case $MYTARGET in
41
42ext2-cf|nfs)
43echo "creating device nodes"
44makenode 0666 dev/null c 1 3
45makenode 0666 dev/tty c 5 0
46makenode 0622 dev/console c 5 1
47makenode 0660 dev/cfa b 13 0
48makenode 0660 dev/cfa1 b 13 1
49makenode 0660 dev/cfa2 b 13 2
50;;
51
52yaffs2)
53echo "copying over device nodes"
54cp -dpR /dev/null /dev/tty /dev/console /dev/mtd* dev/
55echo "copying over kernel"
56if [ -b /dev/mtdblock0 ]; then
57 mount -t yaffs2 /dev/mtdblock0 mnt/
58elif [ -b /dev/mtdblock/0 ]; then
59 mount -t yaffs2 /dev/mtdblock/0 mnt/
60else
61 echo "device node for first flash partition not found!"
62 exit 1
63fi
64cp kernel mnt/kernel
65umount mnt/
66;;
67
68*)
69echo "something is really going wrong here!"
70;;
71
72esac
73
74echo "recursively fixing ownership"
75chown -R 0:0 *
76
77echo "fixing sticky bit of /tmp"
78chmod 1777 tmp/
79
80echo "setting busybox setuid"
81chmod u+s bin/busybox
82
83exit 0
84
Note: See TracBrowser for help on using the repository browser.