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

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

mtr is vrij handig om bij de hand te hebben.

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