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

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