-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmkrootfs
executable file
·55 lines (39 loc) · 972 Bytes
/
mkrootfs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
[ "$#" = "1" ] || { echo "Usage: $(basename "$0") filename_of_image"; exit 1; }
CWD=$(pwd)
BUSYBOX=busybox
TMPDIR=$(mktemp -d .tmp.XXXXXXXX)
cd $TMPDIR
mkdir -p dev etc/init.d mnt proc root sys tmp
chmod a+rwxt tmp
cp -rf ${CWD}/${BUSYBOX}/_install/* ./
mkdir -p usr/share/udhcpc
cp -rf ${CWD}/${BUSYBOX}/examples/udhcp/simple.script ./usr/share/udhcpc/default.script
cat << EOF > etc/profile
echo
echo "Let's hack the kernel!"
echo
EOF
cat << EOF > etc/fstab
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
EOF
cat << EOF > etc/inittab
::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh
tty2::askfirst:-/bin/sh
::ctrlaltdel:/bin/umount -a -r
EOF
cat << EOF > etc/init.d/rcS
#!bin/sh
/bin/mount -a
/sbin/mdev -s
/sbin/ifconfig eth0 up >/dev/null 2>&1 \
&& /sbin/udhcpc eth0 >/dev/null 2>&1
EOF
chmod 755 etc/init.d/rcS
find ./ | cpio -o -H newc | gzip > ${CWD}/${1}
cd $CWD
rm -rf $TMPDIR
exit 0