New bootoption micvol
[grml-autoconfig.git] / grml-autoconfig
1 #!/bin/zsh
2 # Filename:      /etc/init.d/grml-autoconfig
3 # Purpose:       basic system configuration and hardware setup for grml system
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 # Latest change: Sam Nov 03 17:22:09 CET 2007 [mika]
8 ################################################################################
9
10 # http://wiki.debian.org/LSBInitScripts =>
11 ### BEGIN INIT INFO
12 # Provides:          grml-autoconfig
13 # Required-Start:
14 # Required-Stop:
15 # Should-Start:      udev
16 # Default-Start:     S 2 3 4 5
17 # Default-Stop:
18 ### END INIT INFO
19
20 # {{{ placeholder functions for restart/reload/stop
21 if [[ $1 == "restart" ]] ; then
22   echo "$0 restart - empty placeholder. Doing nothing but running."
23 fi
24
25 if [[ $1 == "force-reload" ]] ; then
26   echo "$0 force-reload - empty placeholder. Doing nothing but running."
27 fi
28
29 if [[ $1 == "stop" ]] ; then
30   echo "$0 stop - empty placeholder. Doing nothing but exiting."
31   exit 1
32 fi
33 # }}}
34
35 # {{{ path, signals, umask, zsh, colors
36 export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin"
37 umask 022
38 # Ignore these signals: INT, TERM, SEGV
39 trap "" 2 3 11
40
41 # zsh stuff
42 setopt no_nomatch # avoid 'no matches found: ...'
43 # }}}
44
45 # {{{ source main files
46 source /etc/grml/autoconfig            # configuration file
47 source /etc/grml/autoconfig.functions  # functions
48 source /etc/grml/lsb-functions         # helper functions for smart display
49 # }}}
50
51 # {{{ mount important directories
52 mount_proc
53 mount_pts
54 mount_sys
55 # }}}
56
57 # {{{ Read in boot parameters
58 CMDLINE="$(cat /proc/cmdline)"
59 [ -d /cdrom/bootparams/ ] && CMDLINE="$CMDLINE $(cat /cdrom/bootparams/* | tr '\n' ' ')"
60 # }}}
61
62 # {{{ main grml-autoconfig
63 checkvalue $CONFIG_DEBUG && config_debug
64
65 SPLASH=''
66 if checkbootparam "textsplash" || checkbootparam "tsplash"; then
67    SPLASH=1
68 fi
69
70 # update /etc/mtab if running in live-initramfs mode:
71 if [ -z "$INSTALLED" -a -e /live/cow ] ; then
72    if ! grep -q rootfs /etc/mtab ; then
73       for i in rootfs "none /sys sysfs" proc /live/image /live/cow /lib/init/rw /dev/shm /dev/pts ; do
74           grep $i /proc/mounts | grep -v /dev/.static >> /etc/mtab
75       done
76    fi
77 fi
78
79 if [ -z "$SPLASH" ] ; then
80   stage=5
81   rundebugshell
82 fi
83
84 if [ -z "$BOOTDEBUG" ] ; then
85   einfo "Setting kernel ring buffer to level 2."
86   echo "2" > /proc/sys/kernel/printk ; eend $?
87 else
88   einfo "Setting kernel ring buffer to level 6. Adjust manually via running dmesg -n \$VALUE."
89   echo "6" > /proc/sys/kernel/printk ; eend $?
90 fi
91
92 checkvalue $CONFIG_SYSLOG && config_syslog
93
94 if checkbootparam "forensic" ; then
95    eerror "Bootopion forensic found. Important notice!"
96    eerror " Do *not* boot with something like 'grml forensic ...' but with 'forensic ...' instead!"
97    eerror " To avoid damage to your system a debugshell will be started after a delay of 10 seconds." ; eend 1
98    eerror " If you want to continue booting just exit the shell, but think about what you are doing!" ; eend 1
99    sleep 10
100    rundebugshell
101 fi
102
103 if [ -n "$SPLASH" ] ; then
104    /usr/bin/grml-bootsplash "|">/dev/tty14
105    chvt 14
106 fi
107
108 checkvalue $CONFIG_LANGUAGE && config_language
109
110 checkvalue $CONFIG_LOG && config_log
111
112 checkvalue $CONFIG_SWSPEAK && config_swspeak
113
114 checkvalue $CONFIG_FWTIMEOUT && config_fwtimeout
115
116 checkvalue $CONFIG_FIX_PASSWD && config_fix_passwd
117
118 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "||">/dev/tty14
119
120 checkvalue $CONFIG_HOSTNAME && config_hostname
121
122 checkvalue $CONFIG_USERFSTAB && config_userfstab
123
124 checkvalue $CONFIG_TIME && config_time
125
126 checkvalue $CONFIG_KERNEL &&  config_kernel
127
128 checkvalue $CONFIG_VMWARE &&  config_vmware
129
130 checkvalue $CONFIG_QEMU && config_qemu
131
132 checkvalue $CONFIG_SMALL && config_small
133
134 checkvalue $CONFIG_LD_MOD && config_ld_mod
135
136 checkvalue $CONFIG_TIMEZONE && config_timezone
137
138 checkvalue $CONFIG_FAST && config_fast
139
140 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "|||">/dev/tty14
141
142 checkvalue $CONFIG_ENVIRONMENT && config_environment
143
144 checkvalue $CONFIG_SWRAID && config_swraid
145
146 checkvalue $CONFIG_LVM && config_lvm
147
148 # No kernel messages while probing modules
149 echo "0" > /proc/sys/kernel/printk
150
151 checkvalue $CONFIG_CDROM_PERM && config_cdrom_perm
152
153 checkvalue $CONFIG_LOCAL_NET && config_local_net
154
155 checkvalue $CONFIG_FIREWIRE_DEV && config_firewire_dev
156
157 checkvalue $CONFIG_TESTCD && config_testcd
158
159 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "||||">/dev/tty14
160
161 checkvalue $CONFIG_DISCOVER && config_discover
162
163 checkvalue $CONFIG_HWINFO && config_hwinfo
164
165 checkvalue $CONFIG_HOTPLUG_AGENT && config_hotplug_agent
166
167 checkvalue $CONFIG_HOTPLUG_BLACKLIST && config_hotplug_blacklist
168
169 checkvalue $CONFIG_HOTPLUG_MAIN && config_hotplug
170
171 checkvalue $CONFIG_MODULES && config_modules
172
173 checkvalue $CONFIG_ACPI_APM && config_acpi_apm
174
175 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "|||||">/dev/tty14
176
177 checkvalue $CONFIG_PCMCIA && config_pcmcia
178
179 # {{{ Read in what hwsetup has found
180 [ -f /etc/sysconfig/grml ] && . /etc/sysconfig/grml
181 # }}}
182
183 checkvalue $CONFIG_KEYBOARD && config_keyboard
184
185 [ -n "$SPLASH" ] &&  /usr/bin/grml-bootsplash "||||||">/dev/tty14
186
187 checkvalue $CONFIG_BLIND && config_blind
188
189 checkvalue $CONFIG_INTERACTIVE && config_interactive
190
191 checkvalue $CONFIG_AGP && config_agp
192
193 [ -f /etc/sysconfig/grml ] && . /etc/sysconfig/grml
194
195 checkvalue $CONFIG_AUTOMOUNTER && config_automounter
196
197 checkvalue $CONFIG_DMA && config_dma
198
199 checkvalue $CONFIG_FSTAB && config_fstab
200
201 checkvalue $CONFIG_MOUSE && config_mouse
202
203 checkvalue $CONFIG_DHCP && config_dhcp
204
205 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "|||||||">/dev/tty14
206
207 checkvalue $CONFIG_CPU && config_cpu
208
209 checkvalue $CONFIG_SSH && config_ssh
210
211 checkvalue $CONFIG_PASSWD && config_passwd
212
213 checkvalue $CONFIG_EXTRACT  && config_extract
214
215 checkvalue $CONFIG_HOMEDIR && config_homedir
216
217 checkvalue $CONFIG_MYCONFIG && config_myconfig
218
219 checkvalue $CONFIG_DEBS && config_debs
220
221 checkvalue $CONFIG_SCRIPTS && config_scripts
222
223 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "||||||||">/dev/tty14
224
225 checkvalue $CONFIG_CDROM_SCRIPTS && config_cdrom_scripts
226
227 # device symlinks {{{
228   [ -r /mnt/floppy ] || mkdir /mnt/floppy
229   [ -r /mnt/cdrom ]  || mkdir /mnt/cdrom
230   [ -r /mnt/test ]   || mkdir /mnt/test
231 # }}}
232
233 checkvalue $CONFIG_MIXER && config_mixer
234
235 checkvalue $CONFIG_MODEM && config_modem
236
237 checkvalue $CONFIG_WONDERSHAPER && config_wondershaper
238
239 checkvalue $CONFIG_GPM && config_gpm
240
241 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "|||||||||">/dev/tty14
242
243 checkvalue $CONFIG_SERVICES && config_services
244
245 checkvalue $CONFIG_NETCONFIG && config_netconfig
246
247 checkvalue $CONFIG_NETIPV6 && config_ipv6
248
249 checkvalue $CONFIG_DEBNET && config_debnet
250
251 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "||||||||||">/dev/tty14
252
253 checkvalue $CONFIG_CONSOLE && config_console
254
255 checkvalue $CONFIG_SETKEYCODES && config_setkeycodes
256
257 checkvalue $CONFIG_BLINDSOUND && config_blindsound
258
259 checkvalue $CONFIG_WELCOME && config_welcome
260
261 checkvalue $CONFIG_FIX_UNIONFS && fix_unionfs
262
263 checkvalue $CONFIG_CREATE_MNT_DIRS && create_mnt_dirs
264
265 checkvalue $CONFIG_915RESOLUTION && config_915resolution
266
267 checkvalue $CONFIG_IPW3945 && config_ipw3945
268
269 checkvalue $CONFIG_AUTOMOUNT && config_automount
270
271 checkvalue $CONFIG_DISTCC && config_distcc
272
273 checkvalue $CONFIG_DISTRI && config_distri
274
275 checkvalue $CONFIG_BLANKING && config_blanking
276
277 if [ -n "$SPLASH" ] ; then
278    /usr/bin/grml-bootsplash "|||||||||||">/dev/tty14
279    chvt 1
280 fi
281
282 checkvalue $CONFIG_GRML2HD && config_grml2hd
283
284 checkvalue $CONFIG_DEBOOTSTRAP && config_debootstrap
285
286 checkvalue $CONFIG_XSTARTUP && config_x_startup
287 # }}}
288
289 # {{{ debug
290 if [ -z "$SPLASH" ] ; then
291   stage=6
292   rundebugshell
293 fi
294
295 if [ -n "$BOOTDEBUG" ] ; then
296   CMDLINE="$(cat /proc/cmdline)"
297   [ -d /cdrom/bootparams/ ] && CMDLINE="$CMDLINE $(cat /cdrom/bootparams/*)"
298   einfo "Bootoption debug detected. Printing kernel command line:"
299   echo "$CMDLINE"
300 fi
301 # }}}
302
303 # {{{ Re-enable signals
304 trap 2 3 11
305 # }}}
306
307 exit 0
308
309 ## END OF FILE #################################################################
310 # vim:foldmethod=marker