-
Notifications
You must be signed in to change notification settings - Fork 9
/
init.sh
executable file
·108 lines (93 loc) · 2.57 KB
/
init.sh
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash -
# Init script installed in stage3 disk image.
# Set up the PATH. The GCC path is a hack because I wasn't able to
# find the right flags for configuring GCC.
PATH=/usr/libexec/gcc/riscv64-unknown-linux-gnu/6.1.0:\
/usr/local/bin:\
/usr/local/sbin:\
/usr/bin:\
/usr/sbin:\
/bin:\
/sbin
export PATH
# Work around default search path problems.
export LD_LIBRARY_PATH=/usr/lib64:/usr/lib
# Root filesystem is mounted as ro, remount it as rw.
mount.static -o remount,rw /
# Mount standard filesystems.
mount.static -t proc /proc /proc
mount.static -t sysfs /sys /sys
mount.static -t tmpfs -o "nosuid,size=20%,mode=0755" tmpfs /run
mkdir -p /run/lock
mkdir -p /dev/pts
mount.static -t devpts /dev/pts /dev/pts
mkdir -p /dev/shm
mount.static -t tmpfs -o mode=1777 shmfs /dev/shm
# XXX devtmpfs
#mount.static -t devtmpfs /dev /dev
rm -f /dev/loop*
mknod /dev/loop-control c 10 237
mknod /dev/loop0 b 7 0
mknod /dev/loop1 b 7 1
mknod /dev/loop2 b 7 2
rm -f /dev/null
mknod /dev/null c 1 3
rm -f /dev/ptmx
mknod /dev/ptmx c 5 2
rm -f /dev/tty /dev/zero
mknod /dev/tty c 5 0
mknod /dev/zero c 1 5
rm -f /dev/random /dev/urandom
mknod /dev/random c 1 8
mknod /dev/urandom c 1 9
# Initialize dynamic linker cache.
ldconfig /usr/lib64 /usr/lib /lib64 /lib
# Fix owner of umount binary.
chown root.root /usr/bin/umount
# There is no hardware clock, just ensure the date is not miles out.
date `date -r /var/tmp +%m%d%H%M%Y`
# Bring up the network.
# (Note: These commands won't work unless the iproute package has been
# installed in a previous boot)
if ip -V >&/dev/null; then
ip a add 10.0.2.15/255.255.255.0 dev eth0
ip link set eth0 up
ip r add default via 10.0.2.2 dev eth0
ip a list
ip r list
fi
# Allow telnet to work. Use ‘make boot-stage3-in-qemu TELNET=1’.
if test -x /usr/sbin/xinetd && test -x /usr/sbin/in.telnetd ; then
cat > /etc/xinetd.d/telnet <<EOF
service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
server_args = -L /etc/login
log_on_failure += USERID
}
EOF
cat > /etc/login <<EOF
#!/bin/bash -
exec bash -i -l
EOF
chmod +x /etc/login
xinetd -stayalive -filelog /var/log/xinetd.log
fi
hostname stage3
echo stage3.fedoraproject.org > /etc/hostname
echo
echo "Welcome to the Fedora/RISC-V stage3 disk image"
echo "https://fedoraproject.org/wiki/Architectures/RISC-V"
echo
PS1='stage3:\w\$ '
export PS1
# Run bash.
bash -il
# Sync disks and shut down.
sync
mount.static -o remount,ro / >&/dev/null
poweroff