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

Last change on this file was 14328, checked in by rick, 6 years ago

Fix disk image is growing too large

Removing unused FreeBSD components

File size: 15.2 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# Package building done using pourdriere
33NANO_PACKAGE_REPOS="/usr/local/poudriere/data/packages/wlpkgbuild-default-node/"
34
35
36# Dirty quirk to allow comments in part below
37PACKAGE_LIST=`cat <<EOF | sed -e 's/#.*$//g' | xargs
38benchmarks/iperf
39editors/vim-console
40dns/dnsmasq
41dns/nsd
42dns/unbound
43ftp/curl
44net/ladvd
45net-mgmt/iftop
46net-mgmt/net-snmp
47net/mtr
48net/isc-dhcp44-server
49net/pen
50ports-mgmt/pkg
51security/sudo
52security/ca_root_nss
53shells/bash-static
54sysutils/daemontools
55sysutils/monit
56sysutils/screen
57sysutils/ucspi-tcp
58sysutils/wait_on
59www/apache24
60www/tinyproxy
61www/thttpd
62
63# Extra WL ports
64net/lvrouted
65`
66PKG_MAKE_CONF="
67# www/py-cherrypy - include apache templating
68# net-mgmt/net-snmp - no perl please (size)
69# net-mgmt/nagios-plugins - no threading (single CPU)
70# shells/bash-static - logging via syslog
71# net/mtr - no X11 (no screen)
72# lang/ocaml - no TK support (requires X11)
73# devel/ocaml-findlib - no TOOLBOX support (requires ocaml with TK support)
74# ftp/curl - GSSAPI support set to NONE (_BASE requires kerberos)
75OPTIONS_SET= APACHE FPING SYSLOG GSSAPI_NONE
76OPTIONS_UNSET= PERL PERL_EMBEDDED PYTHON X11 TK TOOLBOX GSSAPI_BASE
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# Debugging removal
107NANO_PRUNE="$NANO_PRUNE usr/lib/debug"
108NANO_PRUNE="$NANO_PRUNE usr/tests"
109# Installed ports strip down
110NANO_PRUNE="$NANO_PRUNE usr/local/share/doc"
111NANO_PRUNE="$NANO_PRUNE usr/local/share/examples"
112
113
114
115
116
117# Opties parsed gedurende build & install world
118# Also check man 5 src.conf for details
119# Some flags are misleading, e.g. could only be installworld (e.g.), for details:
120# http://phk.freebsd.dk/misc/build_options/
121# For details on make options also check:
122# /usr/src/share/mk/bsd.own.mk
123CONF_COMMON='
124# Specific enabled options
125#WITHOUT_ACPI=YES # geen advanced configuration power interface
126#WITHOUT_BIND=YES # geen bind tools, dns/named geinstalleerd
127#WITHOUT_CXX=YES # Set to not build g++(1) and related libraries.
128#WITHOUT_GROFF=YES # Set to not build groff(1).
129#WITHOUT_INET6=YES # geen ondersteuning inet versie 6 architectuur
130#WITHOUT_INFO=YES # geen info bestanden, readable online docs
131#WITHOUT_IPFILTER=YES # geen ip filtering geinstalleerd
132#WITHOUT_KLDLOAD=YES # do not allow loading of kernel modules
133#WITHOUT_MAILWRAPPER=YES # geen mailwrapper bij gebruik sendmail
134#WITHOUT_MAN=YES # geen handleidingen gecompileerd
135#WITHOUT_MISC=YES # geen misc sub directory
136#WITHOUT_MODULES=YES # geen ondersteuning toevoegen modules
137#WITHOUT_PAM=YES # geen ondersteuning pa modules
138#WITHOUT_PF=YES # geen packet filtering geinstalleerd
139#WITHOUT_SHARE=YES # geen share sub directory
140#WITHOUT_USB=YES # geen ondersteuning usb modules
141# Specific disabled options
142WITHOUT_ATM=YES # geen ondersteuning Asynchronous Transfer Mode
143WITHOUT_AUDIT=YES # geen event auditing / audit trails
144WITHOUT_AUTHPF=YES # geen authenticating gateway user shell
145WITHOUT_BLUETOOTH=YES # geen ondersteuning Bluetooth modules
146WITHOUT_CALENDAR=YES # geen calendar reminder service gecompileerd
147WITHOUT_CDDL=YES # Set to not build code licensed under Sun CDDL. (also ZFS)
148WITHOUT_CPP=YES # Set to not build cpp(1).
149WITHOUT_CXX=YES # Set to not build c++(1) and related libraries.
150WITHOUT_CLANG=YES # Set to not build the Clang C/C++ compiler.
151WITHOUT_CVS=YES # geen cvs tools geinstalleerd
152WITHOUT_DICT=YES # geen dictionary ondersteuning
153WITHOUT_EXAMPLES=YES # geen voorbeeld configuratiebestanden
154WITHOUT_FORTRAN=YES # geen ondersteuning fortran compilers
155WITHOUT_GAMES=YES # geen games gecompileerd
156WITHOUT_GCOV=YES # geen gcov test coverage program
157WITHOUT_GPIB=YES # geen ondersteuning gpib kaarten
158WITHOUT_HTML=YES # geen html help bestanden gecompileerd
159WITHOUT_I4B=YES # geen ondersteuning voor isdn
160WITHOUT_IPX=YES # geen ondersteuning ipx protocols
161WITHOUT_KERBEROS=YES # geen ondersteuning Kerberos authenticatie
162WITHOUT_LOCALES=YES # geen ondersteuning lokalisatie
163WITHOUT_LPR=YES # geen ondersteuning print services
164WITHOUT_NIS=YES # geen ondersteuning network information system
165WITHOUT_PROFILE=YES # Set to avoid compiling profiled libraries.
166WITHOUT_RCMDS=YES # geen ondersteuning rcmds,
167WITHOUT_RESCUE=YES # geen rescue bestanden gecompileerd
168WITHOUT_SENDMAIL=YES # geen sendmail geinstalleerd
169WITHOUT_SHAREDOCS=YES # geen share/docs directories
170WITHOUT_SSP=YES # Set to not build world with propolice stack smashing protection.
171WITHOUT_SYSCONS=YES # geen syscon devices gecompileerd
172WITHOUT_UNBOUND=YES # Port version will be used if any is used
173WITHOUT_LOCALES=YES # No localization support
174
175WITHOUT_ICONV=YES
176WITHOUT_KVM=YES
177WITHOUT_VI=YES
178WITHOUT_TESTS=YES
179WITHOUT_PC_SYSINSTALL=YES
180WITHOUT_NLS=YES
181WITHOUT_MODULE_DRM=YES
182WITHOUT_MODULE_DRM2=YES
183WITHOUT_KERNEL_SYSBOLS=YES
184WITHOUT_JAIL=YES
185WITHOUT_ISCSI=YES
186
187# LLVM Target selection to speed up compilation
188WITHOUT_LLVM_TARGET_AARCH64=YES
189WITHOUT_LLVM_TARGET_ARM=YES
190WITHOUT_LLVM_TARGET_MIPS=YES
191WITHOUT_LLVM_TARGET_POWERPC=YES
192WITHOUT_LLVM_TARGET_SPARC=YES
193WITH_LLVM_TARGET_X86=YES
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# Monit permissions needs to be more restrictive which cannot be set by
255# repository tooling
256cust_monitrc_permissions () (
257 if [ -r ${NANO_WORLDDIR}/usr/local/etc/monitrc ]; then
258 chroot ${NANO_WORLDDIR} sh -c "chmod 0600 /usr/local/etc/monitrc"
259 fi
260)
261
262
263# Assuming we are running a safe envirionment where snooping could occur during or after the build
264cust_set_root_password() (
265 if [ -n "${CFG_ROOT_PASSWORD}" ]; then
266 pprint 2 "Set root password using CFG_ROOT_PASSWORD variable"
267 chroot ${NANO_WORLDDIR} sh -c "echo '${CFG_ROOT_PASSWORD}' | pw usermod -h 0 -n root"
268 else
269 pprint 2 "Root password is <blank>, no password provided at variable CFG_ROOT_PASSWORD"
270 fi
271)
272
273
274
275# EXPERIMENTAL patch like envirionment
276# Using '*-nanobsd.patch' files to only specify the bare differences between the base/default file to
277# keep us as close as possible to the base OS
278# Patches are applied to the directory they live in
279#cust_apply_nanobsd_patches() (
280# for PATCHFILE in `find ${NANO_WORLDDIR} -regex '.*-nanobsd\.patch$'`; do
281# cd `dirname ${PATCHFILE}`
282# patch -t -N -p0 -i `basename ${PATCHFILE}`
283# #XX: What to with installed patch files? Delete them for the time beeing
284# rm -v ${PATCHFILE}
285#done
286
287
288
289#)
290
291
292
293# Customize ntpd
294cust_ntpd() (
295 chroot ${NANO_WORLDDIR} sh -c "ln -fs /usr/local/etc/ntp.drift /var/db/ntp.drift"
296)
297
298
299# Enable Serial TTYs
300cust_serial_ttys() (
301 chroot ${NANO_WORLDDIR} sed -i '' -e '/ttyv[0-9]/s/on /off/' -e '/ttyu0/s/off/on/' -e '/ttyu0/s/dialup/ansi/' /etc/ttys
302
303 # Serial login is consided to be phycically secured, so no credentials are required
304 chroot ${NANO_WORLDDIR} sed -i '' -e '/ttyu0/s/std.9600/al.9600/' /etc/ttys
305)
306
307# Customize sudoers files
308cust_sudo_rules() {
309 chroot ${NANO_WORLDDIR} find /usr/local/etc/sudoers.d/ -type f -exec chmod 0640 {} \+
310}
311
312
313# Update databases of tooling like locate and apropos
314cust_update_databases() {
315 chroot ${NANO_WORLDDIR} sh -c '/usr/libexec/makewhatis.local `/usr/bin/manpath -q`'
316 chroot ${NANO_WORLDDIR} "/usr/libexec/locate.updatedb"
317}
318
319# Install files from specific relative location
320cust_install_files () (
321 cd ${NANO_CONF_DIR}/../files
322 find . -print | grep -v -e /CVS -e .svn | cpio -dumpv ${NANO_WORLDDIR}
323)
324
325
326# Make tools available for root by default
327cust_root_bin_to_tools() {
328 ln -s /tools ${NANO_WORLDDIR}/root/bin
329}
330
331
332# Prune no needed directories of image
333cust_nano_prune () (
334 cd ${NANO_WORLDDIR}
335 for ENTRY in ${NANO_PRUNE}; do
336 rm -vfR ${ENTRY}
337 done
338)
339
340# We actually do need an seperate /tmp, so undo the symlinking done in
341# setup_nanobsd()
342late_cust_unset_common_var_and_tmp() (
343 cd ${NANO_WORLDDIR}
344 rm tmp
345 mkdir -m 1777 tmp
346)
347
348
349# Fill /cfg wmth custom files, based on 'create_i386_diskimage ( )'
350last_nano_fill_cfg () (
351 # Variables to be used
352 IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
353 MNT=${MAKEOBJDIRPREFIX}/_.mnt
354
355 # Mount '/cfg' slize in image
356 MD=`mdconfig -a -t vnode -f ${IMG}`
357 mount /dev/${MD}s3 ${MNT}
358
359 # Location of '/cfg' directory
360 cd ${NANO_CONF_DIR}/../cfg-files
361 find . -print | grep -v -e /CVS -e .svn | cpio -dumpv ${MNT}
362
363
364 # Leave in nice end state
365 umount ${MNT}
366 mdconfig -d -u ${MD}
367) > ${MAKEOBJDIRPREFIX}/_.fc 2>&1
368
369last_nano_disk_usage () (
370 # Variables to be used
371 IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
372 MNT=${MAKEOBJDIRPREFIX}/_.mnt
373
374 # Mount root slize
375 MD=`mdconfig -a -t vnode -f ${IMG}`
376 mount /dev/${MD}s1a ${MNT}
377
378 # Show disk usage (percent free) inc header
379 pprint 2 $(df -h | head -1)
380 pprint 2 "$(df -h | grep /dev/${MD})"
381
382 # Leave in nice end state
383 umount ${MNT}
384 mdconfig -d -u ${MD}
385)
386
387
388cust_pkgng () (
389
390 # If the package directory doesn't exist, we're done.
391 if [ ! -d ${NANO_PACKAGE_REPOS} ]; then
392 echo "DONE 0 packages"
393 return 0
394 fi
395
396 # Find a pkg-* package
397 if [ -z "${NANO_PACKAGE_REPOS}/Latest/pkg.txz" ]; then
398 echo "FAILED: need a pkg/ package for bootstrapping"
399 exit 2
400 fi
401
402 # Replicate the packages into the NanoBSD world (as hard links) so we can
403 # access them from the chroot in which pkg is being run.
404 cp -lpR ${NANO_PACKAGE_REPOS} ${NANO_WORLDDIR}/Repos
405
406 #Bootstrap pkg
407 CR env ASSUME_ALWAYS_YES=YES SIGNATURE_TYPE=none /usr/sbin/pkg add /Repos/Latest/pkg.txz
408 CR pkg -N >/dev/null 2>&1
409 if [ "$?" -ne "0" ]; then
410 echo "FAILED: pkg bootstrapping faied"
411 exit 2
412 fi
413
414 mkdir -p ${NANO_WORLDDIR}/usr/local/etc/pkg/repos
415 echo "FreeBSD: { enabled: no }" > ${NANO_WORLDDIR}/usr/local/etc/pkg/repos/FreeBSD.conf
416
417 # Generate a reference to our local repository
418 cat > ${NANO_WORLDDIR}/usr/local/etc/pkg/repos/LOCAL.conf <<-EOF
419 LOCAL: {
420 url : file:///Repos
421 enabled : yes
422 mirror_type : none
423 signature_type : none
424 }
425 EOF
426
427
428 # Count & report how many we have to install
429 todo=`echo ${PACKAGE_LIST} | /usr/bin/wc -l`
430 todo=$(expr $todo + 1) # add one for pkg since it is installed already
431 echo "=== TODO: $todo"
432 echo "${PACKAGE_LIST}"
433 echo "==="
434 for PKG in ${PACKAGE_LIST}
435 do
436 CR env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg install $PKG
437 done
438 rm -rf ${NANO_WORLDDIR}/Repos
439)
440
441last_orders () (
442 last_nano_fill_cfg
443 last_nano_disk_usage
444)
445
446# Ugly hack to 'escaping' pprint from inside a customize_cmd to output
447# instead of a file
448exec 3>/dev/stdout
449# Progress Print
450# Print $2 at level $1
451pprint() {
452 if [ "$1" -le $PPLEVEL ]; then
453 printf "%.${1}s %s\n" "#####" "$2" 1>&3
454 fi
455}
456
457# Cust macro`s gestart in onderstaande volgorde
458# XXX: Determine size before installing all find of additions to see how much
459# base we are actually using ## du -h -d 0
460customize_cmd cust_pkgng
461customize_cmd cust_install_files
462customize_cmd cust_ntpd
463customize_cmd cust_serial_ttys
464customize_cmd cust_version_tag
465customize_cmd cust_root_bin_to_tools
466customize_cmd cust_allow_ssh_root
467customize_cmd cust_openvpn_dhparam
468customize_cmd cust_nano_prune
469customize_cmd cust_set_root_password
470customize_cmd cust_sudo_rules
471customize_cmd cust_unbound_rights
472customize_cmd cust_update_databases
473customize_cmd cust_monitrc_permissions
474#customize_cmd cust_apply_nanobsd_patches
475late_customize_cmd late_cust_unset_common_var_and_tmp
476
477# Standard overwrite
478if [ -r "$NANO_CONF_DIR/nanobsd.local" ]; then
479 . $NANO_CONF_DIR/nanobsd.local
480fi
481
482# Extra config if existing is not suffient
483if [ -n "$EXTRA_NANOBSD_CONFIG" ]; then
484 for FILE in $EXTRA_NANOBSD_CONFIG; do
485 # File relative to config directory
486 if [ "`echo $FILE | cut -c1`" != "/" ]; then
487 FILE=$NANO_CONF_DIR/$FILE
488 fi
489 pprint 1 "Loading $FILE"
490 . $FILE || exit 1
491 done
492fi
Note: See TracBrowser for help on using the repository browser.