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

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

Use dev during package install, for jinja2 (easy_install) needs it.

fixes nodefactory:ticket:144

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