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

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

No need for space bulky locales

File size: 13.8 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
170WITHOUT_ICONV=YES # No extended character support
171WITHOUT_LOCALES=YES # No localization support
172'
173
174CONF_BUILD="
175${CONF_COMMON}
176"
177
178CONF_INSTALL="
179${CONF_COMMON}
180WITHOUT_TOOLCHAIN=YES # geen freebsd toolchain
181"
182
183
184# Flash disks arrived, sandisk 1g seems to match the geometry of the (blanc) cards
185#FlashDevice sandisk 1g # nanobsd flashdevice entry
186#FlashDevice sandisk 512mb # nanobsd flashdevice entry
187#FlashDevice transcend 2g # nanobsd flashdevice entry
188# Calculated value of PEAK hardware 1GB CF card
189# C/H/S phys 1954/16/63, logical 977/32/63
190# Mediasize is calculated as C*H*S*512
191
192# Using logical values reported by ALIX board
193# values for PCEngines blanc 1 GB cards
194# C/H/S phys 1966/16/63, logical 983/32/63
195NANO_MEDIASIZE=`expr 1008451584 / 512`
196NANO_HEADS=32
197NANO_SECTS=63
198
199
200# Version tagging
201cust_version_tag() (
202 VERSION_FILE="${NANO_WORLDDIR}/tools/wl-release.txt"
203 (
204 echo "Generated by `id -un`@`hostname -f` at `date`"
205 echo ""
206 echo "=== CONFIG specifics ==="
207 svn info ${NANO_CONF_DIR}/../ || exit 0
208 svn diff ${NANO_CONF_DIR}/../ || exit 0
209 echo "=== BEGIN CONFIG specifics ==="
210 ) > $VERSION_FILE
211)
212
213# Takes a very long time (10+) minutes to generate this file on an ALIX board,
214# not practical for quick debugging and configuration.
215cust_openvpn_dhparam() (
216 if [ -r ${NANO_CONF_DIR}/usr/local/bin/openvpn ]; then
217 DHFILE=${NANO_WORLDDIR}/etc/easy-rsa-keys/dh1024.pem
218 mkdir -p `dirname $DHFILE`
219 openssl dhparam -out $DHFILE 1024
220 fi
221)
222
223
224
225# Assuming we are running a safe envirionment where snooping could occur during or after the build
226cust_set_root_password() (
227 if [ -n "${CFG_ROOT_PASSWORD}" ]; then
228 pprint 2 "Set root password using CFG_ROOT_PASSWORD variable"
229 chroot ${NANO_WORLDDIR} sh -c "echo '${CFG_ROOT_PASSWORD}' | pw usermod -h 0 -n root"
230 else
231 pprint 2 "Root password is <blank>, no password provided at variable CFG_ROOT_PASSWORD"
232 fi
233)
234
235
236
237# EXPERIMENTAL patch like envirionment
238# Using '*-nanobsd.patch' files to only specify the bare differences between the base/default file to
239# keep us as close as possible to the base OS
240# Patches are applied to the directory they live in
241#cust_apply_nanobsd_patches() (
242# for PATCHFILE in `find ${NANO_WORLDDIR} -regex '.*-nanobsd\.patch$'`; do
243# cd `dirname ${PATCHFILE}`
244# patch -t -N -p0 -i `basename ${PATCHFILE}`
245# #XX: What to with installed patch files? Delete them for the time beeing
246# rm -v ${PATCHFILE}
247#done
248
249
250
251#)
252
253
254
255# Customize ntpd
256cust_ntpd() (
257 chroot ${NANO_WORLDDIR} sh -c "ln -fs /usr/local/etc/ntp.drift /var/db/ntp.drift"
258)
259
260
261# Enable Serial TTYs
262cust_serial_ttys() (
263 chroot ${NANO_WORLDDIR} sed -i '' -e '/ttyv[0-9]/s/on /off/' -e '/ttyu0/s/off/on/' -e '/ttyu0/s/dialup/ansi/' /etc/ttys
264
265 # Serial login is consided to be phycically secured, so no credentials are required
266 chroot ${NANO_WORLDDIR} sed -i '' -e '/ttyu0/s/std.9600/al.9600/' /etc/ttys
267)
268
269# Customize sudoers files
270cust_sudo_rules() {
271 chroot ${NANO_WORLDDIR} find /usr/local/etc/sudoers.d/ -type f -exec chmod 0640 {} \+
272}
273
274
275
276# Install files from specific relative location
277cust_install_files () (
278 cd ${NANO_CONF_DIR}/../files
279 find . -print | grep -v -e /CVS -e .svn | cpio -dumpv ${NANO_WORLDDIR}
280)
281
282
283# Make tools available for root by default
284cust_root_bin_to_tools() {
285 ln -s /tools ${NANO_WORLDDIR}/root/bin
286}
287
288
289# Prune no needed directories of image
290cust_nano_prune () (
291 cd ${NANO_WORLDDIR}
292 for ENTRY in ${NANO_PRUNE}; do
293 rm -vfR ${ENTRY}
294 done
295)
296
297# We actually do need an seperate /tmp, so undo the symlinking done in
298# setup_nanobsd()
299late_cust_unset_common_var_and_tmp() (
300 cd ${NANO_WORLDDIR}
301 rm tmp
302 mkdir -m 1777 tmp
303)
304
305
306# Fill /cfg wmth custom files, based on 'create_i386_diskimage ( )'
307last_nano_fill_cfg () (
308 # Variables to be used
309 IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
310 MNT=${MAKEOBJDIRPREFIX}/_.mnt
311
312 # Mount '/cfg' slize in image
313 MD=`mdconfig -a -t vnode -f ${IMG}`
314 mount /dev/${MD}s3 ${MNT}
315
316 # Location of '/cfg' directory
317 cd ${NANO_CONF_DIR}/../cfg-files
318 find . -print | grep -v -e /CVS -e .svn | cpio -dumpv ${MNT}
319
320
321 # Leave in nice end state
322 umount ${MNT}
323 mdconfig -d -u ${MD}
324) > ${MAKEOBJDIRPREFIX}/_.fc 2>&1
325
326last_nano_disk_usage () (
327 # Variables to be used
328 IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
329 MNT=${MAKEOBJDIRPREFIX}/_.mnt
330
331 # Mount root slize
332 MD=`mdconfig -a -t vnode -f ${IMG}`
333 mount /dev/${MD}s1a ${MNT}
334
335 # Show disk usage (percent free) inc header
336 pprint 2 $(df -h | head -1)
337 pprint 2 "$(df -h | grep /dev/${MD})"
338
339 # Leave in nice end state
340 umount ${MNT}
341 mdconfig -d -u ${MD}
342)
343
344
345cust_pkgng () (
346
347 # If the package directory doesn't exist, we're done.
348 if [ ! -d ${NANO_PACKAGE_REPOS} ]; then
349 echo "DONE 0 packages"
350 return 0
351 fi
352
353 # Find a pkg-* package
354 if [ -z "${NANO_PACKAGE_REPOS}/Latest/pkg.txz" ]; then
355 echo "FAILED: need a pkg/ package for bootstrapping"
356 exit 2
357 fi
358
359 # Replicate the packages into the NanoBSD world (as hard links) so we can
360 # access them from the chroot in which pkg is being run.
361 cp -lpR ${NANO_PACKAGE_REPOS} ${NANO_WORLDDIR}/Repos
362
363 #Bootstrap pkg
364 CR env ASSUME_ALWAYS_YES=YES SIGNATURE_TYPE=none /usr/sbin/pkg add /Repos/Latest/pkg.txz
365 CR pkg -N >/dev/null 2>&1
366 if [ "$?" -ne "0" ]; then
367 echo "FAILED: pkg bootstrapping faied"
368 exit 2
369 fi
370
371 mkdir -p ${NANO_WORLDDIR}/usr/local/etc/pkg/repos
372 echo "FreeBSD: { enabled: no }" > ${NANO_WORLDDIR}/usr/local/etc/pkg/repos/FreeBSD.conf
373
374 # Generate a reference to our local repository
375 cat > ${NANO_WORLDDIR}/usr/local/etc/pkg/repos/LOCAL.conf <<-EOF
376 LOCAL: {
377 url : file:///Repos
378 enabled : yes
379 mirror_type : none
380 signature_type : none
381 }
382 EOF
383
384
385 # Count & report how many we have to install
386 todo=`echo ${PACKAGE_LIST} | /usr/bin/wc -l`
387 todo=$(expr $todo + 1) # add one for pkg since it is installed already
388 echo "=== TODO: $todo"
389 echo "${PACKAGE_LIST}"
390 echo "==="
391 for PKG in ${PACKAGE_LIST}
392 do
393 CR env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg install $PKG
394 done
395 nano_rm -rf ${NANO_WORLDDIR}/Repos
396)
397
398last_orders () (
399 last_nano_fill_cfg
400 last_nano_disk_usage
401)
402
403# Ugly hack to 'escaping' pprint from inside a customize_cmd to output
404# instead of a file
405exec 3>/dev/stdout
406# Progress Print
407# Print $2 at level $1
408pprint() {
409 if [ "$1" -le $PPLEVEL ]; then
410 printf "%.${1}s %s\n" "#####" "$2" 1>&3
411 fi
412}
413
414# Cust macro`s gestart in onderstaande volgorde
415# XXX: Determine size before installing all find of additions to see how much
416# base we are actually using ## du -h -d 0
417customize_cmd cust_pkgng
418customize_cmd cust_install_files
419customize_cmd cust_ntpd
420customize_cmd cust_serial_ttys
421customize_cmd cust_version_tag
422customize_cmd cust_root_bin_to_tools
423customize_cmd cust_allow_ssh_root
424customize_cmd cust_openvpn_dhparam
425customize_cmd cust_nano_prune
426customize_cmd cust_set_root_password
427customize_cmd cust_sudo_rules
428#customize_cmd cust_apply_nanobsd_patches
429late_customize_cmd late_cust_unset_common_var_and_tmp
430
431# Standard overwrite
432if [ -r "$NANO_CONF_DIR/nanobsd.local" ]; then
433 . $NANO_CONF_DIR/nanobsd.local
434fi
435
436# Extra config if existing is not suffient
437if [ -n "$EXTRA_NANOBSD_CONFIG" ]; then
438 for FILE in $EXTRA_NANOBSD_CONFIG; do
439 # File relative to config directory
440 if [ "`echo $FILE | cut -c1`" != "/" ]; then
441 FILE=$NANO_CONF_DIR/$FILE
442 fi
443 pprint 1 "Loading $FILE"
444 . $FILE || exit 1
445 done
446fi
Note: See TracBrowser for help on using the repository browser.