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
|
#!/bin/sh
# Copyright (c) 2003..2006 - RZ Uni Freiburg
# Copyright (c) 2006..2010 - 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) configuration script for OpenSLX linux
# diskless clients (executed in stage3 within initial ramfs). The file-
# system setup is completed when servconfig starts
#############################################################################
# check for configuration files to source
# functions common for all distros, messages contains all error and
# info output
. /etc/messages
. /etc/functions
# load distro specific configuration functions. Distro specific functions may
# overwrite functions defined in /etc/functions
. /etc/distro-functions
. /etc/slxsystem.conf
# load variables defined by plugins
[ -f /tmp/env/wrapper.env ] && . /tmp/env/wrapper.env
# script run timer
[ $DEBUGLEVEL -eq 8 ] && echo "** SW setup started at $(sysup)"
# heavy debugging output in level 3 and below 8 ...
[ $DEBUGLEVEL -gt 3 -a $DEBUGLEVEL -lt 8 -o $DEBUGLEVEL -eq 12 ] && \
set -x
#############################################################################
# read and unify configuration options - default configuration file, from
# dhcp, ldap ...
# wait for the appearance of configuration from several sources
cfgcomplete
. /etc/initramfs-setup
[ $DEBUGLEVEL -eq 8 ] && echo "** Config info is complete at $(sysup)"
# copy additional configuration and var files and directories
# admins can place there files in /var/lib/openslx/config/...
# to be packed during stage2 into (/srv/dxs)/tftpboot/client-config...)
cp -a /rootfs/* /mnt 2>/dev/null
# copy passwd, group files for temporarily (within stage3 configuration) used
# by chown
cp /mnt/etc/passwd /etc
cp /mnt/etc/group /etc
# set greeting and add information on booted system
len=$(expr length ${SLXVERSION}${SYSTEM_NAME})
if [ $len -le 28 ] ; then
vdstr="Stateless Workstation (V${SLXVERSION}/${SYSTEM_NAME})"
smax=28
else
vdstr="V${SLXVERSION}/${SYSTEM_NAME}"
smax=52
fi
while [ $len -le $smax ] ; do
vdstr="$vdstr "
len=$(($len + 1))
done
len=$(expr length ${host_name})
while [ $len -le 30 ] ; do
space="$space "
len=$(($len + 1))
done
echo "
WELCOME TO $space \n (\l)
_____ ______ ______ __ __ _______ __ __ __
/ _ | _ | ___| | | | | ____| | | | | |
| | | | |_| | |_ | | | | |___ | | / /
| | | | ___/| _| | | ____ | | | |
| |_| | | | |___| | | | ____| | |___ / /
_____/|__| |______|__| |__| |_______|______|__| |__|
$vdstr (c) <OpenSLX.ORG>
" >/mnt/etc/issue
#############################################################################
# set localization and add entries to initialize keytable and consolefont to
# boot.slx
if [ -z "${country}" ] ; then
error "$scfg_country" nonfatal
country="us"
fi
# do localization (this functions simply sets a list of variables)
localization "${country}"
# start distrospecific localization
dlocale
#############################################################################
# setup passwd and shadow for local system users like root, bin, daemon and
# nobody if no user/admin provided passwd exists ... fixme: see #206
[ ! -e /rootfs/etc/shadow ] && \
basepasswd $(sed "/+::0/d;s/root://;s/:.*//" /rootfs/etc/shadow 2>/dev/null)
#############################################################################
# dns and ip configuration
# hostname of the machine
echo "$host_name" >/proc/sys/kernel/hostname
echo -e "# /etc/hosts - file generated by $0 during OpenSLX stage3\
\n#\n# IP-Address Full-Qualified-Hostname Short-Hostname\n#\n\
127.0.0.1\tlocalhost\n::1\t\tlocalhost ipv6-localhost ipv6-loopback\n\
fe00::0\t\tipv6-localnet\nff00::0\t\tipv6-mcastprefix\nff02::1\
\t\tipv6-allnodes\nff02::2\t\tipv6-allrouters\nff02::3\t\t\
ipv6-allhosts\n" >/mnt/etc/hosts
if [ -n "${domain_name}" ]; then
echo -en "${clientip}\t" >>/mnt/etc/hosts
for name in ${domain_name}; do
echo -en "${host_name}.${name} " >>/mnt/etc/hosts
done
echo -e "${host_name}" >>/mnt/etc/hosts
else
echo -e "${clientip}\t${host_name}" >>/mnt/etc/hosts
fi
# set up domainname and resolving
rm -rf /mnt/etc/resolv.conf
test -n "${domain_name}" && \
echo -e "# /etc/resolv.conf - file generated by\n#\t$0:\n\
#\t${date}\n#options timeout:1 attempts:1 rotate\n\
search "${domain_name} >/mnt/etc/resolv.conf
test -n "${domain_name_servers}" && {
for name in ${domain_name_servers}; do
echo nameserver ${name} >>/mnt/etc/resolv.conf;
done; }
#############################################################################
# run distro specific configuration function
config_distro
#############################################################################
# basic (non network) services
# at daemon - calling distro specific function config_atd
config_atd
# configuration of cron services - calling distro specific function
# config_cron (runlevel links, directories, ...)
config_cron
# setup system log services - distro dependent function config_syslog
config_syslog
# acpi and powersave - distro dependent function config_acpi, these daemons
# might require dbus
config_acpi
# configure udev
config_udev
# configure dbus - distro dependent function config_dreshal - handle
# all stuff regarding dependent services like dbus, resmgr, hal ...
# (check for runlevel scripts, passwd entries, directories ...)
config_dreshal
# configure automounter (should be moved to plugin)
if [ "x$automnt" != "xno" ] ; then
# check if there is some user provided configuration (only auto.master is
# important) and skip automatic setup
if [ ! -f /rootfs/etc/auto.master ] ; then
if [ -d /mnt/misc ] ; then
echo -e "# /etc/auto.master - file generated by $0:\n\
/misc\t/etc/auto.misc" >/mnt/etc/auto.master
echo -e "# /etc/auto.misc - file generated by $0:" >/mnt/etc/auto.misc
else
echo -e "# /etc/auto.master - file generated by $0:\n\
/misc\t#/etc/auto.misc" >/mnt/etc/auto.master
echo -e "# /etc/auto.misc - file generated by $0:\nautomount for \
removable devices is mostly deprecated, so /misc is not\nactivated in \
auto.master." >/mnt/etc/auto.misc
fi
if [ -n "${automnt_src}" ] ; then
# local directory and home directory server from initialramfs-setup
[ -z "${automnt_dir}" ] && automnt_dir="/home"
# remove leading and trailing slash
automnt_dir=${automnt_dir#/}
automnt_dir=${automnt_dir%/}
test -d /${automnt_dir} || error "$scfg_erradir" nonfatal
amserv=$(uri_token $automnt_src server)
ampath=$(uri_token $automnt_src path)
amdirn=$(echo ${automnt_dir}|sed "s,/,_,g")
echo -e "/${automnt_dir}\t/etc/auto.${amdirn}\n" \
>> /mnt/etc/auto.master
echo -e "# /etc/auto.${amdirn} created by $0:\n" \
> /mnt/etc/auto.${amdirn}
# add '/' to path because uri_token removes any leading '/' (s. function)
echo -e "*\t-rsize=32768,wsize=32768,rw\t${amserv}:/${ampath}/&" \
>> /mnt/etc/auto.${amdirn}
# no tempfs needed if automounter operates on /home
[ "${automnt_dir}" = "home" ] && umount -t tmpfs /mnt/home 2>/dev/null
# portmapper is needed for remote NFS sources and local nfs directories
testmkd /mnt/var/lib/nfs/state
config_portmap
fi
fi
config_automount
fi
# configure print services / start requested printer daemon
config_printer
# configure bluetooth services
#[ -s /etc/hwinfo.bt ] if existance of bt devices should play any role
config_bt
#############################################################################
# network(ed) services
if [ -n "$ntp_servers" ]; then
# rdate uses the time protocol (port 37 which is not the ntp standard port)
# thus not every standard ntp-server might offer this service)
( rdate -s "$ntp_servers" 2>/dev/null || error "$scfg_rdate" nonfatal
hwclock -w ) &
fi
# network time service (ntp) configuration file
if [ -n "$ntp_servers" -a ! -f /rootfs/etc/ntp.conf ]; then
echo -e "# /etc/ntp.conf - file generated by $0: \
$date\n" >/mnt/etc/ntp.conf
for name in $ntp_servers; do
echo server $name >>/mnt/etc/ntp.conf
done
fi
# copy timezone file defined with language settings
[ -z "$TZ" ] && TZ="$timezone"
ln -snf /usr/share/zoneinfo/${TZ} /mnt/etc/localtime || \
error "$scfg_ntptz" nonfatal
config_ntp
# secure shell server - at the moment all clients share one "secret"
# key or the key has to be regenerated on every bootup or fetched on
# every bootup from somewhere
config_sshd
# simple network management protocol agent
config_snmp
# configure samba service
config_samba
#############################################################################
# NIS (variable typically fetched via dhcp)
# setup nis configuration if needed
if [ "x$nis_domain" != "x" -a "x$nis_servers" != "x" ] ; then
echo $nis_domain >/mnt/etc/defaultdomain
echo -e "# /etc/yp.conf - file generated by $0:\n#\t\
$date\n\nypserver "$nis_servers >/mnt/etc/yp.conf
config_nis
fi
#############################################################################
# name service caching daemon if networked user database
config_nscd
#############################################################################
# preparation of /tmp directory (partition 44, nfs scratch, ramdisk). there
# might be the chance that we have a disk partition available, so wait for
# completion of detection, setup process
[ $DEBUGLEVEL -eq 8 ] && echo "** Waiting for /tmp completion at $(sysup)"
waitfor /tmp/tmpready 40000
[ $DEBUGLEVEL -eq 8 ] && echo "** Setup of /tmp completed at $(sysup)"
# create some directories and correct permissions
tmpisdisk=$(sed -n '/\/tmp/p' /tmp/fstab 2>/dev/null)
# if there is no local disk partition for /tmp then try to mount a rw
# scratch space (if defined in $scratch) and prepared on server
if [ -n "$scratch" -a -z "$tmpisdisk" ] ; then
scrproto=$(uri_token $FILESRC prot)
scrpath=$(uri_token $FILESRC path)
testmkd /tmp/scratch
# exports have to be per client!!
case "$scrproto" in
nbd)
:
;;
*)
tmpserv=$(uri_token $scratch server)
tmppath=$(uri_token $scratch path)
# hanging mount processes might stop further setup - timeout
# should be configured ...
# fsmount proto server path target options
fsmount nfs ${tmpserv} ${tmppath} /tmp/scratch \
"rw,intr,soft,timeo=2,nosuid" && {
if [ -d /tmp/scratch/${clientip} ] ; then
mv /tmp/scratch/${clientip} /tmp/scratch/${clientip}.totrash
rm -rf /tmp/scratch/${clientip}.totrash 2>/dev/null &
fi
testmkd /tmp/scratch/${clientip}
# no need for tempfs there ...
umount /mnt/tmp >/dev/null 2>&1
fsmount nfs ${tmpserv} ${tmppath} /mnt/tmp \
"rw,intr,soft,timeo=2,nosuid"; }
;;
esac
fi
# script run timer
[ $DEBUGLEVEL -eq 8 ] && echo "** SW setup finished at $(sysup)"
# servconfig finished successfully
echo "servconfig finished at $(sysup)" > /tmp/svcfg
|