Added tag 0.7.23 for changeset da2a77bcbaf48cfddefff19cf17888acf761f617
[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: Mon Sep 17 17:39:29 CEST 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 >> /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 if checkbootparam "forensic" ; then
93    eerror "Bootopion forensic found. Important notice!"
94    eerror " Do *not* boot with something like 'grml forensic ...' but with 'forensic ...' instead!"
95    eerror " To avoid damage to your system a debugshell will be started after a delay of 10 seconds." ; eend 1
96    eerror " If you want to continue booting just exit the shell, but think about what you are doing!" ; eend 1
97    sleep 10
98    rundebugshell
99 fi
100
101 if [ -n "$SPLASH" ] ; then
102    /usr/bin/grml-bootsplash "|">/dev/tty14
103    chvt 14
104 fi
105
106 checkvalue $CONFIG_LANGUAGE && config_language
107
108 checkvalue $CONFIG_LOG && config_log
109
110 checkvalue $CONFIG_SWSPEAK && config_swspeak
111
112 checkvalue $CONFIG_FWTIMEOUT && config_fwtimeout
113
114 checkvalue $CONFIG_FIX_PASSWD && config_fix_passwd
115
116 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "||">/dev/tty14
117
118 checkvalue $CONFIG_HOSTNAME && config_hostname
119
120 checkvalue $CONFIG_USERFSTAB && config_userfstab
121
122 checkvalue $CONFIG_TIME && config_time
123
124 checkvalue $CONFIG_KERNEL &&  config_kernel
125
126 checkvalue $CONFIG_VMWARE &&  config_vmware
127
128 checkvalue $CONFIG_QEMU && config_qemu
129
130 checkvalue $CONFIG_SMALL && config_small
131
132 checkvalue $CONFIG_LD_MOD && config_ld_mod
133
134 checkvalue $CONFIG_TIMEZONE && config_timezone
135
136 checkvalue $CONFIG_FAST && config_fast
137
138 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "|||">/dev/tty14
139
140 checkvalue $CONFIG_ENVIRONMENT && config_environment
141
142 checkvalue $CONFIG_SWRAID && config_swraid
143
144 checkvalue $CONFIG_LVM && config_lvm
145
146 # No kernel messages while probing modules
147 echo "0" > /proc/sys/kernel/printk
148
149 checkvalue $CONFIG_CDROM_PERM && config_cdrom_perm
150
151 checkvalue $CONFIG_LOCAL_NET && config_local_net
152
153 checkvalue $CONFIG_FIREWIRE_DEV && config_firewire_dev
154
155 checkvalue $CONFIG_TESTCD && config_testcd
156
157 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "||||">/dev/tty14
158
159 checkvalue $CONFIG_DISCOVER && config_discover
160
161 checkvalue $CONFIG_HWINFO && config_hwinfo
162
163 checkvalue $CONFIG_HOTPLUG_AGENT && config_hotplug_agent
164
165 checkvalue $CONFIG_HOTPLUG_BLACKLIST && config_hotplug_blacklist
166
167 checkvalue $CONFIG_HOTPLUG_MAIN && config_hotplug
168
169 checkvalue $CONFIG_MODULES && config_modules
170
171 checkvalue $CONFIG_ACPI_APM && config_acpi_apm
172
173 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "|||||">/dev/tty14
174
175 checkvalue $CONFIG_PCMCIA && config_pcmcia
176
177 # {{{ Read in what hwsetup has found
178 [ -f /etc/sysconfig/grml ] && . /etc/sysconfig/grml
179 # }}}
180
181 checkvalue $CONFIG_KEYBOARD && config_keyboard
182
183 [ -n "$SPLASH" ] &&  /usr/bin/grml-bootsplash "||||||">/dev/tty14
184
185 checkvalue $CONFIG_BLIND && config_blind
186
187 checkvalue $CONFIG_INTERACTIVE && config_interactive
188
189 checkvalue $CONFIG_AGP && config_agp
190
191 [ -f /etc/sysconfig/grml ] && . /etc/sysconfig/grml
192
193 checkvalue $CONFIG_AUTOMOUNTER && config_automounter
194
195 checkvalue $CONFIG_DMA && config_dma
196
197 checkvalue $CONFIG_FSTAB && config_fstab
198
199 checkvalue $CONFIG_MOUSE && config_mouse
200
201 checkvalue $CONFIG_DHCP && config_dhcp
202
203 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "|||||||">/dev/tty14
204
205 checkvalue $CONFIG_SYSLOG && config_syslog
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