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

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

Strip down debugging to make in fit again in available size.

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