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
|
#!/bin/sh
# Copyright (c) 2003..2006 - RZ Uni Freiburg
# Copyright (c) 2006..2014 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your feedback to feedback@openslx.org
#
# General information about OpenSLX can be found under http://openslx.org
#
# Universal (distro independent) hardware autoconfiguration script for
# OpenSLX linux stateless clients, using SuSE hwinfo for configuration
#############################################################################
# pre part, load USB modules and start hardware detection pci
base () {
# avoid annoying error messages because of missing scripts
for tool in /usr/sbin/acpidump \
/usr/bin/udevinfo \
/sbin/dmraid ; do
testmkd ${tool%/*}
echo -e "#!/bin/sh" >${tool}
chmod u+x ${tool}
done
# no kernel messages, switch on hotplug via /sbin/mdev
echo "0 0 0 0" >/proc/sys/kernel/printk
echo "/sbin/mdev" >/proc/sys/kernel/hotplug
echo -e "card[0-9] 0:0 660 =dri/\n(control[A-Z])([0-9]+) 0:0 660 =dri/\n\
event[0-9] 0:0 640 =input/\n" >>/etc/mdev.conf
modprobe -a ${MODPRV} usbhid hid-bright hid-generic 2>/dev/null &
# check from vga= that the traditional framebuffer is needed e.g. for splashy
# get information on the graphics adaptor if bootsplash or xserver plugins are
# present and the new drm/kms infrastructure is present
if strinfile "vga=" /proc/cmdline; then
( modprobe -a vesafb fbcon 2>/dev/null
hwinfo --gfxcard >/etc/hwinfo.gfxcard ) &
elif [ -e /etc/init-hooks/00-started/xserver.sh -o \
-e /etc/init-hooks/05-have-kernelvars/bootsplash.sh ] && \
[ -e /lib/modules/${KERNEL}/kernel/drivers/gpu ]; then
# check for the standard modules (single gpu, multiple connector only)
( hwinfo --gfxcard >/etc/hwinfo.gfxcard
case $(cat /etc/hwinfo.gfxcard) in
*i915*)
modprobe -a ${MODPRV} i915 2>/dev/null
;;
*intel*|*Intel*)
modprobe -a ${MODPRV} i810 i830 i915 2>/dev/null
;;
*nvidia*|*NVidia*|*nouveau*)
modprobe ${MODPRV} nouveau 2>/dev/null
;;
*radeon*|*Radeon*)
modprobe ${MODPRV} radeon 2>/dev/null
;;
*mga*|*matrox*|*Matrox*)
modprobe ${MODPRV} mga 2>/dev/null
;;
*)
modprobe -a ${MODPRV} r128 savage sis tdfx ttm via
;;
esac
modprobe -a drm fbcon; mdev -s ) &
fi
# check and then load appropriate network card modules
nwcardlist=$(echo ${slxconf_listnwmod}|sed "s/\ /|/g")
# save results for later info and for Xen plugin when starting Xen VM
hwinfo --netcard --usb-ctrl >/etc/hwinfo.netcard-usbctrl
grep modprobe /etc/hwinfo.netcard-usbctrl | grep -E "$nwcardlist|hcd" \
| grep -v ehci | sed 's/.* Cmd: "//;s/"//;s/modprobe/modprobe -b ${MODPRV}/' \
| sort -u >/etc/modprobe.base
# virtio hack
if [ $(grep -ic "virtio_pci" /etc/modprobe.base) -ge 1 ]; then
echo 'modprobe ${MODPRV} virtio_net' >>/etc/modprobe.base
fi
sh /etc/modprobe.base; mdev -s
# optimization possible: exclude network and usb base drivers from the
# following list (bios detection for non-hwautocfg component)
( hwinfo --pci >/etc/hwinfo.data; echo "read pci device list at $(sysup)" \
>/tmp/hwdataready ) &
( usleep 100000 ; hwinfo --bios >/etc/hwinfo.bios ) &
# for mounting partitions/devices with the "auto" option
echo -e "ext3\next2\nreiserfs\nxfs\njfs\next4\nvfat" >/etc/filesystems
# request a local block device for config and root filesystem (lbd://)
if grep -iq '"lbd://' /proc/cmdline /etc/initramfs-setup; then
modprobe -a ${MODPRV} ehci_hcd usb-storage sd_mod
mdev -s
fi
return 0
}
#############################################################################
# main part
hwmain () {
# activate the previously detected devices
[ $DEBUGLEVEL -ge 2 ] || modloadbg=" >/dev/null 2>\&1"
# check for rtc if not compiled directly into the kernel
( [ -e /proc/driver/rtc ] || modprobe ${MODPRV} rtc-cmos ) &
waitfor /tmp/hwdataready 10000
sed '/Driver Info #1/,/Config Status:/d' /etc/hwinfo.data | grep modprobe \
| sed "s|.* Cmd: \"||;s|\"|$modloadbg|;s|modprobe|modprobe -b ${MODPRV}|" \
| sort -u >/etc/modprobe.pci
sh /etc/modprobe.pci
mdev -s
# bluetooth setup (start it later if present, depends on firmware availa-
# bility, interpreted by servconfig)
#( hwinfo --bluetooth >/etc/hwinfo.bt ) &
# load harddisk driver and check for harddisk
( grep -q -E "SCSI|SATA" /etc/hwinfo.data && modprobe ${MODPRV} sd_mod
grep -q -E "IDE" /etc/hwinfo.data && modprobe ${MODPRV} ide-disk
hwinfo --disk | sed -n "/Device File: /p" | \
sed -e "s|.*Device File: /dev/||;s| .*||" >/etc/hwinfo.disk
echo "disk detection finished at $(sysup)" >/tmp/diskready; ) &
[ $DEBUGLEVEL -eq 21 ] && echo "** finished 2nd hwdetection at $(sysup)"
# load disk/optical high level drivers
modprobe ${MODPRV} ide-cd 2>/dev/null
modprobe ${MODPRV} sr_mod 2>/dev/null
modprobe ${MODPRV} ide-floppy 2>/dev/null
mdev -s
# load kernel module for ps2 mice and map the mousehandler to /dev/input/mice
( [ -f /lib/modules/${KERNEL}/kernel/drivers/input/mouse/psmouse.ko ] && \
modprobe ${MODPRV} psmouse
[ -f /lib/modules/${KERNEL}/kernel/drivers/input/mousedev.ko ] && \
modprobe ${MODPRV} mousedev
testmkd /dev/input
mknod /dev/input/mice c 13 63 2>/dev/null
hwinfo --mouse >/etc/hwinfo.mouse ) &
# complete the audio configuration and load the dummy module if no audio
# hardware is present in the machine
grep -q -E "Audio|sound" /etc/hwinfo.data || modprobe snd-dummy
modprobe ${MODPRV} snd-pcm-oss
modprobe ${MODPRV} snd-mixer-oss
#ln -s /proc/sound/oss/sndstat /dev/sndstat
[ $DEBUGLEVEL -eq 21 ] && echo "** finished most of module loading at $(sysup)"
# scanner setup (fixme: to be checked)
hwinfo --scanner >/etc/hwinfo.scanner
[ -f /tmp/scanner-udev ] && cat /tmp/scanner-udev \
>>/mnt/etc/udev/rules.d/04-scanner.rules
# parallel port setup
modprobe ${MODPRV} parport_pc && modprobe ${MODPRV} ppdev
# if any new device appeared up to now
mdev -s
return 0
}
#############################################################################
# harddisk partition setup part
disk () {
# get idea of availabe harddisk partitions, put swap partitions into
# (/mnt)/etc/fstab and format and mount partitions of type 44 (unknown)
[ $DEBUGLEVEL -eq 21 ] && echo "** starting hdd stuff at $(sysup)"
waitfor /tmp/diskready 20000
if [ -s /etc/hwinfo.disk ] ; then
for hd in $(cat /etc/hwinfo.disk) ; do
fdisk -l /dev/$hd|sed -n "/^\/dev\//p" >/etc/disk.partition
for hdpartnr in $(cat /etc/disk.partition | \
sed -n -e "/ 82 /p"|sed -e "s/[[:space:]].*//") ; do
echo -e "$hdpartnr\tswap\t\tswap\t\tdefaults\t 0 0" >>/tmp/fstab
done
# we use special non assigned partition type (id44) for harddisk scratch
# space, thus no normal filesystem will be incidentally deleted or
# corrupted
for hdpartnr in $(cat /etc/disk.partition | \
sed -n -e "/ 44 /p"|sed -e "s/[[:space:]].*//") ; do
# check for supported filesystem and formatter
( if diskfm $hdpartnr ; then
echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready
echo -e "$hdpartnr\t/tmp\t\tauto\t\tdefaults\t 0 0" >>/tmp/fstab
else
echo "formatting failed for some reason ($(sysup))" >/tmp/tmpready
fi ) &
part44=yes
break
done
# put detected linux partitions (83) into /etc/fstab with "noauto",
# special partition 45 (persistent scratch) to /var/scratch and 46
# to /var/openslx
for partid in 83 45 46 ; do
for hdpartnr in $(cat /etc/disk.partition | \
sed -n -e "/ ${partid} /p"|sed -e "s/[[:space:]].*//") ; do
mkdir -p /mnt/media/${hdpartnr#/dev/*} 2>/dev/null
if [ ${partid} -eq 83 ] ; then
echo -e "$hdpartnr\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,\
noexec\t 0 0" >>/tmp/fstab
elif [ ${partid} -eq 45 ] ; then
# if more than one id45 present, the latter ones are simply mounted
# over the previous (the mounts are postponed a bit via do_mnt to
# have the filesystem completely prepared)
echo -e "waitfor ${hdpartnr} 10000\n\
mount -t auto ${hdpartnr} /mnt/media/${hdpartnr#/dev/*}\n\
ln -sf /media/${hdpartnr#/dev/*} /mnt/var/scratch" >>/etc/do_mnt
echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\
\t\t 0 0" >>/tmp/fstab
elif [ ${partid} -eq 46 ] ; then
# mount a home directory to (/mnt)/var/home
echo -e "waitfor ${hdpartnr} 10000\n\
mount -t auto ${hdpartnr} /mnt/media/${hdpartnr#/dev/*} \n\
test -d /mnt/media/${hdpartnr#/dev/*}/home && \
ln -sf /media/${hdpartnr#/dev/*} /mnt/var/home" >>/etc/do_mnt
echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\
\t\t 0 0" >>/tmp/fstab
fi
done
done
done
# determine if tmp preparation should wait for format/mount or not
[ -z "$part44" ] && echo "finished at $(sysup)" >/tmp/tmpready
else
echo "no harddisk found ( $(sysup) )" >/tmp/tmpready
fi
[ $DEBUGLEVEL -eq 21 ] && echo "** finished hdd stuff at $(sysup)"
}
#############################################################################
# cleanup/finishing part
finish () {
mdev -s
# mount filesystem parts (if any) requested in disk setup
[ -f /etc/do_mnt ] && \
{ sed -e "1i. /etc/functions" -i /etc/do_mnt; sh /etc/do_mnt; } &
# remove unneeded disk and mouse drivers
[ ! -s /etc/hwinfo.disk ] && rmmod sd_mod 2>/dev/null
#grep -q " PS/2 " /etc/hwinfo.mouse || \
# { rmmod psmouse 2>/dev/null; rm /dev/psaux 2>/dev/null; }
# more sophistication possible :)
# remove /sbin/mdev as not available in stage4
echo >/proc/sys/kernel/hotplug
return 0
}
#############################################################################
# main script starts here
# functions common for all distros
. /etc/functions
# functions common for all distros, messages contains all error and
# info output
. /etc/messages
# load distro specific configuration variables and functions. distro
# specific functions may overwrite functions defined in /etc/functions
. /etc/distro-functions
# source general slx and initramfs-setup settings
. /etc/slxsystem.conf
. /etc/initramfs-setup
# script run timer
[ $DEBUGLEVEL -eq 8 -o $DEBUGLEVEL -eq 21 ] && \
echo "** HW $1 setup started at $(sysup)"
# heavy debugging output in level 3 and above and specific for 11
[ $DEBUGLEVEL -gt 3 -a $DEBUGLEVEL -lt 8 -o $DEBUGLEVEL -eq 11 ] && \
set -x
case $1 in
# pre initialization: loading USB base and network adaptor modules,
# detection of other pci bus modules
base)
base
;;
# main part of hardware setup of pci stuff
main)
hwmain
# main script run timer or debug information
[ $DEBUGLEVEL -eq 8 -o $DEBUGLEVEL -eq 21 ] && \
echo "** HW main setup finished at $(sysup)"
echo "hwsetup main part finished at $(sysup)" >/tmp/hwcfg
;;
# disk setup part (detecting general id82,83 and slx id44,45,46, formatting
# if required and mounting)
disk)
# try to enable compressed RAM SWAP / ZRAM
if modprobe ${MODPRV} ramzswap 2>/dev/null && [ -f /usr/bin/rzscontrol ] ; then
mdev -s
rzscontrol /dev/ramzswap0 --init
swapon /dev/ramzswap0 2>/dev/null
#hdswap="# disk swap disabled because of enabled compressed ramswap"
elif modprobe ${MODPRV} zram 2>/dev/null ; then
mdev -s
# assign a quarter of total mem to zram
echo $(( $(free -k | awk '/^Mem:/ { print $2 }') * 256 )) > /sys/block/zram0/disksize
mkswap /dev/zram0 2>/dev/null
swapon /dev/zram0 2>/dev/null
fi
# if disk action is not disabled
if [ "x${hw_local_disk}" != "xno" ] ; then
disk
else
echo "using harddisk switched off by hw_local_disk set to 'no' ( $(sysup) )" \
>/tmp/tmpready
fi
;;
# remove unneeded kernel modules
finish)
finish
;;
esac
|