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

Last change on this file since 13409 was 13409, checked in by ed, 10 years ago

Geen soft-updates meer op de nieuw node image

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