source: trunk/debirf/src/grub2-terminal-chooser @ 1287

Last change on this file since 1287 was 1287, checked in by dkg, 4 years ago

added a grub2 script that allows choosing between serial and graphical terminals at boot time.

File size: 3.7 KB
Line 
1# Choose a Terminal (serial vs. graphical consle) from GRUB
2
3# Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
4# Date: 2009-09-29 12:44:06-0400
5
6# this is a grub config file that offers 5 alternating 1-second
7# chances to hit ESC in either the serial console or the
8# graphical console to select which console to use for grub.
9
10# it is ridiculously long right now because grub
11# currently (2009-09-29) does not support any looping constructs,
12# so i've pasted them all together within the ABSURD LOOP
13# comments.
14
15# if looping constructs were possible, the ideal would be to have
16# this cycle through all possible terminal_input and
17# terminal_output choices (what if they don't match?)
18
19# You can load this file with a line in /boot/grub/grub.cfg like:
20
21# configfile /boot/grub/grub2-terminal-chooser
22
23insmod echo
24insmod sleep
25insmod test
26insmod serial
27serial --unit=0 --speed=115200
28
29echo "checking for alternate inputs"
30
31## BEGIN ABSURD LOOP
32
33if test $chosen_console == "" ; then
34 if terminal_input serial ; then true ; else
35  terminal serial
36 fi
37 if terminal_output serial ; then true ; else
38  terminal serial
39 fi
40 echo "hit ESC to use serial..."
41 if sleep --interruptible 1 ; then true; else
42  chosen_console=serial
43 fi
44fi
45
46if test $chosen_console == "" ; then
47 if terminal_input console ; then true ; else
48  terminal console
49 fi
50 if terminal_output console ; then true ; else
51  terminal console
52 fi
53 echo "hit ESC to use graphical console..."
54 if sleep --interruptible 1 ; then true; else
55  chosen_console=console
56 fi
57fi
58
59if test $chosen_console == "" ; then
60 if terminal_input serial ; then true ; else
61  terminal serial
62 fi
63 if terminal_output serial ; then true ; else
64  terminal serial
65 fi
66 echo "hit ESC to use serial..."
67 if sleep --interruptible 1 ; then true; else
68  chosen_console=serial
69 fi
70fi
71
72if test $chosen_console == "" ; then
73 if terminal_input console ; then true ; else
74  terminal console
75 fi
76 if terminal_output console ; then true ; else
77  terminal console
78 fi
79 echo "hit ESC to use graphical console..."
80 if sleep --interruptible 1 ; then true; else
81  chosen_console=console
82 fi
83fi
84
85if test $chosen_console == "" ; then
86 if terminal_input serial ; then true ; else
87  terminal serial
88 fi
89 if terminal_output serial ; then true ; else
90  terminal serial
91 fi
92 echo "hit ESC to use serial..."
93 if sleep --interruptible 1 ; then true; else
94  chosen_console=serial
95 fi
96fi
97
98if test $chosen_console == "" ; then
99 if terminal_input console ; then true ; else
100  terminal console
101 fi
102 if terminal_output console ; then true ; else
103  terminal console
104 fi
105 echo "hit ESC to use graphical console..."
106 if sleep --interruptible 1 ; then true; else
107  chosen_console=console
108 fi
109fi
110
111if test $chosen_console == "" ; then
112 if terminal_input serial ; then true ; else
113  terminal serial
114 fi
115 if terminal_output serial ; then true ; else
116  terminal serial
117 fi
118 echo "hit ESC to use serial..."
119 if sleep --interruptible 1 ; then true; else
120  chosen_console=serial
121 fi
122fi
123
124if test $chosen_console == "" ; then
125 if terminal_input console ; then true ; else
126  terminal console
127 fi
128 if terminal_output console ; then true ; else
129  terminal console
130 fi
131 echo "hit ESC to use graphical console..."
132 if sleep --interruptible 1 ; then true; else
133  chosen_console=console
134 fi
135fi
136
137if test $chosen_console == "" ; then
138 if terminal_input serial ; then true ; else
139  terminal serial
140 fi
141 if terminal_output serial ; then true ; else
142  terminal serial
143 fi
144 echo "hit ESC to use serial..."
145 if sleep --interruptible 1 ; then true; else
146  chosen_console=serial
147 fi
148fi
149
150## END ABSURD LOOP
151
152# else we default to using the graphical console:
153
154echo "using graphical console"
155
156if terminal_input console ; then true ; else
157 terminal console
158fi
159if terminal_output console ; then true ; else
160 terminal console
161fi
162
163echo "using graphical console"
Note: See TracBrowser for help on using the repository browser.