source: hybrid/branches/releng-10/nanobsd/cfg/nanobsd.wleiden@ 12883

Last change on this file since 12883 was 12883, checked in by rick, 10 years ago

Note to myself: Stop trying to re-invent the wheel and start reading the scripts. Somebody probaly hit the same issue before :-)

File size: 11.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
29NANO_PACKAGE_LIST="*"
30
31
32# Wireless Leiden ports from $WL_PORTSDIR are copied OVER $PORTSDIR
33PORTSDIR='/usr/ports'
34WL_PORTSDIR="$NANO_CONF_DIR/../ports/"
35
36# Dirty quirk to allow comments in part below
37PACKAGE_LIST=`cat <<EOF | sed -e 's/#.*$//g' | xargs
38benchmarks/iperf
39devel/py-Jinja2
40devel/py-yaml
41dns/dnsmasq
42editors/vim-lite
43ftp/curl
44lang/python2
45lang/python
46net-mgmt/iftop
47net-mgmt/net-snmp
48net-mgmt/nrpe
49net/mtr
50net/isc-dhcp42-server
51net/pen
52net/sixxs-aiccu
53security/nmap
54security/openvpn
55security/sudo
56shells/bash-static
57sysutils/screen
58sysutils/pftop
59sysutils/ucspi-tcp
60www/thttpd
61www/tinyproxy
62
63# Extra WL ports
64net/lvrouted
65`
66# Package target
67PKG_MAKE_ARGS="PACKAGES=$(dirname $NANO_PACKAGE_DIR) BATCH=yes PACKAGE_BUILDING=yes"
68
69PKG_MAKE_CONF="
70# www/py-cherrypy - include apache templating
71# net-mgmt/net-snmp - no perl please (size)
72# net-mgmt/nagios-plugins - no threading (single CPU)
73# shells/bash-static - logging via syslog
74# net/mtr - no X11 (no screen)
75OPTIONS_SET= APACHE FPING SYSLOG
76OPTIONS_UNSET= PERL PERL_EMBEDDED X11
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
231#cust_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[0-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# Make tools available for root by default
275cust_root_bin_to_tools() {
276 ln -s /tools ${NANO_WORLDDIR}/root/bin
277}
278
279
280# Prune no needed directories of image
281cust_nano_prune () (
282 cd ${NANO_WORLDDIR}
283 for ENTRY in ${NANO_PRUNE}; do
284 rm -vfR ${ENTRY}
285 done
286)
287
288# We actually do need an seperate /tmp, so undo the symlinking done in
289# setup_nanobsd()
290late_cust_unset_common_var_and_tmp() (
291 cd ${NANO_WORLDDIR}
292 rm tmp
293 mkdir -m 1777 tmp
294)
295
296
297# Fill /cfg wmth custom files, based on 'create_i386_diskimage ( )'
298last_nano_fill_cfg () (
299 # Variables to be used
300 IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
301 MNT=${MAKEOBJDIRPREFIX}/_.mnt
302
303 # Mount '/cfg' slize in image
304 MD=`mdconfig -a -t vnode -f ${IMG}`
305 mount /dev/${MD}s3 ${MNT}
306
307 # Location of '/cfg' directory
308 cd ${NANO_CONF_DIR}/../cfg-files
309 find . -print | grep -v -e /CVS -e .svn | cpio -dumpv ${MNT}
310
311
312 # Leave in nice end state
313 umount ${MNT}
314 mdconfig -d -u ${MD}
315) > ${MAKEOBJDIRPREFIX}/_.fc 2>&1
316
317last_nano_disk_usage () (
318 # Variables to be used
319 IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
320 MNT=${MAKEOBJDIRPREFIX}/_.mnt
321
322 # Mount root slize
323 MD=`mdconfig -a -t vnode -f ${IMG}`
324 mount /dev/${MD}s1a ${MNT}
325
326 # Show disk usage (percent free) inc header
327 pprint 2 $(df -h | head -1)
328 pprint 2 "$(df -h | grep /dev/${MD})"
329
330 # Leave in nice end state
331 umount ${MNT}
332 mdconfig -d -u ${MD}
333)
334
335last_orders () (
336 last_nano_fill_cfg
337 last_nano_disk_usage
338)
339
340# Ugly hack to 'escaping' pprint from inside a customize_cmd to output
341# instead of a file
342exec 3>/dev/stdout
343# Progress Print
344# Print $2 at level $1
345pprint() {
346 if [ "$1" -le $PPLEVEL ]; then
347 printf "%.${1}s %s\n" "#####" "$2" 1>&3
348 fi
349}
350
351# Cust macro`s gestart in onderstaande volgorde
352# XXX: Determine size before installing all find of additions to see how much
353# base we are actually using ## du -h -d 0
354customize_cmd cust_pkgng
355customize_cmd cust_install_files
356customize_cmd cust_ntpd
357customize_cmd cust_serial_ttys
358customize_cmd cust_version_tag
359customize_cmd cust_root_bin_to_tools
360customize_cmd cust_allow_ssh_root
361customize_cmd cust_openvpn_dhparam
362customize_cmd cust_nano_prune
363customize_cmd cust_set_root_password
364#customize_cmd cust_apply_nanobsd_patches
365late_customize_cmd late_cust_unset_common_var_and_tmp
366
367# Standard overwrite
368if [ -r "$NANO_CONF_DIR/nanobsd.local" ]; then
369 . $NANO_CONF_DIR/nanobsd.local
370fi
371
372# Extra config if existing is not suffient
373if [ -n "$EXTRA_NANOBSD_CONFIG" ]; then
374 for FILE in $EXTRA_NANOBSD_CONFIG; do
375 # File relative to config directory
376 if [ "`echo $FILE | cut -c1`" != "/" ]; then
377 FILE=$NANO_CONF_DIR/$FILE
378 fi
379 pprint 1 "Loading $FILE"
380 . $FILE || exit 1
381 done
382fi
Note: See TracBrowser for help on using the repository browser.