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

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

Nice hack to publish the /var/db/pkg into /usr/local/var/db/pkg. Allowing it to store on permanent location.

Related-To: nodefactory#109

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