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

Last change on this file since 13427 was 13427, checked in by rick, 9 years ago

PoC Poudriere generated local repository

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