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

Last change on this file since 13922 was 13922, checked in by rick, 7 years ago

Python sneaked back in by devel/gdb options

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