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

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

Handig pakket om bandbreedte gebruik van sessies te monitoring.

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