source: hybrid/branches/releng-11/nanobsd/cfg/nanobsd.wleiden@ 13917

Last change on this file since 13917 was 13917, checked in by rick, 8 years ago

Nuke some python test stuff in favour in good old dig.

File size: 15.1 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_TOOLS=$(pwd)
16NANO_KERNEL=$NANO_CONF_DIR/kernel.wleiden # naam van het kernel configuratiebestand
17NANO_IMAGES=2 # aantal nanobsd code slices/installs (1/2)
18
19NANO_CONFSIZE=20480 # Volume van de config slice (10MB) in 512bs
20NANO_DATASIZE=0 # volume van de data slice, 0 = not configured
21NANO_CODESIZE=819200 # Let buildscript the operating system slice as large as posible
22
23# Size of the /etc ramdisk in 512 bytes sectors
24NANO_RAM_ETCSIZE=20480
25
26NANO_RAM_TMPVARSIZE=102400 # Volume of combined var & tmp slice (50MB) in 512bs
27
28NANO_LABEL=WLIMG
29NANO_NEWFS="-b 4096 -f 512 -i 8192" # Overwrite the default stettings to disable Soft-updates
30
31
32#XXX: Eeks, fixed packages, needs building a hook to allow building the package
33# of the shelfs if needed, copy to right directory, done. With only input needed
34# a list of ports in the format like net/net-snmp
35NANO_PACKAGE_DIR=$NANO_CONF_DIR/../pkg/All
36NANO_PACKAGE_LIST="*"
37
38VERSION=$(uname -r | sed -e 's/-.*//g' -e 's/\./_/')
39NANO_PACKAGE_REPOS="/usr/local/poudriere/data/packages/wlpkgbuild${VERSION}-default-node/"
40
41
42# Wireless Leiden ports from $WL_PORTSDIR are copied OVER $PORTSDIR
43PORTSDIR='/usr/ports'
44WL_PORTSDIR="$NANO_CONF_DIR/../ports/"
45
46# Dirty quirk to allow comments in part below
47PACKAGE_LIST=`cat <<EOF | sed -e 's/#.*$//g' | xargs
48benchmarks/iperf
49devel/py-Jinja2
50devel/py-yaml
51editors/vim-lite
52dns/dnsmasq
53dns/nsd
54dns/unbound
55ftp/curl
56lang/python2
57lang/python
58net/ladvd
59net-mgmt/iftop
60net-mgmt/net-snmp
61net/mtr
62net/isc-dhcp43-server
63net/pen
64net/py-speedtest-cli
65ports-mgmt/pkg
66security/sudo
67security/ca_root_nss
68shells/bash-static
69sysutils/daemontools
70sysutils/monit
71sysutils/screen
72sysutils/ucspi-tcp
73sysutils/wait_on
74www/apache24
75www/tinyproxy
76
77# Extra WL ports
78net/lvrouted
79`
80# Package target
81PKG_MAKE_ARGS="PACKAGES=$(dirname $NANO_PACKAGE_DIR) BATCH=yes PACKAGE_BUILDING=yes"
82
83PKG_MAKE_CONF="
84# www/py-cherrypy - include apache templating
85# net-mgmt/net-snmp - no perl please (size)
86# net-mgmt/nagios-plugins - no threading (single CPU)
87# shells/bash-static - logging via syslog
88# net/mtr - no X11 (no screen)
89# lang/ocaml - no TK support (requires X11)
90# devel/ocaml-findlib - no TOOLBOX support (requires ocaml with TK support)
91OPTIONS_SET= APACHE FPING SYSLOG
92OPTIONS_UNSET= PERL PERL_EMBEDDED X11 TK TOOLBOX
93"
94
95##NANO_PACKAGE_LIST=
96
97# Warning: set to 1 to debug make build errors
98# Number of recurrent parrallel make builds
99if `grep -q 'acpi0: <PRLS PRLS_OEM> on motherboard' /var/run/dmesg.boot`; then
100 # Mac OS X Parallels virtual machine
101 NANO_PMAKE="make -B"
102else
103 # Default 2 times number of CPU's inside machine
104 NANO_PARALLEL_MAKE=`expr $(sysctl -n hw.ncpu) \* 2`
105 NANO_PMAKE="make -j ${NANO_PARALLEL_MAKE}"
106fi
107
108# Starting from soekris bios version 1.31 upwards boot0sio does not seems work
109# anymore, but boot0 does (weird)
110NANO_BOOTLOADER="boot/boot0"
111
112# Strip down to a more acceptable size
113# hints from http://people.freebsd.org/~phk/nanobsd/soekris_4x26/make.soekris_4x26.conf (46MB)
114NANO_PRUNE="$NANO_PRUNE usr/share/examples"
115NANO_PRUNE="$NANO_PRUNE usr/share/syscons"
116NANO_PRUNE="$NANO_PRUNE usr/share/calendar"
117# NB! usr/share/misc contains termcap, vi(1) etc fails to work without it.
118# NANOBSD_PRUNE += usr/share/misc
119NANO_PRUNE="$NANO_PRUNE usr/share/pcvt"
120NANO_PRUNE="$NANO_PRUNE usr/share/me"
121NANO_PRUNE="$NANO_PRUNE usr/share/doc"
122# Debugging removal
123NANO_PRUNE="$NANO_PRUNE usr/lib/debug"
124NANO_PRUNE="$NANO_PRUNE usr/tests"
125# Installed ports strip down
126NANO_PRUNE="$NANO_PRUNE usr/local/share/doc"
127NANO_PRUNE="$NANO_PRUNE usr/local/share/examples"
128# Directories not removable by installer
129NANO_PRUNE="$NANO_PRUNE usr/local/lib/python2.7/test"
130
131
132
133
134
135# Opties parsed gedurende build & install world
136# Also check man 5 src.conf for details
137# Some flags are misleading, e.g. could only be installworld (e.g.), for details:
138# http://phk.freebsd.dk/misc/build_options/
139# For details on make options also check:
140# /usr/src/share/mk/bsd.own.mk
141CONF_COMMON='
142# Specific enabled options
143#WITHOUT_ACPI=YES # geen advanced configuration power interface
144#WITHOUT_BIND=YES # geen bind tools, dns/named geinstalleerd
145#WITHOUT_CXX=YES # Set to not build g++(1) and related libraries.
146#WITHOUT_GROFF=YES # Set to not build groff(1).
147#WITHOUT_INET6=YES # geen ondersteuning inet versie 6 architectuur
148#WITHOUT_INFO=YES # geen info bestanden, readable online docs
149#WITHOUT_IPFILTER=YES # geen ip filtering geinstalleerd
150#WITHOUT_KLDLOAD=YES # do not allow loading of kernel modules
151#WITHOUT_MAILWRAPPER=YES # geen mailwrapper bij gebruik sendmail
152#WITHOUT_MAN=YES # geen handleidingen gecompileerd
153#WITHOUT_MISC=YES # geen misc sub directory
154#WITHOUT_MODULES=YES # geen ondersteuning toevoegen modules
155#WITHOUT_PAM=YES # geen ondersteuning pa modules
156#WITHOUT_PF=YES # geen packet filtering geinstalleerd
157#WITHOUT_SHARE=YES # geen share sub directory
158#WITHOUT_USB=YES # geen ondersteuning usb modules
159# Specific disabled options
160WITHOUT_ATM=YES # geen ondersteuning Asynchronous Transfer Mode
161WITHOUT_AUDIT=YES # geen event auditing / audit trails
162WITHOUT_AUTHPF=YES # geen authenticating gateway user shell
163WITHOUT_BLUETOOTH=YES # geen ondersteuning Bluetooth modules
164WITHOUT_CALENDAR=YES # geen calendar reminder service gecompileerd
165WITHOUT_CDDL=YES # Set to not build code licensed under Sun CDDL. (also ZFS)
166WITHOUT_CPP=YES # Set to not build cpp(1).
167WITHOUT_CXX=YES # Set to not build c++(1) and related libraries.
168WITHOUT_CLANG=YES # Set to not build the Clang C/C++ compiler.
169WITHOUT_CVS=YES # geen cvs tools geinstalleerd
170WITHOUT_DICT=YES # geen dictionary ondersteuning
171WITHOUT_EXAMPLES=YES # geen voorbeeld configuratiebestanden
172WITHOUT_FORTRAN=YES # geen ondersteuning fortran compilers
173WITHOUT_GAMES=YES # geen games gecompileerd
174WITHOUT_GCOV=YES # geen gcov test coverage program
175WITHOUT_GDB=YES # geen gnu debugger gecompileerd
176WITHOUT_GPIB=YES # geen ondersteuning gpib kaarten
177WITHOUT_HTML=YES # geen html help bestanden gecompileerd
178WITHOUT_I4B=YES # geen ondersteuning voor isdn
179WITHOUT_ICONV=YES # No iconv support (no need to support native files)
180WITHOUT_IPX=YES # geen ondersteuning ipx protocols
181WITHOUT_KERBEROS=YES # geen ondersteuning Kerberos authenticatie
182WITHOUT_LOCALES=YES # geen ondersteuning lokalisatie
183WITHOUT_LPR=YES # geen ondersteuning print services
184WITHOUT_NIS=YES # geen ondersteuning network information system
185WITHOUT_PROFILE=YES # Set to avoid compiling profiled libraries.
186WITHOUT_RCMDS=YES # geen ondersteuning rcmds,
187WITHOUT_RESCUE=YES # geen rescue bestanden gecompileerd
188WITHOUT_SENDMAIL=YES # geen sendmail geinstalleerd
189WITHOUT_SHAREDOCS=YES # geen share/docs directories
190WITHOUT_SSP=YES # Set to not build world with propolice stack smashing protection.
191WITHOUT_SYSCONS=YES # geen syscon devices gecompileerd
192WITHOUT_UNBOUND=YES # Port version will be used if any is used
193WITHOUT_LOCALES=YES # No localization support
194'
195
196CONF_BUILD="
197${CONF_COMMON}
198"
199
200CONF_INSTALL="
201${CONF_COMMON}
202WITHOUT_TOOLCHAIN=YES # geen freebsd toolchain
203"
204
205
206# Flash disks arrived, sandisk 1g seems to match the geometry of the (blanc) cards
207#FlashDevice sandisk 1g # nanobsd flashdevice entry
208#FlashDevice sandisk 512mb # nanobsd flashdevice entry
209#FlashDevice transcend 2g # nanobsd flashdevice entry
210# Calculated value of PEAK hardware 1GB CF card
211# C/H/S phys 1954/16/63, logical 977/32/63
212# Mediasize is calculated as C*H*S*512
213
214# Using logical values reported by ALIX board
215# values for PCEngines blanc 1 GB cards
216# C/H/S phys 1966/16/63, logical 983/32/63
217NANO_MEDIASIZE=`expr 1008451584 / 512`
218NANO_HEADS=32
219NANO_SECTS=63
220
221
222# Version tagging
223cust_version_tag() (
224 VERSION_FILE="${NANO_WORLDDIR}/tools/wl-release.txt"
225 (
226 echo "Generated by `id -un`@`hostname -f` at `date`"
227 echo ""
228 echo "=== CONFIG specifics ==="
229 svn info ${NANO_CONF_DIR}/../ || exit 0
230 svn diff ${NANO_CONF_DIR}/../ || exit 0
231 echo "=== BEGIN CONFIG specifics ==="
232 ) > $VERSION_FILE
233)
234
235# Takes a very long time (10+) minutes to generate this file on an ALIX board,
236# not practical for quick debugging and configuration.
237cust_openvpn_dhparam() (
238 if [ -r ${NANO_CONF_DIR}/usr/local/bin/openvpn ]; then
239 DHFILE=${NANO_WORLDDIR}/etc/easy-rsa-keys/dh1024.pem
240 mkdir -p `dirname $DHFILE`
241 openssl dhparam -out $DHFILE 1024
242 fi
243)
244
245# Unbound is running in alternative chroot location (port default) how-ever
246# this directory needs to be writeable by unbound for key generation etc.
247cust_unbound_rights() (
248 if [ -r ${NANO_WORLDDIR}/usr/local/etc/unbound ]; then
249 chroot ${NANO_WORLDDIR} sh -c "chown unbound:unbound /usr/local/etc/unbound"
250 fi
251)
252
253
254# Assuming we are running a safe envirionment where snooping could occur during or after the build
255cust_set_root_password() (
256 if [ -n "${CFG_ROOT_PASSWORD}" ]; then
257 pprint 2 "Set root password using CFG_ROOT_PASSWORD variable"
258 chroot ${NANO_WORLDDIR} sh -c "echo '${CFG_ROOT_PASSWORD}' | pw usermod -h 0 -n root"
259 else
260 pprint 2 "Root password is <blank>, no password provided at variable CFG_ROOT_PASSWORD"
261 fi
262)
263
264
265
266# EXPERIMENTAL patch like envirionment
267# Using '*-nanobsd.patch' files to only specify the bare differences between the base/default file to
268# keep us as close as possible to the base OS
269# Patches are applied to the directory they live in
270#cust_apply_nanobsd_patches() (
271# for PATCHFILE in `find ${NANO_WORLDDIR} -regex '.*-nanobsd\.patch$'`; do
272# cd `dirname ${PATCHFILE}`
273# patch -t -N -p0 -i `basename ${PATCHFILE}`
274# #XX: What to with installed patch files? Delete them for the time beeing
275# rm -v ${PATCHFILE}
276#done
277
278
279
280#)
281
282
283
284# Customize ntpd
285cust_ntpd() (
286 chroot ${NANO_WORLDDIR} sh -c "ln -fs /usr/local/etc/ntp.drift /var/db/ntp.drift"
287)
288
289
290# Enable Serial TTYs
291cust_serial_ttys() (
292 chroot ${NANO_WORLDDIR} sed -i '' -e '/ttyv[0-9]/s/on /off/' -e '/ttyu0/s/off/on/' -e '/ttyu0/s/dialup/ansi/' /etc/ttys
293
294 # Serial login is consided to be phycically secured, so no credentials are required
295 chroot ${NANO_WORLDDIR} sed -i '' -e '/ttyu0/s/std.9600/al.9600/' /etc/ttys
296)
297
298# Customize sudoers files
299cust_sudo_rules() {
300 chroot ${NANO_WORLDDIR} find /usr/local/etc/sudoers.d/ -type f -exec chmod 0640 {} \+
301}
302
303
304# Update databases of tooling like locate and apropos
305cust_update_databases() {
306 chroot ${NANO_WORLDDIR} sh -c '/usr/libexec/makewhatis.local `/usr/bin/manpath -q`'
307 chroot ${NANO_WORLDDIR} "/usr/libexec/locate.updatedb"
308}
309
310# Install files from specific relative location
311cust_install_files () (
312 cd ${NANO_CONF_DIR}/../files
313 find . -print | grep -v -e /CVS -e .svn | cpio -dumpv ${NANO_WORLDDIR}
314)
315
316
317# Make tools available for root by default
318cust_root_bin_to_tools() {
319 ln -s /tools ${NANO_WORLDDIR}/root/bin
320}
321
322
323# Prune no needed directories of image
324cust_nano_prune () (
325 cd ${NANO_WORLDDIR}
326 for ENTRY in ${NANO_PRUNE}; do
327 rm -vfR ${ENTRY}
328 done
329)
330
331# We actually do need an seperate /tmp, so undo the symlinking done in
332# setup_nanobsd()
333late_cust_unset_common_var_and_tmp() (
334 cd ${NANO_WORLDDIR}
335 rm tmp
336 mkdir -m 1777 tmp
337)
338
339
340# Fill /cfg wmth custom files, based on 'create_i386_diskimage ( )'
341last_nano_fill_cfg () (
342 # Variables to be used
343 IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
344 MNT=${MAKEOBJDIRPREFIX}/_.mnt
345
346 # Mount '/cfg' slize in image
347 MD=`mdconfig -a -t vnode -f ${IMG}`
348 mount /dev/${MD}s3 ${MNT}
349
350 # Location of '/cfg' directory
351 cd ${NANO_CONF_DIR}/../cfg-files
352 find . -print | grep -v -e /CVS -e .svn | cpio -dumpv ${MNT}
353
354
355 # Leave in nice end state
356 umount ${MNT}
357 mdconfig -d -u ${MD}
358) > ${MAKEOBJDIRPREFIX}/_.fc 2>&1
359
360last_nano_disk_usage () (
361 # Variables to be used
362 IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
363 MNT=${MAKEOBJDIRPREFIX}/_.mnt
364
365 # Mount root slize
366 MD=`mdconfig -a -t vnode -f ${IMG}`
367 mount /dev/${MD}s1a ${MNT}
368
369 # Show disk usage (percent free) inc header
370 pprint 2 $(df -h | head -1)
371 pprint 2 "$(df -h | grep /dev/${MD})"
372
373 # Leave in nice end state
374 umount ${MNT}
375 mdconfig -d -u ${MD}
376)
377
378
379cust_pkgng () (
380
381 # If the package directory doesn't exist, we're done.
382 if [ ! -d ${NANO_PACKAGE_REPOS} ]; then
383 echo "DONE 0 packages"
384 return 0
385 fi
386
387 # Find a pkg-* package
388 if [ -z "${NANO_PACKAGE_REPOS}/Latest/pkg.txz" ]; then
389 echo "FAILED: need a pkg/ package for bootstrapping"
390 exit 2
391 fi
392
393 # Replicate the packages into the NanoBSD world (as hard links) so we can
394 # access them from the chroot in which pkg is being run.
395 cp -lpR ${NANO_PACKAGE_REPOS} ${NANO_WORLDDIR}/Repos
396
397 #Bootstrap pkg
398 CR env ASSUME_ALWAYS_YES=YES SIGNATURE_TYPE=none /usr/sbin/pkg add /Repos/Latest/pkg.txz
399 CR pkg -N >/dev/null 2>&1
400 if [ "$?" -ne "0" ]; then
401 echo "FAILED: pkg bootstrapping faied"
402 exit 2
403 fi
404
405 mkdir -p ${NANO_WORLDDIR}/usr/local/etc/pkg/repos
406 echo "FreeBSD: { enabled: no }" > ${NANO_WORLDDIR}/usr/local/etc/pkg/repos/FreeBSD.conf
407
408 # Generate a reference to our local repository
409 cat > ${NANO_WORLDDIR}/usr/local/etc/pkg/repos/LOCAL.conf <<-EOF
410 LOCAL: {
411 url : file:///Repos
412 enabled : yes
413 mirror_type : none
414 signature_type : none
415 }
416 EOF
417
418
419 # Count & report how many we have to install
420 todo=`echo ${PACKAGE_LIST} | /usr/bin/wc -l`
421 todo=$(expr $todo + 1) # add one for pkg since it is installed already
422 echo "=== TODO: $todo"
423 echo "${PACKAGE_LIST}"
424 echo "==="
425 for PKG in ${PACKAGE_LIST}
426 do
427 CR env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg install $PKG
428 done
429 rm -rf ${NANO_WORLDDIR}/Repos
430)
431
432last_orders () (
433 last_nano_fill_cfg
434 last_nano_disk_usage
435)
436
437# Ugly hack to 'escaping' pprint from inside a customize_cmd to output
438# instead of a file
439exec 3>/dev/stdout
440# Progress Print
441# Print $2 at level $1
442pprint() {
443 if [ "$1" -le $PPLEVEL ]; then
444 printf "%.${1}s %s\n" "#####" "$2" 1>&3
445 fi
446}
447
448# Cust macro`s gestart in onderstaande volgorde
449# XXX: Determine size before installing all find of additions to see how much
450# base we are actually using ## du -h -d 0
451customize_cmd cust_pkgng
452customize_cmd cust_install_files
453customize_cmd cust_ntpd
454customize_cmd cust_serial_ttys
455customize_cmd cust_version_tag
456customize_cmd cust_root_bin_to_tools
457customize_cmd cust_allow_ssh_root
458customize_cmd cust_openvpn_dhparam
459customize_cmd cust_nano_prune
460customize_cmd cust_set_root_password
461customize_cmd cust_sudo_rules
462customize_cmd cust_unbound_rights
463customize_cmd cust_update_databases
464#customize_cmd cust_apply_nanobsd_patches
465late_customize_cmd late_cust_unset_common_var_and_tmp
466
467# Standard overwrite
468if [ -r "$NANO_CONF_DIR/nanobsd.local" ]; then
469 . $NANO_CONF_DIR/nanobsd.local
470fi
471
472# Extra config if existing is not suffient
473if [ -n "$EXTRA_NANOBSD_CONFIG" ]; then
474 for FILE in $EXTRA_NANOBSD_CONFIG; do
475 # File relative to config directory
476 if [ "`echo $FILE | cut -c1`" != "/" ]; then
477 FILE=$NANO_CONF_DIR/$FILE
478 fi
479 pprint 1 "Loading $FILE"
480 . $FILE || exit 1
481 done
482fi
Note: See TracBrowser for help on using the repository browser.