summaryrefslogtreecommitdiff
path: root/debian/local/runsystem
blob: ddb45270cf9762689bfbdda0ebf35949cfe4cf72 (plain)
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
#!/bin/sh

PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH

umask 022

# Create a minimal subset of device and server nodes
/usr/lib/hurd/setup-translators -m -k -p

/hurd/mach-defpager

mem=`vmstat-hurd --size -k`
if [ "$mem" -lt 240000 ]
then
	echo "You only have ${mem}KiB memory."
	echo "Debian GNU/Hurd installation has not been optimized for memory usage yet, and thus currently needs at least 512MiB memory, sorry."
	while true
	do
		sleep 60
	done
fi

# Get all kernel parameters that can be exported as environment variables
envvars="$(echo $* | tr ' ' '\012' | egrep '^[-_/[:alnum:]]+=.*$')"

# Invoke init as linuxrc to work around pid != 1
init='/bin/busybox linuxrc'

# Parse kernel parameters
for i in $envvars ; do
    case "$i" in
        init="/sbin/init"|init="init")
            # Avoid endless loop
            : ;;
        init=*)
            init=${i#init=}
            ;;
        noshell=*)
            sed -i '/^tty[12]/s/^/#/' /etc/inittab
            ;;
        TERM=*)
            term=yes
            ;;
        VGA_OPTIONS=*)
            VGA_OPTIONS=${i#VGA_OPTIONS=}
            ;;
    esac
done

if [ "$term" != yes ]
then
        # No terminal type set, assume we can start the Hurd console

        # Touch the first tty so that the Hurd console is certain to pick it
        # and not some random other tty.
        sleep 1
        touch /dev/tty1

        echo -n "Starting the Hurd console..."
	while true
	do
		LAYOUT=""
		if [ -f /etc/default/keyboard ]
		then
			. /etc/default/keyboard
			[ -z "$XKBLAYOUT" ] || LAYOUT="--keymap $XKBLAYOUT"
		fi
		console -d vga -g $VGA_OPTIONS -d pc_kbd --repeat=kbd $LAYOUT -d pc_mouse --repeat=mouse -c /dev/vcs &
		echo $! > /var/run/hurd-console.pid
		wait
		echo
		echo -n "Restarting the Hurd console..."
	done &

        # Switch over
        envvars="$envvars TERM=hurd"
        exec < /dev/tty1 > /dev/tty1 2>&1
        echo "Console started"

        # Set the console device used by /sbin/reopen-console
        echo /dev/tty1 >/var/run/console-device
fi

# Preset the terminal type for /lib/debian-installer/detect-console
eval exec env - $envvars TERM_TYPE=virtual $init