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

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

Since we are going to use multiple types of disks ada(4) for ALIX and da(4) for SD-card based USB disk, requiring a more
stable way of locating partitions. Labels are a perfect fit for this purposes.

WARNING: This will break upgrades of images.

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