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
|
#!/bin/sh
#
# Description: universal (distro independent) hardware autoconfiguration
# script for linux diskless clients, using hwconfig from
# knoppix as base tool
#
# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 24-03-2006
# Blabla
# Blub
#
# Copyright: (c) 2003 - 2006 - RZ Universitaet Freiburg
#
# Version: 0.3.1e
# local functions used within hwautocfg
displaysetup () {
local xfc=$1
# define some defaults
local HSYNCRANGE="31.5-63.5"
local VSYNCRANGE="60-90"
local MAXRES="1024x768"
local DEFAULTCOLORDPT=24
# set variables representing the xorg.conf sections (version 6.8.x)
local Module='\tLoad\t\t"dbe"\n
\tLoad\t\t"extmod"\n
\tLoad\t\t"type1"\n
\tLoad\t\t"speedo"\n
\tLoad\t\t"freetype"\n
\tLoad\t\t"v4l"'
local ServerFlags='\tOption\t\t"AllowMouseOpenFail"\n
\tOption\t\t"blank time"\t\t"5"\n
\tOption\t\t"standby time"\t\t"10"\n
\tOption\t\t"suspend time"\t\t"15"\n
\tOption\t\t"off time"\t\t"20"'
local Files='\tRgbPath\t\t"/usr/X11R6/lib/X11/rgb"\n
\tModulePath\t"/etc/X11/modules"\n
\tModulePath\t"/usr/X11R6/lib/modules"\n
\tFontPath\t"/usr/X11R6/lib/X11/fonts/misc/:unscaled"\n
\tFontPath\t"/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"\n
\tFontPath\t"/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"'
local InputDevice='\tIdentifier\t"Keyboard1"\n
\tDriver\t\t"keyboard"\n
\tOption\t\t"XkbRules"\t\t"xfree86"\n
\tOption\t\t"XkbLayout"\t\t"XKEYBOARD"\n
\tOption\t\t"XkbModel"\t\t"pc105"'
local InputMouseDef='\tIdentifier "Mouse1"\n
\tDriver\t\t"mouse"\n
\tOption\t\t"Protocol"\t\t"imps/2"\n
\tOption\t\t"Device"\t\t"/dev/input/mice"\n
\tOption\t\t"Emulate3Buttons"\n
\tOption\t\t"ZAxisMapping"\t\t"4 5"\n
\tOption\t\t"Buttons"\t\t"3"'
local Monitor='\tIdentifier "Default"\n
\tModelName\t"MODEL"\n
\tOption\t"CalcAlgorithm"\t"CheckDesktopGeometry"\n
\tHorizSync\tHS\n
\tVertRefresh\tVS\n
\tUseModes\t"Default"\n
\tOption\t"DPMS"\t"true"'
local Modes='\tIdentifier "Default"'
local Modelines='
\t# crt modelines (refreshrates should be above 72Hz or enable uncommented lines)\n
\tModeline "640x400" 25.175 640 664 760 800 400 409 411 450\n
\tModeline "640x400" 31.5 640 672 736 832 400 401 404 445\n
\tModeline "640x480" 31.50 640 680 720 864 480 488 491 521\n
\tModeline "640x480" 45.80 640 672 768 864 480 488 494 530\n
\tModeline "800x600" 50.00 800 856 976 1040 600 637 643 666\n
\tModeline "800x600" 69.65 800 864 928 1088 600 604 610 640\n
\t#Modeline "1024x768" 44.90 1024 1048 1208 1264 768 776 784 817 interlace\n
\tModeline "1024x768" 80.00 1024 1052 1164 1360 768 784 787 823\n
\tModeline "1024x768" 86.00 1024 1040 1152 1360 768 784 787 823\n
\tModeline "1024x768" 98.90 1024 1056 1216 1408 768 782 788 822\n
\tModeline "1024x768" 115.50 1024 1056 1248 1440 768 771 781 802\n
\tModeline "1152x864" 92.00 1152 1208 1368 1474 864 865 875 895\n
\tModeline "1152x864" 110.00 1152 1240 1324 1552 864 864 876 908\n
\tModeline "1280x960" 112.00 1280 1312 1456 1704 960 963 970 1064\n
\tModeline "1280x960" 142.00 1280 1312 1456 1712 960 963 970 1064\n
\tModeline "1280x1024" 145.00 1280 1312 1456 1712 1024 1027 1030 1064\n
\tModeline "1280x1024" 157.50 1280 1344 1504 1728 1024 1025 1028 1072\n
\tModeline "1400x1050" 180.00 1400 1472 1672 1880 1050 1052 1055 1100\n
\tModeline "1600x1200" 202.50 1600 1664 1856 2160 1200 1201 1204 1250\n
\t# tft modlines (refreshrates of 60Hz schould be ok)\n
\tModeline "lcd1024x768" 67.90 1024 1052 1164 1360 768 784 787 823\n
\tModeline "lcd1280x1024" 108.00 1280 1328 1440 1688 1024 1025 1028 1066\n
\tModeline "lcd1400x1050" 160.00 1400 1472 1672 1880 1050 1052 1055 1100'
local Device='\tIdentifier\t"StdGraphics"\n
\tVendorName\t"XDESC"\n
\tDriver\t\t"XMODULE"'
local Screen='\tIdentifier\t"Screen 1"\n
\tDevice\t\t"StdGraphics"\n
\tMonitor\t\t"Default"\n
\tDefaultColorDepth CDP'
local ServerLayout='\tIdentifier\t"Simple Layout"\n
\tScreen\t"Screen 1"\n
\tInputDevice "Keyboard1"\t"CoreKeyboard"\n
\tInputDevice "Mouse1"\t"CorePointer"\n
\tOption\t"BlankTime"\t"5"\n
\tOption\t"StandbyTime"\t"10"\n
\tOption\t"SuspendTime"\t"20"\n
\tOption\t"OffTime"\t"30"'
local DRI='\tGroup\t\t"video"\n
\tMode\t\t0666'
if [ -n "$hw_graphic" ] ; then
DRV=${hw_graphic% *}
CDP=${hw_graphic##* }
msg="Please check your graphic adaptor settings ($hw_graphic)."
if [ -z "$DRV" ] ; then error " Manual configuration of your graphic \
hardware module to set failed.\n $msg" nonfatal
XMODULE=DRV
else
[ -z "${XMODULE}" ] && XMODULE=vesa
fi
fi
if [ -z "$CDP" ] ; then error " Manual configuration of your graphic \
systems color depth failed.\n $msg" nonfatal
CDP=${DEFAULTCOLORDPT}
fi
if [ -n "$hw_monitor" ] ; then
# just cut all starting from k(Hz) ...
HS=${hw_monitor%k*}
VS=${hw_monitor%Hz*}
[ -z "$VS" ] && VS=${hw_monitor%hz*}
VS=${VS##* }
MR=${hw_monitor##* }
msg="Please check your predefined monitor settings ($hw_monitor): Manual\n\
configurtion of display"
else
# gather monitor information automatically
ddcprobe > /tmp/ddcprobe
msg="Please check the output of ddcprobe. The settings where not \
complete\n or non existant. The $0 script tried for a fully automatic\n\
configuration of display"
fi
if [ -z "$HS" ] ; then error " $msg timings requested but could not \
establish\n horizontal frequency in kHz." nonfatal
HS=${HSYNCRANGE}
fi
if [ -z "$VS" ] ; then error " $msg timings but could not establish \
vertical\n frequency in Hz." nonfatal
VS=${VSYNCRANGE}
fi
if [ -z "$MR" ] ; then error " $msg resolution requested but not \
established." nonfatal
MR=${MAXRES}
fi
monmanual=yes
## compute max resolution
#for res in 640x400 640x480 800x600 1024x768 1280x1024 1400x1050 1600x1200
# do MODES="\"$res\" \"lcd$res\" $MODES"
# [ "$res" = "$MR" ] && break
#done
MODES=`screenres | sed -n '/Recommended Screen Modes:/s/[^"]*\(.*\)/\1/p'`
# finally write config file
echo -e "#\n# autogenerated X hardware configuration by $0\n# \
Dirk von Suchodoletz <dirk@goe.net>, $date" >$xfc
echo -e "# DO NOT EDIT THIS FILE BUT '$0' INSTEAD!\n#" \
>>$xfc
for section in Files ServerFlags Module InputDevice Monitor \
Modes Screen Device ServerLayout DRI ; do
echo "Section \"$section\"" >>$xfc
case "$section" in
Files)
echo -e ${Files} >>$xfc
# check for 64bit CPU/installation (fixme!!)
[ -n "$amd64" ] && \
echo '"\tModulePath\t"/usr/X11R6/lib64/modules"\n' >>$xfc
for i in ${D_XFONTPATH} ; do
echo -e "\tFontPath\t\"$i/\"" >>$xfc ; done
;;
ServerFlags)
echo -e ${ServerFlags} >>$xfc
;;
Device)
echo -e ${Device} | \
sed -e "s,XMODULE,${XMODULE}," -e "s%XDESC%${XDESC}%" >>$xfc
# special options may be needed for some drivers
[ $DEBUGLEVEL -gt 1 ] && msg "X setup" \
"adding for some Xfree86 modules \
(radeon, s3virge, nvidia) special options to\nthe 'Device' section. Consult \
hwsetup if you like to add more or remove some."
[ x$DRV = "xs3virge" ] && {
echo -e "\tOption\t\t\"XVideo\" \"Off\"\n" >>$xfc
[ $DEBUGLEVEL -gt 1 ] && msg "X setup" \
"added special option for \
the s3virge module -> 'XVideo Off'. remove the\nappropriate line in hwsetup \
if you like not to use it." ; }
[ x$DRV = "xnvidia" ] && {
echo -e "\tOption\t\t\"NvAGP\" \"3\"" >>$xfc
echo -e "\tOption\t\t\"NoLogo\" \"1\"" >>$xfc
[ $DEBUGLEVEL -gt 1 ] && msg "X setup" \
"added special option for \
the nvidia module -> 'NvAGP '. it sets the use\nof internal or external \
agpgart support." ; }
[ "$busid" ] && {
echo -e "\tOption\t\t\"BusID\" \"$busid\"" >>$xfc
[ $DEBUGLEVEL -gt 1 ] && msg "X setup" \
"added special option for \
the 'BusID' information - it\ndefines the npostion of graphics adaptor in \
pci/agp bus needed for acceleration." ; }
;;
Module)
echo -e ${Module} >>$xfc
[ x$DRM = "xyes" ] && \
echo -e "\tLoad\t\t\"dri\"" >>$xfc
[ x$GLX != "xno" ] && \
echo -e "\tLoad\t\t\"glx\"" >>$xfc
;;
Monitor)
echo -e ${Monitor} | \
sed -e "s,HS,${HS},g" -e "s,VS,${VS},g" >>$xfc
;;
InputDevice)
echo -e ${InputDevice} | sed -e "s,XKEYBOARD,${XKEYBOARD},g" \
>>$xfc
[ "${XKEYBOARD}" = "de" ] && \
echo -e '\tOption\t\t"XkbVariant"\t\t"nodeadkeys"' >>$xfc
echo -e "EndSection\n\nSection \"$section\"" >>$xfc
echo -e $InputMouseDef >>$xfc
;;
Modes)
echo -e ${Modes} >>$xfc
echo -e ${Modelines} >>$xfc
;;
Screen)
echo -e ${Screen} | sed -e "s,CDP,${CDP}," >>$xfc
for BPP in 15 16 24 32
do echo -e '\tSubSection "Display"\n\t\tDepth\t'\
$BPP'\n\t\tModes\t'$MODES'\n\tEndSubSection' >>$xfc
[ $BPP = "$CDP" ] && break
done
;;
ServerLayout)
echo -e ${ServerLayout} >>$xfc
;;
esac
echo -e "EndSection\n" >>$xfc
done
# only if X is link itself (normally to /var/X11R6/bin/X) check!!
link=`ls -l /mnt/usr/X11R6/bin/X 2>/dev/null`
if strinstr "/var/X11R6" "$link" ; then
testmkd /mnt/var/X11R6/bin
for i in /usr/X11R6/bin/Xorg /usr/X11R6/bin/XFree86 ; do
[ -e "/mnt/$i" ] && { ln -sf $i /mnt/var/X11R6/bin/X; break; }
done
fi
}
#######################################################################
# script starts here
# functions common for all distros
. /etc/functions
# load distro specific configuration variables and functions. distro
# specific functions may overwrite functions defined in /etc/functions
. /etc/sysconfig/config
. /etc/distro-functions
# heavy debugging output in level 3 and above ...
[ $DEBUGLEVEL -gt 2 ] && set -x
# set X11 configuration file
if [ -n "${D_XF86CONFFILE}" ] ; then
D_XF86CONFFILE="/mnt/${D_XF86CONFFILE}"
else
D_XF86CONFFILE="/mnt/etc/X11/xorg.conf"
error " You should define the variable D_XF86CONFFILE in yours distro \
configuration\n file" nonfatal
fi
# USB core is needed for presence of /proc/bus/usb
modprobe ${MODPRV} usbcore &
# "drivers" (pseudo, placeholder strings, ...) to exclude from loading
# depending on distro more hw modules have to be excluded too. use the
# D_HWMODTOIGNORE for that purpose
DRIVERLIST=" disabled unknown ignore pcspkr synaptics keybdev\
${D_HWMODTOIGNORE} "
# driver blacklist (real modules which fail to load)
DRIVERLIST=${DRIVERLIST}"hw_random kanotix genericwheelusb "
# hack for pseudo modules (not to load)
for i in $DRIVERLIST ; do
echo -e "alias\t$i\tusbcore" >> /etc/modprobe.conf
done
# load kernel module for ps2 mice
[ -f /lib/modules/${KERNEL}/kernel/drivers/input/mouse/psmouse.ko ] && \
modprobe ${MODPRV} psmouse
# and map the mousehandler to /dev/input/mice
[ -f /lib/modules/${KERNEL}/kernel/drivers/input/mousedev.ko ] && \
modprobe ${MODPRV} mousedev
# start the knoppix hardware autodetection tool
( hwsetup -v > /tmp/hwsetup.info && echo "hwsetup" > /tmp/hwrun1 ) &
# ACPI configuration - at least not needed with SuSE 9.3/10.0
# needed for other distros?
# AGP configuration (agpgart and chipset specific driver)
modprobe ${MODPRV} agpgart || \
modprobe ${MODPRV} agpgart agp_try_unsupported=1
# wait for /tmp/hwsetup.info to appear
waitfor /tmp/hwrun1 50000 || \
error " Expected information from hwsetup to appear in \
/tmp/hwsetup.info.\n Unable to configure parts of the systems hardware. \
Please check that\n hwsetup is properly installed and executable."
# load ide drivers first, takes a while to initialize
for DRIVER in cmd64x hpt366 piix slc90e66 cs5520 it821x rz1000 \
triflex aec62xx cs5530 ns87415 sc1200 trm290 alim15x3 \
cy82c693 opti621 serverworks via82cxxx amd74xx pdc202xx_new \
siimage atiixp hpt34x pdc202xx_old sis5513; do
strinfile " ${DRIVER}" /tmp/hwsetup.info && {
IDE="yes"
modprobe ${MODPRV} ${DRIVER} &
DRIVERLIST="${DRIVERLIST} ${DRIVER}"; }
done
# check for IDE/SCSI (SATA) - incomplete list
for DRIVER in ata_piix sata_via sata_nv; do
strinfile " ${DRIVER}" /tmp/hwsetup.info && {
#SCSIIDE="yes"
modprobe ${MODPRV} ${DRIVER} &
DRIVERLIST="${DRIVERLIST} ${DRIVER}"; }
done
# check for USB, pcmcia and ieee1394 hardware drivers
for DRIVER in ohci-hcd uhci-hcd ehci-hcd ohci1394; do
strinfile " ${DRIVER}" /tmp/hwsetup.info && {
USB="yes"
modprobe ${MODPRV} ${DRIVER}
DRIVERLIST="${DRIVERLIST} ${DRIVER}"; }
done
# load usbhid (for USB keyboard/mouse) or remove usbcore module if USB
# not present
if [ -n "$USB" ] ; then
modprobe ${MODPRV} usbhid &
else rmmod usbcore
fi
# remove unneeded network card modules
for DRIVER in ${NWMODULES}; do
strinfile " ${DRIVER}" /tmp/hwsetup.info || {
rmmod ${DRIVER}
DRIVERLIST="${DRIVERLIST} ${DRIVER}"; }
done
# sound card setup (alsa and oss compatibility drivers)
if [ -f /etc/sysconfig/sound ] ; then
. /etc/sysconfig/sound
else DRIVER="snd-dummy"
fi
modprobe ${MODPRV} ${DRIVER}
DRIVERLIST="${DRIVERLIST} ${DRIVER} "
modprobe -a ${MODPRV} snd_pcm_oss snd_mixer_oss
# check for PCMCIA / cardbus stuff
for DRIVER in yenta_socket i82365 pd6729 tcic; do
strinfile ${DRIVER} /tmp/hwsetup.info && {
modprobe ${MODPRV} ${DRIVER}
DRIVERLIST="${DRIVERLIST} ${DRIVER}"
PCMCIA="yes"; }
done
if [ -n "${PCMCIA}" ] ; then
#echo "pcmcia=\"yes\"" > config
modprobe ${MODPRV} ds
fi
# remaining drivers listed in /tmp/hwsetup.info
cat /tmp/hwsetup.info| while read LINE ; do
if strinstr "driver:" "${LINE}"; then
DRIVER=${LINE##driver: }
if ! strinstr " ${DRIVER} " "${DRIVERLIST}"; then
strinstr "Card:" "${DRIVER}" || strinstr "ps/2" "${DRIVER}" || {
modprobe ${MODPRV} ${DRIVER} &
usleep 10; }
DRIVERLIST="${DRIVERLIST} ${DRIVER}"
fi
fi
done
# rerun the knoppix hardware autodetection tool for USB and ide devices
# like dvd or harddisk - wait a few seconds so hopefully the ide driver
# is initialized
test -f /proc/bus/usb/devices || mount -n -t usbfs usbfs /proc/bus/usb
[ -n "$IDE" ] && modprobe -q ide_generic 2>/dev/null
usleep 10 && hwsetup -v > /tmp/hwsetup.info
# check if USB mouse and/or keyboard is connected and remove usbhid if
# not
strinfile "genericwheelusb" /tmp/hwsetup.info || \
(strinfile "keybdev" /tmp/hwsetup.info || rmmod usbhid)
# load IDE high level drivers
if [ -n "$IDE" ] ; then
# you might want to check /etc/sysconfig/floppy for more info
strinfile "ZIP" /tmp/hwsetup.info && modprobe ${MODPRV} ide_floppy
strinfile "CDROM" /tmp/hwsetup.info && modprobe ${MODPRV} ide_cd
strinfile "HD" /tmp/hwsetup.info && modprobe ${MODPRV} ide_disk
fi
# not rather precise ...
if strinfile "SCSI" /tmp/hwsetup.info ; then
strinfile "CDROM" /tmp/hwsetup.info && modprobe -a ${MODPRV} sr_mod sg
strinfile "HD" /tmp/hwsetup.info && modprobe ${MODPRV} sd_mod
fi
# fixme - psmouse entladen, falls nicht vorhanden
# configure some variables from configuration file - wait for dhcp or ldap
# confiurator to complete
waitfor /tmp/dhcp-done 10000 || error " Did not get any configuration \
data via dhcp until now ..." nonfatal
waitfor /tmp/ldap-done 10000 || error " Did not get any configuration \
data via ldap until now ..." nonfatal
. /etc/machine-setup
# wait for completion of clients root filesystem in /mnt
waitfor /tmp/fscmpl 40000
# postpone some commands into normal bootup environment
echo -e "\t# entry added by $0: $date" \
>>/mnt/etc/${D_INITDIR}/boot.ld
# get idea of availabe harddisk partitions, put swap partitions into
# (/mnt)/etc/fstab and format and mount partitions of type 44 (unknown)
for hd in $(cat /tmp/hwsetup.info|sed -n -e '/HD$/,/device:/p'| \
sed -n -e '/device:/p' | sed -e 's/device: //') ; do
fdisk -l /dev/$hd| sed -n "/^\/dev\//p" > /tmp/hd_part
for hdpartnr in $(cat /tmp/hd_part | \
sed -n -e "/ 82 /p"|sed -e "s/[[:space:]].*//") ; do
echo -e "$hdpartnr\tswap\t\tswap\t\tdefaults\t 0 0" >> /mnt/etc/fstab
done
# we use special non assigned partition type for harddisk scratch space
for hdpartnr in $(cat /tmp/hd_part | \
sed -n -e "/ 44 /p"|sed -e "s/[[:space:]].*//") ; do
# ugly message from ext2 mount :-(
( mkfs.ext2 -q $hdpartnr; mount -n $hdpartnr /mnt/tmp; \
echo "$hdpartnr" > /tmp/tmpready ) &
echo -e "$hdpartnr\t/tmp\t\text2\t\tdefaults\t 0 0" >> /mnt/etc/fstab
part44=yes
break
done
# put detected linux partitions into /etc/fstab with "noauto"
for hdpartnr in $(cat /tmp/hd_part | \
sed -n -e "/ 83 /p"|sed -e "s/[[:space:]].*//") ; do
mkdir -p /mnt/media/${hdpartnr#/dev/*} 2>/dev/null
echo -e "$hdpartnr\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,\
noexec\t 0 0" >> /mnt/etc/fstab
done
done
# determine if tmp preparation should wait for format/mount or not
[ -z "$part44" ] && echo "finished" > /tmp/tmpready
# run localizator and configure keyboard and console fonts
DEFKEYTABLE="de-latin1-nodeadkeys"
localization $country
if [ -z "${KEYTABLE}" ] ; then
msg "Keyboard setup" "No settings found for keyboard, using default of \
'${DEFKEYTABLE}' defined\nin $0."
KEYTABLE=${DEFKEYTABLE}
fi
echo -e "\tloadkeys -q ${KEYTABLE}\n" >>/mnt/etc/${D_INITDIR}/boot.ld
[ -n "${CONSOLE_FONT}" ] && consolefont
# run X11 / Xorg configurator
. /etc/sysconfig/xserver >/dev/null 2>&1 || error " The xserver \
configuration file generated by hwsetup could not\n be found." nonfatal
displaysetup ${D_XF86CONFFILE}
echo "finished" > /tmp/hwcfg
|