source: hybrid/branches/releng-9.0/nanobsd/cfg/nanobsd.wleiden@ 10835

Last change on this file since 10835 was 10835, checked in by rick, 13 years ago

Make sure to umount in case of failure which normally uses exit 1 to terminate.

File size: 14.0 KB
Line 
1## Dit is een NanoBSD configuratie-template voor WirelessLeiden.
2## Instellingen weergegeven binnen dit bestand gelden als
3## standaard binnen de organisatie.
4
5# Little hack to allow proper secify of KERNL/PKG location
6if [ -n "$NANO_CFG_FILE" ]; then
7 NANO_CONF_DIR=$(cd $(dirname $NANO_CFG_FILE); pwd -P)
8else
9 NANO_CONF_DIR=$(cd $(dirname $2); pwd -P)
10fi
11
12# object naam in /usr/obj/nanobsd.{obj}
13NANO_NAME=wleiden-hybrid
14NANO_SRC=/usr/src # nanobsd source tree
15NANO_KERNEL=$NANO_CONF_DIR/kernel.wleiden # naam van het kernel configuratiebestand
16NANO_IMAGES=2 # aantal nanobsd code slices/installs (1/2)
17
18NANO_CONFSIZE=8192 # volume van de config slice, default 2048 (512bs)
19NANO_DATASIZE=0 # volume van de data slice, 0 = not configured
20NANO_CODESIZE=819200
21NANO_RAM_TMPVARSIZE=20480
22
23NANO_DRIVE=ada0
24
25#XXX: Eeks, fixed packages, needs building a hook to allow building the package
26# of the shelfs if needed, copy to right directory, done. With only input needed
27# a list of ports in the format like net/net-snmp
28NANO_PACKAGE_DIR=$NANO_CONF_DIR/../pkg/All
29
30# Wireless Leiden ports from $WL_PORTSDIR are copied OVER $PORTSDIR
31PORTSDIR='/usr/ports'
32WL_PORTSDIR="$NANO_CONF_DIR/../ports/"
33
34# Dirty quirk to allow comments in part below
35PACKAGE_LIST=`cat <<EOF | sed -e 's/#.*$//g' | xargs
36benchmarks/iperf
37devel/py-Jinja2
38devel/py-yaml
39dns/dnsmasq
40editors/vim-lite
41ftp/curl
42lang/python
43net-mgmt/net-snmp
44net-mgmt/nrpe2
45net/isc-dhcp42-server
46net/pen
47net/sixxs-aiccu
48security/nmap
49security/openvpn
50security/sudo
51shells/bash-static
52sysutils/screen
53sysutils/ucspi-tcp
54www/thttpd
55www/tinyproxy
56
57# Extra WL ports
58net/lvrouted
59`
60# Package target
61# Dirty quirk to allow comments in part below
62PKG_MAKE_ARGS=`cat <<EOF | sed 's/#.*$//g' | xargs
63PACKAGES=$(dirname $NANO_PACKAGE_DIR)
64BATCH=yes PACKAGE_BUILDING=yes
65# www/py-cherrypy
66WITH_APACHE=yes
67# net-mgmt/net-snmp
68WITHOUT_PERL=yes
69WITHOUT_PERL_EMBEDDED=yes
70# net-mgmt/nagios-plugins
71WITH_FPING=yes
72# threads is broken in the version (atleast up to 9.0 - 20120213)
73# Should be fix in current version in linux, but for some reason
74# Not yet in BSD. We don't need threads
75WITHOUT_THREADS=yes
76# shells/bash-static
77WITH_SYSLOG=yes
78`
79
80##NANO_PACKAGE_LIST=
81
82# Warning: set to 1 to debug make build errors
83# Number of recurrent parrallel make builds
84if `grep -q 'acpi0: <PRLS PRLS_OEM> on motherboard' /var/run/dmesg.boot`; then
85 # Mac OS X Parallels virtual machine
86 NANO_PMAKE="make -B"
87else
88 # Default 2 times number of CPU's inside machine
89 NANO_PARALLEL_MAKE=`expr $(sysctl -n hw.ncpu) \* 2`
90 NANO_PMAKE="make -j ${NANO_PARALLEL_MAKE}"
91fi
92
93# Starting from soekris bios version 1.31 upwards boot0sio does not seems work
94# anymore, but boot0 does (weird)
95NANO_BOOTLOADER="boot/boot0"
96
97# Strip down to a more acceptable size
98# hints from http://people.freebsd.org/~phk/nanobsd/soekris_4x26/make.soekris_4x26.conf (46MB)
99NANO_PRUNE="$NANO_PRUNE usr/share/examples"
100NANO_PRUNE="$NANO_PRUNE usr/share/syscons"
101NANO_PRUNE="$NANO_PRUNE usr/share/calendar"
102# NB! usr/share/misc contains termcap, vi(1) etc fails to work without it.
103# NANOBSD_PRUNE += usr/share/misc
104NANO_PRUNE="$NANO_PRUNE usr/share/pcvt"
105NANO_PRUNE="$NANO_PRUNE usr/share/me"
106NANO_PRUNE="$NANO_PRUNE usr/share/doc"
107
108
109
110
111
112# Opties parsed gedurende build & install world
113# Also check man 3 src.conf for details
114# Some flags are misleading, e.g. could only be installworld (e.g.), for details:
115# http://phk.freebsd.dk/misc/build_options/
116# For details on make options also check:
117# /usr/src/share/mk/bsd.own.mk
118CONF_COMMON='
119# Specific enabled options
120#WITHOUT_ACPI=YES # geen advanced configuration power interface
121#WITHOUT_BIND=YES # geen bind tools, dns/named geinstalleerd
122#WITHOUT_CXX=YES # Set to not build g++(1) and related libraries.
123#WITHOUT_GROFF=YES # Set to not build groff(1).
124#WITHOUT_INET6=YES # geen ondersteuning inet versie 6 architectuur
125#WITHOUT_INFO=YES # geen info bestanden, readable online docs
126#WITHOUT_IPFILTER=YES # geen ip filtering geinstalleerd
127#WITHOUT_KLDLOAD=YES # do not allow loading of kernel modules
128#WITHOUT_MAILWRAPPER=YES # geen mailwrapper bij gebruik sendmail
129#WITHOUT_MAN=YES # geen handleidingen gecompileerd
130#WITHOUT_MISC=YES # geen misc sub directory
131#WITHOUT_MODULES=YES # geen ondersteuning toevoegen modules
132#WITHOUT_PAM=YES # geen ondersteuning pa modules
133#WITHOUT_PF=YES # geen packet filtering geinstalleerd
134#WITHOUT_SHARE=YES # geen share sub directory
135#WITHOUT_USB=YES # geen ondersteuning usb modules
136# Specific disabled options
137WITHOUT_ATM=YES # geen ondersteuning Asynchronous Transfer Mode
138WITHOUT_AUDIT=YES # geen event auditing / audit trails
139WITHOUT_AUTHPF=YES # geen authenticating gateway user shell
140WITHOUT_BLUETOOTH=YES # geen ondersteuning Bluetooth modules
141WITHOUT_CALENDAR=YES # geen calendar reminder service gecompileerd
142WITHOUT_CDDL=YES # Set to not build code licensed under Sun CDDL. (also ZFS)
143WITHOUT_CPP=YES # Set to not build cpp(1).
144WITHOUT_CVS=YES # geen cvs tools geinstalleerd
145WITHOUT_DICT=YES # geen dictionary ondersteuning
146WITHOUT_EXAMPLES=YES # geen voorbeeld configuratiebestanden
147WITHOUT_FORTRAN=YES # geen ondersteuning fortran compilers
148WITHOUT_GAMES=YES # geen games gecompileerd
149WITHOUT_GCOV=YES # geen gcov test coverage program
150WITHOUT_GDB=YES # geen gnu debugger gecompileerd
151WITHOUT_GPIB=YES # geen ondersteuning gpib kaarten
152WITHOUT_HTML=YES # geen html help bestanden gecompileerd
153WITHOUT_I4B=YES # geen ondersteuning voor isdn
154WITHOUT_IPX=YES # geen ondersteuning ipx protocols
155WITHOUT_KERBEROS=YES # geen ondersteuning Kerberos authenticatie
156WITHOUT_LOCALES=YES # geen ondersteuning lokalisatie
157WITHOUT_LPR=YES # geen ondersteuning print services
158WITHOUT_NIS=YES # geen ondersteuning network information system
159WITHOUT_PROFILE=YES # Set to avoid compiling profiled libraries.
160WITHOUT_RCMDS=YES # geen ondersteuning rcmds,
161WITHOUT_RESCUE=YES # geen rescue bestanden gecompileerd
162WITHOUT_SENDMAIL=YES # geen sendmail geinstalleerd
163WITHOUT_SHAREDOCS=YES # geen share/docs directories
164WITHOUT_SYSCONS=YES # geen syscon devices gecompileerd
165'
166
167CONF_BUILD="
168${CONF_COMMON}
169"
170
171CONF_INSTALL="
172${CONF_COMMON}
173WITHOUT_TOOLCHAIN=YES # geen freebsd toolchain
174"
175
176
177# Flash disks arrived, sandisk 1g seems to match the geometry of the (blanc) cards
178#FlashDevice sandisk 1g # nanobsd flashdevice entry
179#FlashDevice sandisk 512mb # nanobsd flashdevice entry
180#FlashDevice transcend 2g # nanobsd flashdevice entry
181# Calculated value of PEAK hardware 1GB CF card
182# C/H/S phys 1954/16/63, logical 977/32/63
183# Mediasize is calculated as C*H*S*512
184
185# Using logical values reported by ALIX board
186# values for PCEngines blanc 1 GB cards
187# C/H/S phys 1966/16/63, logical 983/32/63
188NANO_MEDIASIZE=`expr 1008451584 / 512`
189NANO_HEADS=32
190NANO_SECTS=63
191
192
193# Version tagging
194cust_version_tag() (
195 VERSION_FILE="${NANO_WORLDDIR}/tools/wl-release.txt"
196 (
197 echo "Generated by `id -un`@`hostname -f` at `date`"
198 echo ""
199 echo "=== CONFIG specifics ==="
200 svn info ${NANO_CONF_DIR}/../ || exit 0
201 svn diff ${NANO_CONF_DIR}/../ || exit 0
202 echo "=== BEGIN CONFIG specifics ==="
203 ) > $VERSION_FILE
204)
205
206# Takes a very long time (10+) minutes to generate this file on an ALIX board,
207# not practical for quick debugging and configuration.
208cust_openvpn_dhparam() (
209 DHFILE=${NANO_WORLDDIR}/etc/easy-rsa-keys/dh1024.pem
210 mkdir -p `dirname $DHFILE`
211 openssl dhparam -out $DHFILE 1024
212)
213
214
215
216# Assuming we are running a safe envirionment where snooping could occur during or after the build
217cust_set_root_password() (
218 if [ -n "${CFG_ROOT_PASSWORD}" ]; then
219 pprint 2 "Set root password using CFG_ROOT_PASSWORD variable"
220 chroot ${NANO_WORLDDIR} sh -c "echo '${CFG_ROOT_PASSWORD}' | pw usermod -h 0 -u root"
221 else
222 pprint 2 "Root password is <blank>, no password provided at variable CFG_ROOT_PASSWORD"
223 fi
224)
225
226
227
228# EXPERIMENTAL patch like envirionment
229# Using '*-nanobsd.patch' files to only specify the bare differences between the base/default file to
230# keep us as close as possible to the base OS
231# Patches are applied to the directory they live in
232cust_apply_nanobsd_patches() (
233 for PATCHFILE in `find ${NANO_WORLDDIR} -regex '.*-nanobsd\.patch$'`; do
234 cd `dirname ${PATCHFILE}`
235 patch -t -N -p0 -i `basename ${PATCHFILE}`
236 #XX: What to with installed patch files? Delete them for the time beeing
237 rm -v ${PATCHFILE}
238 done
239
240
241
242)
243
244
245
246# Compile & install lvroute daemon vanuit source in svn
247cust_install_lvrouted() (
248 svn co http://svn.wirelessleiden.nl/svn/node-config/other/lvrouted/trunk/ /tmp/lvrouted
249 cd /tmp/lvrouted && autoconf && autoheader && ./configure && make || true
250 cp src/lvrouted.opt ${NANO_WORLDDIR}/usr/local/sbin
251)
252
253
254
255# Customize ntpd
256cust_ntpd() (
257 chroot ${NANO_WORLDDIR} sh -c "ln -fs /usr/local/etc/ntp.drift /var/db/ntp.drift"
258)
259
260
261# Enable Serial TTYs
262cust_serial_ttys() (
263 chroot ${NANO_WORLDDIR} sed -i '' -e '/ttyv[0-9]/s/on /off/' -e '/ttyu0/s/off/on/' -e '/ttyu0/s/dialup/ansi/' /etc/ttys
264)
265
266
267
268# Install files from specific relative location
269cust_install_files () (
270 cd ${NANO_CONF_DIR}/../files
271 find . -print | grep -v -e /CVS -e .svn | cpio -dumpv ${NANO_WORLDDIR}
272)
273
274
275# pkgdb should live on persistent storage only
276cust_alternate_pkg_db () (
277 mkdir -p ${NANO_WORLDDIR}/usr/local/var/db/pkg ${NANO_WORLDDIR}/usr/local/tmp
278 touch ${NANO_WORLDDIR}/usr/local/tmp/.hack-to-avoid-pruning-directory
279 # sh profile
280 ( echo 'PKG_DBDIR=/usr/local/var/db/pkg; export PKG_DBDIR'; \
281 echo 'PKG_TMPDIR=/usr/local/tmp; export PKG_TMPDIR' ) >> ${NANO_WORLDDIR}/etc/profile
282 # csh profile
283 ( echo 'setenv PKG_DBDIR /usr/local/var/db/pkg'; \
284 echo 'setenv PKG_TMPDIR /usr/local/tmp' ) >> ${NANO_WORLDDIR}/etc/csh.cshrc
285
286 rmdir ${NANO_WORLDDIR}/var/db/pkg
287 ln -s /usr/local/var/db/pkg ${NANO_WORLDDIR}/var/db/pkg
288)
289
290# Make tools available for root by default
291cust_root_bin_to_tools() {
292 ln -s /tools ${NANO_WORLDDIR}/root/bin
293}
294
295# Directly stolen from /usr/src/tools/tools/nanobsd/nanobsd.sh, and make sure
296# to source /etc/profile in chroot to get PKG_* included, for alternate installs
297cust_pkg () (
298 # If the package directory doesn't exist, we're done.
299 if [ ! -d ${NANO_PACKAGE_DIR} ]; then
300 echo "DONE 0 packages"
301 return 0
302 fi
303
304 # Make sure to enable /dev as easy_install requires it for example
305 mount -t devfs devfs ${NANO_WORLDDIR}/dev
306 trap "umount ${NANO_WORLDDIR}/dev" 0
307 trap "exit 1" 1 2 3 15
308
309 # Copy packages into chroot
310 mkdir -p ${NANO_WORLDDIR}/Pkg
311 (
312 cd ${NANO_PACKAGE_DIR}
313 find ${NANO_PACKAGE_LIST} -print |
314 cpio -Ldumpv ${NANO_WORLDDIR}/Pkg
315 )
316
317 # Count & report how many we have to install
318 todo=`ls ${NANO_WORLDDIR}/Pkg | wc -l`
319 echo "=== TODO: $todo"
320 ls ${NANO_WORLDDIR}/Pkg
321 echo "==="
322 NANO_PKG_DBDIR=${NANO_WORLDDIR}/`chroot ${NANO_WORLDDIR} sh -c '. /etc/profile; echo ${PKG_DBDIR:-/var/db/pkg}'`
323 while true
324 do
325 # Record how many we have now
326 have=`ls ${NANO_PKG_DBDIR} | wc -l`
327
328 # Attempt to install more packages
329 # ...but no more than 200 at a time due to pkg_add's internal
330 # limitations.
331 chroot ${NANO_WORLDDIR} sh -c \
332 '. /etc/profile; ls Pkg/*tbz | xargs -n 200 pkg_add -F' || true
333
334 # See what that got us
335 now=`ls ${NANO_PKG_DBDIR} | wc -l`
336 echo "=== NOW $now"
337 ls ${NANO_PKG_DBDIR}
338 echo "==="
339
340
341 if [ $now -eq $todo ] ; then
342 echo "DONE $now packages"
343 break
344 elif [ $now -eq $have ] ; then
345 echo "FAILED: Nothing happened on this pass"
346 exit 2
347 fi
348 done
349 rm -rf ${NANO_WORLDDIR}/Pkg
350
351 # Return normal trap behaviour
352 trap - 1 2 3 15
353)
354
355
356# Prune no needed directories of image
357cust_nano_prune () (
358 cd ${NANO_WORLDDIR}
359 for ENTRY in ${NANO_PRUNE}; do
360 rm -vfR ${ENTRY}
361 done
362)
363
364# We actually do need an seperate /tmp, so undo the symlinking done in
365# setup_nanobsd()
366late_cust_unset_common_var_and_tmp() (
367 cd ${NANO_WORLDDIR}
368 rm tmp
369 mkdir -m 1777 tmp
370)
371
372
373# Fill /cfg wmth custom files, based on 'create_i386_diskimage ( )'
374last_nano_fill_cfg () (
375 # Variables to be used
376 IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
377 MNT=${MAKEOBJDIRPREFIX}/_.mnt
378
379 # Mount '/cfg' slize in image
380 MD=`mdconfig -a -t vnode -f ${IMG}`
381 mount /dev/${MD}s3 ${MNT}
382
383 # Location of '/cfg' directory
384 cd ${NANO_CONF_DIR}/../cfg-files
385 find . -print | grep -v -e /CVS -e .svn | cpio -dumpv ${MNT}
386
387
388 # Leave in nice end state
389 umount ${MNT}
390 mdconfig -d -u ${MD}
391) > ${MAKEOBJDIRPREFIX}/_.fc 2>&1
392
393last_nano_disk_usage () (
394 # Variables to be used
395 IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
396 MNT=${MAKEOBJDIRPREFIX}/_.mnt
397
398 # Mount root slize
399 MD=`mdconfig -a -t vnode -f ${IMG}`
400 mount /dev/${MD}s1a ${MNT}
401
402 # Show disk usage (percent free) inc header
403 pprint 2 $(df -h | head -1)
404 pprint 2 "$(df -h | grep /dev/${MD})"
405
406 # Leave in nice end state
407 umount ${MNT}
408 mdconfig -d -u ${MD}
409)
410
411last_orders () (
412 last_nano_fill_cfg
413 last_nano_disk_usage
414)
415
416# Ugly hack to 'escaping' pprint from inside a customize_cmd to output
417# instead of a file
418exec 3>/dev/stdout
419# Progress Print
420# Print $2 at level $1
421pprint() {
422 if [ "$1" -le $PPLEVEL ]; then
423 printf "%.${1}s %s\n" "#####" "$2" 1>&3
424 fi
425}
426
427# Cust macro`s gestart in onderstaande volgorde
428# XXX: Determine size before installing all find of additions to see how much
429# base we are actually using ## du -h -d 0
430customize_cmd cust_alternate_pkg_db
431customize_cmd cust_pkg
432customize_cmd cust_install_files
433customize_cmd cust_ntpd
434customize_cmd cust_serial_ttys
435customize_cmd cust_version_tag
436customize_cmd cust_root_bin_to_tools
437customize_cmd cust_allow_ssh_root
438customize_cmd cust_openvpn_dhparam
439customize_cmd cust_nano_prune
440customize_cmd cust_set_root_password
441customize_cmd cust_apply_nanobsd_patches
442late_customize_cmd late_cust_unset_common_var_and_tmp
443
444# Standard overwrite
445if [ -r "$NANO_CONF_DIR/nanobsd.local" ]; then
446 . $NANO_CONF_DIR/nanobsd.local
447fi
448
449# Extra config if existing is not suffient
450if [ -n "$EXTRA_NANOBSD_CONFIG" ]; then
451 for FILE in $EXTRA_NANOBSD_CONFIG; do
452 # File relative to config directory
453 if [ "`echo $FILE | cut -c1`" != "/" ]; then
454 FILE=$NANO_CONF_DIR/$FILE
455 fi
456 pprint 1 "Loading $FILE"
457 . $FILE || exit 1
458 done
459fi
Note: See TracBrowser for help on using the repository browser.