close Warning: Can't use blame annotator:
No changeset 7608 in the repository

source: hybrid/branches/releng-9/nanobsd/cfg/nanobsd.wleiden@ 12714

Last change on this file since 12714 was 12714, checked in by rick, 11 years ago

Proper default for python and making sure no X11 and TK stuff gets included when building ocaml (required by lvrouted), since it will make the flash past the 512MB boundry.

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