-
Notifications
You must be signed in to change notification settings - Fork 7
/
autoconfig.functions
executable file
·2087 lines (1934 loc) · 64.2 KB
/
autoconfig.functions
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/zsh
# Filename: autoconfig.functions
# Purpose: basic system configuration and hardware setup for grml system
# Authors: grml-team (grml.org), (c) Klaus Knopper <knopper@knopper.net>, (c) Michael Prokop <mika@grml.org>
# Bug-Reports: see http://grml.org/bugs/
# License: This file is licensed under the GPL v2.
# Latest change: Don Okt 12 13:00:04 CEST 2006 [mika]
################################################################################
# {{{ path, variables, signals, umask, zsh
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin"
DEBUG="/dev/null"
KERNEL="$(uname -r)"
umask 022
# Ignore these signals in non-interactive mode: INT, TERM, SEGV
[ -z "$PS1" ] && trap "" 2 3 11
# zsh stuff
iszsh(){
if [ -n "$ZSH_VERSION" ] ; then
return 0
else
return 1
fi
}
# avoid 'no matches found: ...'
iszsh && setopt no_nomatch # || echo "Warning: not running under zsh!"
# }}}
### {{{ Utility Functions
# Simple shell grep
stringinfile(){
case "$(cat $2)" in *$1*) return 0;; esac
return 1
}
# same for strings
stringinstring(){
case "$2" in *$1*) return 0;; esac
return 1
}
# Reread boot command line; echo last parameter's argument or return false.
getbootparam(){
stringinstring " $1=" "$CMDLINE" || return 1
result="${CMDLINE##*$1=}"
result="${result%%[ ]*}"
echo "$result"
return 0
}
# Check boot commandline for specified option
checkbootparam(){
stringinstring " $1" "$CMDLINE"
return "$?"
}
checkvalue(){
if [ "$1" = "yes" ] ; then
return 0
else
return 1
fi
}
checkgrmlsmall(){
grep -q small /etc/grml_version 2>>$DEBUG && return 0 || return 1
}
checkgrmlusb(){
grep -q usb /etc/grml_version 2>>$DEBUG && return 0 || return 1
}
### }}}
# {{{ filesystems (proc, pts, sys) and fixes
mount_proc(){
[ -f /proc/version ] || mount -t proc /proc /proc 2>/dev/null
}
mount_pts(){
stringinfile "/dev/pts" /proc/mounts || mount -t devpts /dev/pts /dev/pts 2>/dev/null
}
mount_sys(){
[ -d /sys/devices ] || mount -t sysfs /sys /sys 2>/dev/null
}
# }}}
# {{{ Read in boot parameters
CMDLINE="$(cat /proc/cmdline)"
[ -d /cdrom/bootparams/ ] && CMDLINE="$CMDLINE $(cat /cdrom/bootparams/* | tr '\n' ' ')"
# }}}
# {{{ Check if we are running from the grml-CD or HD
INSTALLED=""
[ -e /GRML/etc/grml_cd ] || INSTALLED="yes"
# testcd
TESTCD=""
checkbootparam "testcd" >>$DEBUG 2>&1 && TESTCD="yes"
# }}}
# {{{ source lsb-functions , color handling
if checkbootparam "nocolor"; then
RC_NOCOLOR=yes
. /etc/grml/lsb-functions
einfo "Disabling colors in bootsequence as requested on commandline." ; eend 0
else
. /etc/grml/lsb-functions
. /etc/grml_colors
fi
# }}}
# {{{ debug
config_debug(){
if checkbootparam "debug"; then
BOOTDEBUG="yes"
fi
if stringinstring "BOOT_IMAGE=debug " "$CMDLINE" ; then
BOOTDEBUG="yes"
fi
rundebugshell(){
if [ -n "$BOOTDEBUG" ]; then
einfo "Starting intermediate shell stage $stage as requested by \"debug\" option."
eindent
if [ -r /etc/grml/screenrc ] ; then
einfo "Starting GNU screen to be able to use a full featured shell environment."
einfo "Just exit the shells (and therefore screen) to continue boot process..."
/bin/zsh -c "screen -c /etc/grml/screenrc"
else
einfo "Notice that the shell does not provide job handling: ctrl-z, bg and fg won't work!"
einfo "Just exit the shell to continue boot process..."
/bin/zsh
fi
eoutdent
fi
}
}
# }}}
# {{{ log
config_log(){
if checkbootparam "log"; then
export DEBUG="/tmp/grml.log.`date +%Y%m%d`"
touch $DEBUG
einfo "Bootparameter log found. Log files: ${DEBUG} and /var/log/boot."
eindent
einfo "Starting bootlogd."
bootlogd -r -c 1>>$DEBUG 2>&1 ; eend $?
eoutdent
else
DEBUG="/dev/null"
fi
}
# }}}
# {{{ Check if we are in interactive startup mode
INTERACTIVE=""
stringinstring "BOOT_IMAGE=expert " "$CMDLINE" && INTERACTIVE="yes"
# }}}
# {{{ set firmware timeout via bootparam
config_fwtimeout(){
if checkbootparam fwtimeout ; then
TIMEOUT="$(getbootparam 'fwtimeout' 2>>$DEBUG)"
einfo "Bootoption fwtimeout found. (Re)Loading firmware_class module."
rmmod firmware_class 1>>$DEBUG 2>&1
modprobe firmware_class ; eend $?
fi
if [ -z "$TIMEOUT" ] ; then
TIMEOUT="100" # linux kernel default: 10
fi
if [ -f /sys/class/firmware/timeout ] ; then
einfo "Setting timeout for firmware loading to ${TIMEOUT}."
echo 100 > /sys/class/firmware/timeout ; eend $?
fi
}
# }}}
### {{{ language configuration / localization
config_language(){
einfo "Activating language settings:"
eindent
# people can specify $LANGUAGE and $CONSOLEFONT in a config file:
[ -r /etc/grml/autoconfig ] && . /etc/grml/autoconfig
grep -q ' lang=.*-utf8' /proc/cmdline && UTF8='yes' || UTF8=''
# check for bootoption which overrides config from /etc/grml/autoconfig:
BOOT_LANGUAGE="$(getbootparam lang 2>>$DEBUG)"
[ -n "$BOOT_LANGUAGE" ] && LANGUAGE="$BOOT_LANGUAGE"
# set default to 'en' in live-cd mode if $LANGUAGE is not yet set:
if [ -z "$INSTALLED" ] ; then
[ -n "$LANGUAGE" ] || LANGUAGE='en'
fi
# if bootoption lang is used update /etc/default/locale, otherwise *not*!
if [ -n "$BOOT_LANGUAGE" ] ; then
[ -x /usr/sbin/grml-setlang ] && /usr/sbin/grml-setlang "$LANGUAGE"
fi
# set console font
if [ -z "$CONSOLEFONT" ] ; then
if ! checkbootparam "nodefaultfont" >>$DEBUG 2>&1 ; then
# [ -n "$UTF8" ] && CONSOLEFONT='LatArCyrHeb-16' || CONSOLEFONT='Lat15-Terminus16'
if [ -r /usr/share/consolefonts/Lat15-Terminus16.psf.gz ] ; then
CONSOLEFONT='Lat15-Terminus16'
else
ewarn "/usr/share/consolefonts/Lat15-Terminus16.psf.gz not available. Please upgrade package console-terminus." ; eend 1
fi
fi
fi
# export it now, so error messages get translated, too
if checkgrmlsmall ; then
export LANG='C' # grml-small does not provide any further locales
else
[ -r /etc/default/locale ] && . /etc/default/locale
export LANG LANGUAGE
fi
# configure keyboard layout, read in already set values first:
[ -r /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
# now allow keyboard override by boot commandline for later use:
KKEYBOARD="$(getbootparam keyboard 2>>$DEBUG)"
[ -n "$KKEYBOARD" ] && KEYTABLE="$KKEYBOARD"
# notce: de/at is a bad choice, so take de-latin1-nodeadkeys instead:
[[ "$KKEYBOARD" == 'de' ]] && KEYTABLE=de-latin1-nodeadkeys
[[ "$KKEYBOARD" == 'at' ]] && KEYTABLE=de-latin1-nodeadkeys
# modify /etc/sysconfig/keyboard only in live-cd mode:
if [ -z "$INSTALLED" ] ; then
local LANGUAGE="$BOOT_LANGUAGE"
. /etc/grml/language-functions
# allow setting xkeyboard explicitly different than console keyboard
KXKEYBOARD="$(getbootparam xkeyboard 2>>$DEBUG)"
if [ -n "$KXKEYBOARD" ]; then
XKEYBOARD="$KXKEYBOARD"
KDEKEYBOARD="$KXKEYBOARD"
elif [ -n "$KKEYBOARD" ]; then
XKEYBOARD="$KKEYBOARD"
KDEKEYBOARD="$KKEYBOARD"
fi
# duplicate of previous code to make sure /etc/grml/language-functions
# does not overwrite our values....
# now allow keyboard override by boot commandline for later use:
KKEYBOARD="$(getbootparam keyboard 2>>$DEBUG)"
[ -n "$KKEYBOARD" ] && KEYTABLE="$KKEYBOARD"
# notce: de/at is a bad choice, so take de-latin1-nodeadkeys instead:
[[ "$KKEYBOARD" == 'de' ]] && KEYTABLE=de-latin1-nodeadkeys
[[ "$KKEYBOARD" == 'at' ]] && KEYTABLE=de-latin1-nodeadkeys
# write keyboard related variables to file for later use
echo "KEYTABLE=\"$KEYTABLE\"" > /etc/sysconfig/keyboard
echo "XKEYBOARD=\"$XKEYBOARD\"" >> /etc/sysconfig/keyboard
echo "KDEKEYBOARD=\"$KDEKEYBOARD\"" >> /etc/sysconfig/keyboard
echo "KDEKEYBOARDS=\"$KDEKEYBOARDS\"" >> /etc/sysconfig/keyboard
fi
[ -r /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
# Set default keyboard before interactive setup
if [ -n "$KEYTABLE" ] ; then
einfo "Running loadkeys for ${WHITE}${KEYTABLE}${NORMAL} in background"
loadkeys -q $KEYTABLE &
eend $?
fi
if [ -n "$CONSOLEFONT" ] ; then
einfo "Running consolechars using ${CONSOLEFONT}"
consolechars -f $CONSOLEFONT || consolechars -d
eend $?
if [ -n "$UTF8" ] ; then
einfo "Notice: run 'filterm - dynafont' in your shell to enable a unicode capable console."
fi
fi
# we have to set up all consoles, therefore loop it over all ttys:
if [ -n "$CHARMAP" ] ; then
einfo "Running consolechars for ${CHARMAP}"
NUM_CONSOLES=`fgconsole --next-available`
NUM_CONSOLES=`expr ${NUM_CONSOLES} - 1`
[ ${NUM_CONSOLES} -eq 1 ] && NUM_CONSOLES=6
for vc in `seq 0 ${NUM_CONSOLES}` ; do
consolechars --tty=/dev/tty${vc} -m ${CHARMAP} ; RC=$?
done
eend ${RC}
fi
eoutdent
}
# }}}
# {{{ Set hostname
config_hostname(){
if checkbootparam hostname ; then
HOSTNAME="$(getbootparam 'hostname' 2>>$DEBUG)"
einfo "Setting hostname to $HOSTNAME as requested."
sed -i "s/^127.0.0.1.*localhost/127.0.0.1 $HOSTNAME localhost/" /etc/hosts
hostname $HOSTNAME ; eend $?
else
hostname --file /etc/hostname
fi
}
# }}}
# fstabuser (needed when running from harddisk with username != grml {{{
config_userfstab(){
fstabuser=$(getent passwd 1000 | cut -d: -f1)
[ -n "$fstabuser" ] || fstabuser='grml'
}
# }}}
# {{{ Set clock (Local time is more often used than GMT, so it is default)
config_time(){
# don't touch the files if running from harddisk:
if [ -z "$INSTALLED" ]; then
UTC=""
checkbootparam utc >>$DEBUG 2>&1 && UTC="-u"
checkbootparam gmt >>$DEBUG 2>&1 && UTC="-u"
# hwclock uses the TZ variable
export TZ
hwclock $UTC -s
fi
}
# }}}
# {{{ print kernel info
config_kernel(){
vmware-detect &>/dev/null && VMWARE="inside ${WHITE}VMWare${NORMAL}"
einfo "Running Linux Kernel $KERNEL $VMWARE" ; eend 0
}
# }}}
# {{{ vmware specific stuff
config_vmware(){
if checkbootparam novmware ; then
ewarn "Skipping running vmware specific stuff as requested on boot commandline." ; eend 0
else
if [ -z "$INSTALLED" ]; then
if vmware-detect ; then
if [ -r /etc/X11/xorg.conf.vmware ] ; then
einfo "Copying /etc/X11/xorg.conf.vmware to /etc/X11/xorg.conf"
cp /etc/X11/xorg.conf.vmware /etc/X11/xorg.conf ; eend $?
fi
fi
fi
fi
}
# }}}
# {{{ installed on hd?
config_checkfs(){
if [ -n "$INSTALLED" ]; then
einfo "Running from HD, checking filesystems."
# We are running from HD, so a file system check is recommended
[ -f /etc/init.d/checkroot.sh ] && /etc/init.d/checkroot.sh
[ -f /etc/init.d/checkfs.sh ] && /etc/init.d/checkfs.sh
eend 0
fi
}
# }}}
# {{{ / must be read-write in any case, starting from here
config_remount_root(){
mount -o remount,rw / 2>>$DEBUG
}
# }}}
# {{{ ld.so.cache + depmod
config_ld_mod(){
if [ -n "$INSTALLED" ]; then
if ! [ -r /etc/grml.first.boot ] ; then
einfo "Running from HD for the first time, regenerate ld.so.cache and modules.dep:"
eindent
# Regenerate ld.so.cache and module dependencies on HD
einfo "Running ldconfig" ; ldconfig ; eend $?
einfo "Running depmod" ; depmod -a ; eend $?
touch /etc/grml.first.boot
eend 0
eoutdent
fi
fi
}
# }}}
# update_progress {{{
update_progress(){
# be sure we are non-blocking
(echo "$1" > /etc/sysconfig/progress) &
}
# }}}
# {{{ timezone
config_timezone(){
# don't touch the files if running from harddisk:
if [ -z "$INSTALLED" ]; then
einfo "Setting timezone."
KTZ="$(getbootparam tz 2>>$DEBUG)"
[ -f "/usr/share/zoneinfo/$KTZ" ] && TZ="$KTZ"
rm -f /etc/localtime
cp "/usr/share/zoneinfo/$TZ" /etc/localtime && eend 0
fi
}
# }}}
# small computer / nearly no ram {{{
config_small(){
RAM=$(/usr/bin/gawk '/MemTotal/{print $2}' /proc/meminfo)
# MEM=$(/usr/bin/gawk 'BEGIN{m=0};/MemFree|Cached|SwapFree/{m+=$2};END{print m}' /proc/meminfo)
eindent
if checkbootparam "small"; then
einfo "Information: ${RAM} kB of RAM available." ; eend 0
einfo "Bootoption small detected. Activating small system."
if [ -r /etc/inittab.small ] ; then
mv /etc/inittab /etc/inittab.normal
mv /etc/inittab.small /etc/inittab
else
sed -i 's/^9/#&/' /etc/inittab
sed -i 's/^10/#&/' /etc/inittab
sed -i 's/^11/#&/' /etc/inittab
sed -i 's/^12/#&/' /etc/inittab
fi
/sbin/telinit q ; eend $?
else
if checkgrmlsmall ; then
if [[ $RAM -lt 25000 ]] ; then
ewarn "Information: ${RAM} kB of RAM available." ; eend 1
ewarn "At least 32MB of RAM should be available for grml-small." ; eend 1
ewarn "Use the bootoption small to save some more MB of memory usage." ; eend 0
ewarn "Dropping you into a rescue shell. To continue booting exit the shell." ; eend 0
/bin/zsh --login
else
einfo "Information: ${RAM} kB of RAM available." ; eend 0
fi
else
if [[ $RAM -lt 58000 ]] ; then
ewarn "Information: ${RAM} kB of RAM available." ; eend 1
ewarn "At least 64MB of RAM should be available for grml." ; eend 1
ewarn "Use the bootoption small to save some more MB of memory usage." ; eend 0
ewarn "Dropping you into a rescue shell. To continue booting exit the shell." ; eend 0
/bin/zsh --login
else
einfo "Information: ${RAM} kB of RAM available." ; eend 0
fi
fi
fi
eoutdent
}
# }}}
# skip startup of w3m {{{
config_fast(){
if checkbootparam "fast"; then
ewarn "Bootoption fast detected. Skipping startup of w3m."
sed -i 's#^1:.*#1:12345:respawn:/usr/bin/openvt -f -c 1 -w -- /bin/zsh#' /etc/inittab
/sbin/telinit q ; eend $?
fi
}
# }}}
# activate serial console {{{
config_console(){
if checkbootparam "console"; then
einfo "Bootoption (for serial) console detected. Activating mgetty."
sed -i 's/^#T0/T0/' /etc/inittab
sed -i 's/^#T1/T1/' /etc/inittab
/sbin/telinit q ; eend $?
fi
}
# }}}
# For burning on IDE-CD-Roms, k3b (and others) check for special permissions {{{
config_cdrom_perm(){
CDROMS=""
for DEVICE in /proc/ide/hd?; do
[ "$(cat $DEVICE/media 2>/dev/null)" = "cdrom" ] && CDROMS="$CDROMS /dev/${DEVICE##*/}"
done
[ -n "$CDROMS" ] && { chown root.cdrom $CDROMS; chmod 666 $CDROMS; } 2>/dev/null
}
# }}}
# {{{ Bring up loopback interface now
config_local_net(){
if [ -z "$INSTALLED" ] ; then
grep -q lo=lo /etc/network/run/ifstate 2>/dev/null || ifup lo
fi
}
# }}}
# firewire devices {{{
# the raw1394 driver does not yet export info into SYSFS,
# so let's create raw1394 device manually
# http://www.michael-prokop.at/blog/index.php?p=352
config_firewire_dev(){
if checkbootparam "nofirewiredev" ; then
ewarn "Skipping creating some firewire devices as requested on boot commandline." ; eend 0
else
#if [ "${KERNEL%-*}" == "2.6.11" ] ; then
einfo "Creating some firewire devices (fix kernel 2.6-bug)."
# cd /dev && MAKEDEV video1394 raw1394
[ -r /dev/raw1394 ] || mknod /dev/raw1394 c 171 0
[ -r /dev/video1394 ] || mknod -m 666 /dev/video1394 c 171 16
# mknod -m 666 /dev/dv1394 c 171 32 # for NTSC
[ -r /dev/dv1394 ] || mknod -m 666 /dev/dv1394 c 171 34 # for PAL
chown -R root:video /dev/raw1394 /dev/video1394 /dev/dv1394
chmod -R 664 /dev/raw1394 /dev/video1394 /dev/dv1394 ; eend $?
fi
#fi
}
# }}}
# {{{ copy passwd-lockfile to ramdisk (fix unionfs-behaviour)
# otherwise we will get: passwd: Authentication token lock busy
config_fix_passwd(){
if [ -z "$INSTALLED" ] ; then
touch /etc/.pwd.lock
fi
}
# }}}
# {{{ CD Checker
config_testcd(){
if [ -n "$TESTCD" ]; then
einfo "Checking CD data integrity as requested by '${WHITE}testcd${NORMAL}' boot option."
einfo "Reading files and checking against GRML/md5sums, this may take a while..."
echo -n "${RED}"
( cd /cdrom/GRML/ ; rm -f /tmp/md5sum.log ; md5sum -c md5sums 2>&1 | tee /tmp/md5sum.log )
if [ "$?" = "0" ]; then
echo " ${GREEN}Everything looks OK${NORMAL}"
else
echo "${RED} *** CHECKSUM FAILED FOR THESE FILES: ***"
egrep -v '(^md5sum:|OK$)' /tmp/md5sum.log
echo "${RED} *** DATA ON YOUR CD MEDIUM IS POSSIBLY INCOMPLETE OR DAMAGED, ***${NORMAL}"
echo "${RED} *** OR YOUR COMPUTER HAS BAD RAM. ***${NORMAL}"
echo -n "${CYAN}Hit return to contine, or press the reset button to quit.${NORMAL} "
read a
fi
eend 0
fi
}
# }}}
# {{{ hardware detection via discover
config_discover(){
if checkbootparam "nodisc" ; then
ewarn "Skipping hardware detection via discover as requested on boot commandline." ; eend 0
else
if [ -x /sbin/discover ] ; then
einfo "Discovering hardware. Trying to load the following modules in background:"
eindent
einfo "$(discover --data-path=linux/module/name --data-path=linux/modules/options --format="%s %s" --data-version=`uname -r` --enable-bus all | sort -u | xargs echo)"
eoutdent
/sbin/discover-modprobe -v 1>>$DEBUG 2>&1 &
eend 0
else
eerror "Application discover not available. Information: udev should handle hardware recognition." ; eend 0
fi
fi
}
# }}}
# {{{ hardware detection via hwinfo
config_hwinfo(){
if checkbootparam hwinfo >>$DEBUG 2>&1; then
einfo "Discovering hardware via hwinfo:"
MODULES=$(su grml hwinfo | grep "Cmd: \"modprobe" | awk '{print $5}' | sed 's/"//')
echo -n " Loading modules: "
for i in `echo $MODULES` ; do echo -n $i && modprobe $i ; done
eend 0
fi
}
# }}}
# {{{ disable hotplug agents on request
config_hotplug_agent(){
if checkbootparam "noagent" ; then
AGENT="$(getbootparam 'noagent' 2>>$DEBUG)"
AGENTLIST=$(echo "$AGENT" | sed 's/,/\\n/g')
AGENTNL=$(echo "$AGENT" | sed 's/,/ /g')
einfo "Disabling hotplug-agent(s) $AGENTNL"
for agent in $(echo -e $AGENTLIST) ; do
mv /etc/hotplug/${agent}.rc /etc/hotplug/${agent}.norc
done
[ "$?" == "0" ] ; eend $?
fi
}
# }}}
# {{{ blacklist of hotplug-modules
config_hotplug_blacklist(){
if checkbootparam "black" ; then
BLACK="$(getbootparam 'black' 2>>$DEBUG)"
BLACKLIST=$(echo "$BLACK" | sed 's/,/\\n/g')
BLACKNL=$(echo "$BLACK" | sed 's/,/ /g')
einfo "Blacklisting $BLACKNL via /etc/hotplug/blacklist.d/hotplug-light"
echo -e "$BLACKLIST" >> /etc/hotplug/blacklist.d/hotplug-light
echo -e "$BLACKLIST" >> /etc/hotplug/blacklist
eend 0
fi
}
# }}}
# {{{ run hotplug
config_hotplug(){
if checkbootparam "nohotplug" ; then
ewarn "Skipping running hotplug as requested on boot commandline." ; eend 0
else
if [ -r /etc/init.d/hotplug ] ; then
einfo "Starting hotplug system in background."
/etc/init.d/hotplug start 1>>$DEBUG 2>>$DEBUG &
eend 0
elif [ -r /etc/init.d/hotplug-light ] ; then
einfo "Starting hotplug-light system in background."
/etc/init.d/hotplug-light start 1>>$DEBUG 2>>$DEBUG &
eend 0
else
ewarn "No hotplug system found. Should be handled by udev. Skipping execution." ; eend 0
fi
fi
}
# }}}
# {{{ blacklist specific module
config_blacklist(){
if checkbootparam "blacklist" ; then
if [ -z "$INSTALLED" ]; then
einfo "Bootoption blacklist found."
BLACK="$(getbootparam 'blacklist' 2>>$DEBUG)"
if [ -n "$BLACK" ] ; then
einfo "Blacklisting module ${BLACK} via /etc/modprobe.d/grml."
echo "# begin entry generated by config_blacklist of grml-autoconfig" >> /etc/modprobe.d/grml
echo "blacklist $BLACK" >> /etc/modprobe.d/grml
echo "alias $BLACK off" >> /etc/modprobe.d/grml
echo "# end entry generated by config_blacklist of grml-autoconfig" >> /etc/modprobe.d/grml ; eend $?
else
eerror "No given module for blacklist found. Blacklisting will not work therefor."
fi
else
ewarn "Backlisting via bootoption does not work on harddisk installations." ; eend 1
eindent
einfo "Please blacklist the module(s) via /etc/modprobe.d/blacklist."
eoutdent
fi
fi
}
# }}}
# {{{ ACPI
config_acpi_apm(){
if [ -d /proc/acpi ]; then
if checkbootparam "noacpi"; then
ewarn "Skipping ACPI Bios detection as requested on boot commandline." ; eend 0
else
einfo "ACPI Bios found, activating modules: "
eindent
found=""
for a in /lib/modules/$KERNEL/kernel/drivers/acpi/*; do
basename="${a##*/}"
basename="${basename%%.*}"
case "$basename" in *_acpi)
egrep -qi "${basename%%_acpi}" /proc/acpi/dsdt 2>>$DEBUG || continue ;;
esac
modprobe $basename >>$DEBUG 2>&1 && found="yes"
local BASE="$BASE $basename"
done
if [ -n "$found" ] ; then
einfo "$BASE" ; eend 0
else
ewarn "(none)" ; eend 1
fi
if ! [ -S /var/run/acpid.socket ] ; then
if ! [ -r /var/run/dbus/pid ] ; then
einfo "Starting acpi daemon."
/etc/init.d/acpid start >>$DEBUG ; eend $?
else
eerror "acpid error: it seems you are running d-bus/hal, but acpid needs to be started before d-bus."
eerror "Solution: please activate acpid via /etc/runlevel.conf"
eend 1
fi
else
ewarn "acpi daemon already running."
eend 0
fi
eoutdent
fi
else
# APM
if checkbootparam "noapm"; then
ewarn "Skipping APM Bios detection as requested on boot commandline." ; eend 0
else
modprobe apm power_off=1 >>$DEBUG 2>&1
if [ "$?" = "0" ] ; then
if [ -x /etc/init.d/apmd ] ;then
einfo "APM Bios found, enabling power management functions."
/etc/init.d/apmd start ; eend $?
fi
else
eerror "Loading apm module failed." ; eend 1
fi
fi
fi
}
# }}}
# {{{ PCMCIA Check/Setup
# This needs to be done before other modules are being loaded (by hwsetup)
config_pcmcia(){
if checkbootparam "nopcmcia"; then
ewarn "Skipping PCMCIA detection as requested on boot commandline." ; eend 0
else
if /usr/sbin/laptop-detect ; then
einfo "Detected Laptop - checking for PCMCIA." && eend 0
modprobe pcmcia_core >>$DEBUG 2>&1
# Try Cardbus or normal PCMCIA socket drivers
modprobe yenta_socket >>$DEBUG 2>&1 || modprobe i82365 >>$DEBUG 2>&1 || modprobe pd6729 >>$DEBUG 2>&1 || modprobe tcic >>$DEBUG 2>&1
if [ "$?" = "0" ]; then
modprobe ds >>$DEBUG 2>&1
if [ -d /proc/bus/pccard ] ; then
if [ -x /sbin/cardmgr ] ; then
einfo "PCMCIA found, starting cardmgr."
cardmgr >>$DEBUG 2>&1 && sleep 6 && eend 0
else
eerror "No cardmgr found. Make sure package pcmciautils is installed, it should handle it instead." ; eend 1
fi
fi
fi
fi
fi
}
# }}}
# {{{ run software synthesizer via speakup
config_swspeak(){
if checkbootparam swspeak ; then
if [ -d /proc/speakup/ ] ; then
einfo "Bootoption swspeak found. Kernel supports speakup." ; eend 0
eindent
if [ -x /etc/init.d/speech-dispatcher ] ; then
einfo "Starting speech-dispatcher."
/etc/init.d/speech-dispatcher start 1>>DEBUG ; eend $?
einfo "Activating sftsyn in Kernel."
echo sftsyn >/proc/speakup/synth_name ; eend $?
einfo "Just run swspeak if you want to use software synthesizer via speakup."
flite -o play -t "Finished activating software speakup. Just run swspeak when booting finished."
else
eerror "speech-dispatcher not available. swspeak will not work without it." ; eend 1
flite -o play -t "speech-dispatcher not available. speakup will not work without it."
fi
eoutdent
else
eerror "Kernel does not seem to support speakup. Skipping swspeak." ; eend 1
flite -o play -t "Kernel does not seem to support speakup. Sorry."
fi
fi
}
# }}}
# {{{ Check for blind option or brltty
config_blind(){
BLIND=""
checkbootparam "blind" && BLIND="yes"
BRLTTY="$(getbootparam brltty 2>>$DEBUG)"
if [ -n "$BLIND" -o -n "$BRLTTY" ]; then
if [ -x /sbin/brltty ]; then
# Blind option detected, start brltty now.
# modprobe serial_core parport_serial generic_serial && echo "done"
CMD=brltty
BRLTYPE=""
BRLDEV=""
BRLTEXT=""
if [ -n "$BRLTTY" ]; then
# Extra options
BRLTYPE="${BRLTTY%%,*}"
R="${BRLTTY#*,}"
if [ -n "$R" -a "$R" != "$BRLTTY" ]; then
BRLTTY="$R"
BRLDEV="${BRLTTY%%,*}"
R="${BRLTTY#*,}"
if [ -n "$R" -a "$R" != "$BRLTTY" ]; then
BRLTTY="$R"
BRLTEXT="${BRLTTY%%,*}"
R="${BRLTTY#*,}"
fi
fi
fi
[ -n "$BRLTYPE" ] && CMD="$CMD -b $BRLTYPE"
[ -n "$BRLDEV" ] && CMD="$CMD -d $BRLDEV"
[ -n "$BRLTEXT" ] && CMD="$CMD -t $BRLTEXT"
einfo "Starting braille-display manager."
# ( exec $CMD & )
( sh -c "$CMD" & )
sleep 2 && BLINDSOUND="yes"
eend 0
fi
fi
}
# }}}
# {{{ Interactive configuration
config_interactive(){
if [ -n "$INTERACTIVE" ] ; then
einfo "Entering interactive configuration second stage."
echo " ${GREEN}Your console keyboard defaults to: ${MAGENTA}${KEYTABLE}"
echo -n "${CYAN}Do you want to (re)configure your console keyboard?${NORMAL} [Y/n] "
read a
[ "$a" != "n" ] && /usr/sbin/dpkg-reconfigure console-data ; eend $?
echo -n "${CYAN}Do you want to (re)configure your soundcard?${NORMAL} [Y/n] "
read a
[ "$a" != "n" ] && alsaconf && ( exec aumix -m 0 >>$DEBUG 2>&1 & ) ; eend $?
echo -n "${CYAN}Do you want to (re)configure your graphics (X11) subsystem?${NORMAL} [Y/n] "
read a
[ "$a" != "n" ] && xorgcfg -textmode ; eend $?
echo " ${GREEN}Interactive configuration finished. Everything else should be fine for now.${NORMAL}"
fi
eend 0
}
# }}}
# {{{ AGP
config_agp(){
if checkbootparam forceagp ; then
# Probe for AGP. Hope this can fail safely
stringinfile "AGP" "/proc/pci" 2>>$DEBUG && { modprobe agpgart || modprobe agpgart agp_try_unsupported=1; } >>$DEBUG 2>&1 && einfo "AGP bridge detected." ; eend 0
fi
}
# }}}
# {{{ automount(er)
config_automounter(){
if checkbootparam automounter ; then
RUNLEVEL="$(runlevel)"
AUTOMOUNTER=""
[ -x /etc/init.d/autofs ] && [ "$RUNLEVEL" != "N 1" ] && [ "$RUNLEVEL" != "N S" ] && AUTOMOUNTER="yes"
addautomount(){
# /dev/ice options
d="${1##*/}"
if [ -n "$AUTOMOUNTER" ]; then
[ -d "/mnt/$d" -a ! -L "/mnt/$d" ] && rmdir /mnt/$d
[ -d "/mnt/auto/$d" ] || mkdir -p "/mnt/auto/$d"
[ -L "/mnt/$d" ] || ln -s "/mnt/auto/$d" "/mnt/$d"
anew="$d -fstype=auto,$2 :$i"
stringinfile "$anew" "/etc/auto.mnt" || echo "$anew" >> /etc/auto.mnt
AUTOMOUNTS="$AUTOMOUNTS $d"
new="$1 /mnt/auto/$d auto users,noauto,exec,$2 0 0"
else
[ -d /mnt/$d ] && mkdir -p /mnt/$d
new="$1 /mnt/$d auto users,noauto,exec,$2 0 0"
fi
stringinfile "$new" "/etc/fstab" || echo "$new" >> /etc/fstab
}
AUTOMOUNTS="floppy cdrom"
# Add new devices to /etc/fstab and /etc/auto.mnt
for i in /dev/cdrom?*; do
if [ -L $i ]; then
addautomount "$i" "ro"
fi
done
fi
if [ -n "$AUTOMOUNTER" ]; then
# Check for floppy dir, reinstall with automounter
[ -d /mnt/floppy -a ! -L /mnt/floppy ] && rmdir /mnt/floppy
[ -d /mnt/auto/floppy ] || mkdir -p /mnt/auto/floppy
[ -L /mnt/floppy ] || ln -s /mnt/auto/floppy /mnt/floppy
[ -d /mnt/cdrom -a ! -L /mnt/cdrom ] && rmdir /mnt/cdrom
[ -d /mnt/auto/cdrom ] || mkdir -p /mnt/auto/cdrom
[ -L /mnt/cdrom ] || ln -s /mnt/auto/cdrom /mnt/cdrom
rm -f /etc/fstab.new
# Replace paths from bootfloppy
sed 's|/mnt/cdrom|/mnt/auto/cdrom|g;s|/mnt/floppy|/mnt/auto/floppy|g' /etc/fstab > /etc/fstab.new
mv -f /etc/fstab.new /etc/fstab
# Start automounter now
einfo "Starting automounter for ${AUTOMOUNTS}."
/etc/init.d/autofs start >>$DEBUG ; eend $?
fi
}
# }}}
# {{{ Collect partitions from /proc/partitions first for enabling DMA
check_partitions(){
partitions=""
IDEDISKS=""
while read major minor blocks partition relax; do
partition="${partition##*/}"
[ -z "$partition" -o ! -e "/dev/$partition" ] && continue
case "$partition" in
hd?) IDEDISKS="$IDEDISKS $partition";; # IDE Harddisk, entire disk
sd?) ;; # SCSI Harddisk, entire disk
# [hs]d*) partitions="$partitions /dev/$partition";; # IDE or SCSI disk partition
[hs]d*|ub*) partitions="$partitions /dev/$partition";; # IDE, USB or SCSI disk partition
esac
done <<EOT
$(awk 'BEGIN{old="__start"}{if($0==old){exit}else{old=$0;if($4&&$4!="name"){print $0}}}' /proc/partitions)
EOT
}
check_partitions 1>/dev/null 2>&1 # avoid output "check_partitions:3: read-only file system"
# }}}
# {{{ Enable DMA for all IDE drives now if not disabled
# Notice: Already done by linuxrc, maybe not on hd-installations
config_dma(){
if checkbootparam "nodma"; then
ewarn "Skipping DMA accelleration as requested on boot commandline." ; eend 0
else
for d in $(cd /proc/ide 2>>$DEBUG && echo hd[a-z]); do
if test -d /proc/ide/$d; then
if egrep -q 'using_dma[ \t]+0' /proc/ide/$d/settings 2>>$DEBUG; then
MODEL="$(cat /proc/ide/$d/model 2>>$DEBUG)"
test -z "$MODEL" && MODEL="[GENERIC IDE DEVICE]"
einfo "Enabling DMA acceleration for: ${WHITE}$d ${YELLOW}[${MODEL}]${NORMAL}"
echo "using_dma:1" >/proc/ide/$d/settings
eend 0
fi
fi
done
fi
}
# }}}
# {{{ Start creating /etc/fstab with HD partitions and USB SCSI devices now
config_fstab(){
NOSWAP=""
checkbootparam "noswap" && NOSWAP="yes"
if checkbootparam "nofstab"; then
ewarn "Skipping /etc/fstab creation as requested on boot commandline." ; eend 0
else
checkbootparam "anyswap" && export ANYSWAP='yes' || export ANYSWAP=""
einfo "Scanning for harddisk partitions and creating /etc/fstab. (Disable this via boot option: nofstab)"
iszsh && setopt nonomatch
if [ -x /usr/sbin/rebuildfstab ] ; then
config_userfstab || fstabuser=grml
/usr/sbin/rebuildfstab -r -u $fstabuser -g $fstabuser ; eend $?
else
ewarn "Command rebuildfstab not found. Install package grml-rebuildfstab." ; eend 1
fi
if [ -e /var/run/rebuildfstab.pid ]; then
# Another instance of rebuildfstab, probably from hotplug, is still running, so just wait.
sleep 8
fi
fi
# Scan for swap, config, homedir
if [ -z "$NOSWAP" -o -z "$INSTALLED" ]; then
einfo "Checking for swap partition(s)."
fi
GRML_IMG=""
GRML_SWP=""
HOMEDIR="$(getbootparam home)"
if [ -n "$partitions" ]; then
while read p m f relax; do
case "$p" in *fd0*|*proc*|*sys*|*\#*) continue;; esac
partoptions="users,exec"
fnew=""
case "$f" in swap)
eindent
if [ -n "$NOSWAP" ]; then
ewarn "Ignoring swap partition ${WHITE}$p${NORMAL} as requested." ; eend 0
else
case "$(dd if=$p bs=1 count=6 skip=4086 2>/dev/null)" in
S1SUSP|S2SUSP|pmdisk|[zZ]*)
if [ -n "$ANYSWAP" ] ; then
einfo "Using swap partition ${WHITE}${p}${NORMAL} [bootoption anyswap found]."
swapon $p 2>>$DEBUG ; eend $?
else
ewarn "Suspend signature on ${WHITE}${p}${NORMAL} found, not using as swap. (Force usage via boot option: anyswap)"
fi
;;
*)
if [[ "$p" == LABEL* ]] ; then
p=$(blkid -t $p | awk -F: '{print $1}')
fi
if grep -q $p /proc/swaps ; then
ewarn "Not using swap partition ${WHITE}${p}${NORMAL} as it is already in use." ; eend 0
else
einfo "Using swap partition ${WHITE}${p}${NORMAL}."
swapon $p 2>>$DEBUG ; eend $?
fi
;;
esac
fi
eoutdent
continue
;;