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

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

Install missing nrpe2 packages.

Fixes: nodefactory#147

File size: 13.5 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
298 # If the package directory doesn't exist, we're done.
299 if [ ! -d ${NANO_PACKAGE_DIR} ]; then
300 echo "DONE 0 packages"
301 return 0
302 fi
303
304 # Copy packages into chroot
305 mkdir -p ${NANO_WORLDDIR}/Pkg
306 (
307 cd ${NANO_PACKAGE_DIR}
308 find ${NANO_PACKAGE_LIST} -print |
309 cpio -Ldumpv ${NANO_WORLDDIR}/Pkg
310 )
311
312 # Count & report how many we have to install
313 todo=`ls ${NANO_WORLDDIR}/Pkg | wc -l`
314 echo "=== TODO: $todo"
315 ls ${NANO_WORLDDIR}/Pkg
316 echo "==="
317 NANO_PKG_DBDIR=${NANO_WORLDDIR}/`chroot ${NANO_WORLDDIR} sh -c '. /etc/profile; echo ${PKG_DBDIR:-/var/db/pkg}'`
318 while true
319 do
320 # Record how many we have now
321 have=`ls ${NANO_PKG_DBDIR} | wc -l`
322
323 # Attempt to install more packages
324 # ...but no more than 200 at a time due to pkg_add's internal
325 # limitations.
326 chroot ${NANO_WORLDDIR} sh -c \
327 '. /etc/profile; ls Pkg/*tbz | xargs -n 200 pkg_add -F' || true
328
329 # See what that got us
330 now=`ls ${NANO_PKG_DBDIR} | wc -l`
331 echo "=== NOW $now"
332 ls ${NANO_PKG_DBDIR}
333 echo "==="
334
335
336 if [ $now -eq $todo ] ; then
337 echo "DONE $now packages"
338 break
339 elif [ $now -eq $have ] ; then
340 echo "FAILED: Nothing happened on this pass"
341 exit 2
342 fi
343 done
344 rm -rf ${NANO_WORLDDIR}/Pkg
345)
346
347
348# Prune no needed directories of image
349cust_nano_prune () (
350 cd ${NANO_WORLDDIR}
351 for ENTRY in ${NANO_PRUNE}; do
352 rm -vfR ${ENTRY}
353 done
354)
355
356
357# Fill /cfg with custom files, based on 'create_i386_diskimage ( )'
358last_nano_fill_cfg () (
359 # Variables to be used
360 IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
361 MNT=${MAKEOBJDIRPREFIX}/_.mnt
362
363 # Mount '/cfg' slize in image
364 MD=`mdconfig -a -t vnode -f ${IMG}`
365 mount /dev/${MD}s3 ${MNT}
366
367 # Location of '/cfg' directory
368 cd ${NANO_CONF_DIR}/../cfg-files
369 find . -print | grep -v -e /CVS -e .svn | cpio -dumpv ${MNT}
370
371
372 # Leave in nice end state
373 umount ${MNT}
374 mdconfig -d -u ${MD}
375) > ${MAKEOBJDIRPREFIX}/_.fc 2>&1
376
377last_nano_disk_usage () (
378 # Variables to be used
379 IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
380 MNT=${MAKEOBJDIRPREFIX}/_.mnt
381
382 # Mount root slize
383 MD=`mdconfig -a -t vnode -f ${IMG}`
384 mount /dev/${MD}s1a ${MNT}
385
386 # Show disk usage (percent free) inc header
387 pprint 2 $(df -h | head -1)
388 pprint 2 "$(df -h | grep /dev/${MD})"
389
390 # Leave in nice end state
391 umount ${MNT}
392 mdconfig -d -u ${MD}
393)
394
395last_orders () (
396 last_nano_fill_cfg
397 last_nano_disk_usage
398)
399
400# Ugly hack to 'escaping' pprint from inside a customize_cmd to output
401# instead of a file
402exec 3>/dev/stdout
403# Progress Print
404# Print $2 at level $1
405pprint() {
406 if [ "$1" -le $PPLEVEL ]; then
407 printf "%.${1}s %s\n" "#####" "$2" 1>&3
408 fi
409}
410
411# Cust macro`s gestart in onderstaande volgorde
412# XXX: Determine size before installing all find of additions to see how much
413# base we are actually using ## du -h -d 0
414customize_cmd cust_alternate_pkg_db
415customize_cmd cust_pkg
416customize_cmd cust_install_files
417customize_cmd cust_ntpd
418customize_cmd cust_serial_ttys
419customize_cmd cust_version_tag
420customize_cmd cust_root_bin_to_tools
421customize_cmd cust_allow_ssh_root
422customize_cmd cust_openvpn_dhparam
423customize_cmd cust_nano_prune
424customize_cmd cust_set_root_password
425customize_cmd cust_apply_nanobsd_patches
426
427# Standard overwrite
428if [ -r "$NANO_CONF_DIR/nanobsd.local" ]; then
429 . $NANO_CONF_DIR/nanobsd.local
430fi
431
432# Extra config if existing is not suffient
433if [ -n "$EXTRA_NANOBSD_CONFIG" ]; then
434 for FILE in $EXTRA_NANOBSD_CONFIG; do
435 # File relative to config directory
436 if [ "`echo $FILE | cut -c1`" != "/" ]; then
437 FILE=$NANO_CONF_DIR/$FILE
438 fi
439 pprint 1 "Loading $FILE"
440 . $FILE || exit 1
441 done
442fi
Note: See TracBrowser for help on using the repository browser.