Dash:
[t2-trunk.git] / target / share / install / rootfs / sbin / init
blobcb35e08927d1c5ed065b950558ae60cc47c853ae
1 #!/bin/sh
3 # T2 SDE: target/share/install/rootfs/sbin/init
4 # Partially based on linuxrc.c, Copyright (C) 2003, 2004 Clifford Wolf and Rene Rebe
5 # Converted from C to shell, heavily cleaned and improved for the T2 SDE by:
6 # (C)2005-2021 Rene Rebe, ExactCODE GmbH; Germany.
8 export PATH="/sbin:/bin:/usr/sbin:/usr/bin"
9 export HOME="/root"
11 cd /dev; rm -f fd
12 ln -sf /proc/kcore core
13 ln -sf /proc/self/fd fd
14 ln -sf fd/0 stdin
15 ln -sf fd/1 stdout
16 ln -sf fd/2 stderr
17 cd /
18 mkdir -p /mnt
20 echo "
21 T2 SDE installer (2nd stage)
23 The 2nd stage is a small Linux distribution, loaded into your system's memory.
24 It has everything needed to install T2 Linux, restore an old installation,
25 perform some administrative or backup tasks."
27 for x in /etc/setup-*.sh /setup/setup.sh; do
28 if [ -f "$x" ]; then
29 echo; echo "Running $x ..."; sh $x
30 echo "Setup script $x finished."
32 done
34 ttydevs="console= `cat /proc/cmdline`"; ttydevs=${ttydevs##*console=}; ttydevs=${ttydevs%% *}
35 if [ ! "$ttydevs" ]; then
36 ttydevs="`grep -a -H Y /sys/class/tty/*/console`"
37 ttydevs="${ttydevs%%/console*}"; ttydevs=${ttydevs##*/}
39 ttydevs="${ttydevs:-tty1 tty2 tty3 tty4 tty5 tty6}"
40 while true; do
41 echo -n "
42 If you use a serial terminal, enter the names of terminal devices to use,
43 for example 'ttyS0' or 'ttyUSB0' for the first serial port or just 'console',
44 just hit enter otherwise. (default: $ttydevs): "
45 read _ttydevs
46 if [ "$_ttydevs" ]; then # check
47 for x in $_ttydevs; do
48 [ ! -c /dev/$x ] &&
49 echo "$x is not a char-device." && continue 2
50 done
51 ttydevs="$_ttydevs"
53 break
54 done
56 echo "
57 If you don't know what to do, it's a good time to read the T2 documentation.
58 To start a normal installation, simply run: 'install'"
60 if type -p dialog > /dev/null; then
61 echo "(or 'install -text' if you prefer non-dialog based menus)"
63 echo "
64 https://t2sde.org/support"
66 for x in $ttydevs; do
67 ( ( while : ; do agetty -i -J $x -n -N -l /sbin/login-shell; done ) & )
68 done
70 exec < /dev/null > /dev/null 2>&1
71 while : ; do sleep 1; done