Improve check for presence of /dev/shm/resolvconf
[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 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 # make sure /etc/resolv.conf points to /dev/shm/resolvconf
80 # and /dev/shm/resolvconf exists:
81 if [ -z "$INSTALLED" ] && ! [ -d /dev/shm/resolvconf ] ; then
82    if [[ $(readlink /etc/resolv.conf) == /etc/resolvconf/run/resolv.conf ]] && \
83       [[ $(readlink /etc/resolvconf/run) == /dev/shm/resolvconf ]] ; then
84       mkdir /dev/shm/resolvconf
85    fi
86 fi
87
88 if [ -z "$SPLASH" ] ; then
89   stage=5
90   rundebugshell
91 fi
92
93 if [ -z "$BOOTDEBUG" ] ; then
94   einfo "Setting kernel ring buffer to level 2."
95   echo "2" > /proc/sys/kernel/printk ; eend $?
96 else
97   einfo "Setting kernel ring buffer to level 6. Adjust manually via running dmesg -n \$VALUE."
98   echo "6" > /proc/sys/kernel/printk ; eend $?
99 fi
100
101 if checkbootparam "forensic" ; then
102    eerror "Bootopion forensic found. Important notice!"
103    eerror " Do *not* boot with something like 'grml forensic ...' but with 'forensic ...' instead!"
104    eerror " To avoid damage to your system a debugshell will be started after a delay of 10 seconds." ; eend 1
105    eerror " If you want to continue booting just exit the shell, but think about what you are doing!" ; eend 1
106    sleep 10
107    rundebugshell
108 fi
109
110 if [ -n "$SPLASH" ] ; then
111    /usr/bin/grml-bootsplash "|">/dev/tty14
112    chvt 14
113 fi
114
115 checkvalue $CONFIG_LANGUAGE && config_language
116
117 checkvalue $CONFIG_LOG && config_log
118
119 checkvalue $CONFIG_SWSPEAK && config_swspeak
120
121 checkvalue $CONFIG_FWTIMEOUT && config_fwtimeout
122
123 checkvalue $CONFIG_FIX_PASSWD && config_fix_passwd
124
125 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "||">/dev/tty14
126
127 checkvalue $CONFIG_HOSTNAME && config_hostname
128
129 checkvalue $CONFIG_USERFSTAB && config_userfstab
130
131 checkvalue $CONFIG_TIME && config_time
132
133 checkvalue $CONFIG_KERNEL &&  config_kernel
134
135 checkvalue $CONFIG_VMWARE &&  config_vmware
136
137 checkvalue $CONFIG_QEMU && config_qemu
138
139 checkvalue $CONFIG_SMALL && config_small
140
141 checkvalue $CONFIG_LD_MOD && config_ld_mod
142
143 checkvalue $CONFIG_TIMEZONE && config_timezone
144
145 checkvalue $CONFIG_FAST && config_fast
146
147 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "|||">/dev/tty14
148
149 checkvalue $CONFIG_ENVIRONMENT && config_environment
150
151 checkvalue $CONFIG_SWRAID && config_swraid
152
153 checkvalue $CONFIG_LVM && config_lvm
154
155 # No kernel messages while probing modules
156 echo "0" > /proc/sys/kernel/printk
157
158 checkvalue $CONFIG_CDROM_PERM && config_cdrom_perm
159
160 checkvalue $CONFIG_LOCAL_NET && config_local_net
161
162 checkvalue $CONFIG_FIREWIRE_DEV && config_firewire_dev
163
164 checkvalue $CONFIG_TESTCD && config_testcd
165
166 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "||||">/dev/tty14
167
168 checkvalue $CONFIG_DISCOVER && config_discover
169
170 checkvalue $CONFIG_HWINFO && config_hwinfo
171
172 checkvalue $CONFIG_HOTPLUG_AGENT && config_hotplug_agent
173
174 checkvalue $CONFIG_HOTPLUG_BLACKLIST && config_hotplug_blacklist
175
176 checkvalue $CONFIG_HOTPLUG_MAIN && config_hotplug
177
178 checkvalue $CONFIG_MODULES && config_modules
179
180 checkvalue $CONFIG_ACPI_APM && config_acpi_apm
181
182 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "|||||">/dev/tty14
183
184 checkvalue $CONFIG_PCMCIA && config_pcmcia
185
186 # {{{ Read in what hwsetup has found
187 [ -f /etc/sysconfig/grml ] && . /etc/sysconfig/grml
188 # }}}
189
190 checkvalue $CONFIG_KEYBOARD && config_keyboard
191
192 [ -n "$SPLASH" ] &&  /usr/bin/grml-bootsplash "||||||">/dev/tty14
193
194 checkvalue $CONFIG_BLIND && config_blind
195
196 checkvalue $CONFIG_INTERACTIVE && config_interactive
197
198 checkvalue $CONFIG_AGP && config_agp
199
200 [ -f /etc/sysconfig/grml ] && . /etc/sysconfig/grml
201
202 checkvalue $CONFIG_AUTOMOUNTER && config_automounter
203
204 checkvalue $CONFIG_DMA && config_dma
205
206 checkvalue $CONFIG_FSTAB && config_fstab
207
208 checkvalue $CONFIG_MOUSE && config_mouse
209
210 checkvalue $CONFIG_DHCP && config_dhcp
211
212 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "|||||||">/dev/tty14
213
214 checkvalue $CONFIG_SYSLOG && config_syslog
215
216 checkvalue $CONFIG_CPU && config_cpu
217
218 checkvalue $CONFIG_SSH && config_ssh
219
220 checkvalue $CONFIG_PASSWD && config_passwd
221
222 checkvalue $CONFIG_EXTRACT  && config_extract
223
224 checkvalue $CONFIG_HOMEDIR && config_homedir
225
226 checkvalue $CONFIG_MYCONFIG && config_myconfig
227
228 checkvalue $CONFIG_DEBS && config_debs
229
230 checkvalue $CONFIG_SCRIPTS && config_scripts
231
232 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "||||||||">/dev/tty14
233
234 checkvalue $CONFIG_CDROM_SCRIPTS && config_cdrom_scripts
235
236 # device symlinks {{{
237   [ -r /mnt/floppy ] || mkdir /mnt/floppy
238   [ -r /mnt/cdrom ]  || mkdir /mnt/cdrom
239   [ -r /mnt/test ]   || mkdir /mnt/test
240 # }}}
241
242 checkvalue $CONFIG_MIXER && config_mixer
243
244 checkvalue $CONFIG_MODEM && config_modem
245
246 checkvalue $CONFIG_WONDERSHAPER && config_wondershaper
247
248 checkvalue $CONFIG_GPM && config_gpm
249
250 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "|||||||||">/dev/tty14
251
252 checkvalue $CONFIG_SERVICES && config_services
253
254 checkvalue $CONFIG_NETCONFIG && config_netconfig
255
256 checkvalue $CONFIG_NETIPV6 && config_ipv6
257
258 checkvalue $CONFIG_DEBNET && config_debnet
259
260 [ -n "$SPLASH" ] && /usr/bin/grml-bootsplash "||||||||||">/dev/tty14
261
262 checkvalue $CONFIG_CONSOLE && config_console
263
264 checkvalue $CONFIG_SETKEYCODES && config_setkeycodes
265
266 checkvalue $CONFIG_BLINDSOUND && config_blindsound
267
268 checkvalue $CONFIG_WELCOME && config_welcome
269
270 checkvalue $CONFIG_FIX_UNIONFS && fix_unionfs
271
272 checkvalue $CONFIG_CREATE_MNT_DIRS && create_mnt_dirs
273
274 checkvalue $CONFIG_915RESOLUTION && config_915resolution
275
276 checkvalue $CONFIG_IPW3945 && config_ipw3945
277
278 checkvalue $CONFIG_AUTOMOUNT && config_automount
279
280 checkvalue $CONFIG_DISTCC && config_distcc
281
282 checkvalue $CONFIG_DISTRI && config_distri
283
284 checkvalue $CONFIG_BLANKING && config_blanking
285
286 if [ -n "$SPLASH" ] ; then
287    /usr/bin/grml-bootsplash "|||||||||||">/dev/tty14
288    chvt 1
289 fi
290
291 checkvalue $CONFIG_GRML2HD && config_grml2hd
292
293 checkvalue $CONFIG_DEBOOTSTRAP && config_debootstrap
294
295 checkvalue $CONFIG_XSTARTUP && config_x_startup
296 # }}}
297
298 # {{{ debug
299 if [ -z "$SPLASH" ] ; then
300   stage=6
301   rundebugshell
302 fi
303
304 if [ -n "$BOOTDEBUG" ] ; then
305   CMDLINE="$(cat /proc/cmdline)"
306   [ -d /cdrom/bootparams/ ] && CMDLINE="$CMDLINE $(cat /cdrom/bootparams/*)"
307   einfo "Bootoption debug detected. Printing kernel command line:"
308   echo "$CMDLINE"
309 fi
310 # }}}
311
312 # {{{ Re-enable signals
313 trap 2 3 11
314 # }}}
315
316 exit 0
317
318 ## END OF FILE #################################################################
319 # vim:foldmethod=marker