-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit
executable file
·69 lines (59 loc) · 1.53 KB
/
init
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/busybox sh
#set -x
# Create directory structure if it doesn't already exist from the overlay
for dir in bin dev etc lib lib64 mnt proc root sys usr/sbin usr/bin sbin; do
/bin/busybox mkdir -p "$dir"
done
# Install busybox links
/bin/busybox --install -s
# Create some more environment
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devtmpfs none /dev
mkdir /dev/pts
mount -t devpts none /dev/pts
# Stop kernel messages
printf "3 4 1 3" > /proc/sys/kernel/printk
# Load kernel modules
if [ -f "modules" ]; then
depmod
cat modules | while read mod; do
modprobe "$mod"
done
fi
printf "Waiting for devices to come up\n"
sleep 5
# Bring up a network interface
if [ -n "$BOOTIF" ]; then
mac=$(printf "%s" "$BOOTIF" | cut -d "-" -f 2- | tr "-" ":" | tr -d " \n")
for ifacepath in /sys/class/net/*; do
iface=$(basename "$ifacepath")
if [ -f "$ifacepath/address" ]; then
if [ "$mac" = "$(cat $ifacepath/address | tr -d " \n")" ]; then
printf "Boot interface recognized as %s, trying DHCP\n" "$iface"
ip l set dev "$iface" up
udhcpc -t 3 -n -i "$iface" -s ./udhcpc.script
dhcp_done=1
fi
fi
done
if [ -z "$dhcp_done" ]; then
printf "Boot interface %s not found, not configured\n" "$mac"
fi
elif [ "$dhcp" != "no" ]; then
for iface in /sys/class/net/*; do
ip l set dev "$iface" up
done
printf "Trying DHCP on all supported interfaces\n"
udhcpc -t 3 -n -s ./udhcpc.script
fi
if [ -x "./main" ]; then
./main
else
printf "This is jamdisk\n"
sh
fi
umount /dev/pts
umount /dev
umount /proc
umount /sys