1 | ## Dit is een NanoBSD configuratie-template voor WirelessLeiden.
|
---|
2 | ## Instellingen weergegeven binnen dit bestand gelden als
|
---|
3 | ## standaard binnen de organisatie.
|
---|
4 | ## Tweaked for use with 2Gb SDcard, more VAR and TMP space in Alix.APU1C
|
---|
5 |
|
---|
6 | # Little hack to allow proper secify of KERNL/PKG location
|
---|
7 | if [ -n "$NANO_CFG_FILE" ]; then
|
---|
8 | NANO_CONF_DIR=$(cd $(dirname $NANO_CFG_FILE); pwd -P)
|
---|
9 | else
|
---|
10 | NANO_CONF_DIR=$(cd $(dirname $2); pwd -P)
|
---|
11 | fi
|
---|
12 |
|
---|
13 | # object naam in /usr/obj/nanobsd.{obj}
|
---|
14 | NANO_NAME=wleiden-hybrid
|
---|
15 | NANO_SRC=/usr/src # nanobsd source tree
|
---|
16 | NANO_TOOLS=$(pwd)
|
---|
17 | NANO_KERNEL=$NANO_CONF_DIR/kernel.wleiden.apu # naam van het kernel configuratiebestand
|
---|
18 | NANO_IMAGES=2 # aantal nanobsd code slices/installs (1/2)
|
---|
19 |
|
---|
20 | NANO_CONFSIZE=8192 # volume van de config slice, default 2048 (512bs)
|
---|
21 | NANO_DATASIZE=0 # volume van de data slice, 0 = not configured
|
---|
22 | NANO_CODESIZE=0 # Let buildscript the operating system slice as large as posible
|
---|
23 | NANO_RAM_ETCSIZE=20480 # 10 Mb for /etc (10*1024*1024/512)
|
---|
24 | NANO_RAM_TMPVARSIZE=81920 # 40Mb for /Var and /Tmp(40*1024*1024/512)
|
---|
25 |
|
---|
26 | NANO_DRIVE=da0 # Naam van de SD card
|
---|
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
|
---|
31 | NANO_PACKAGE_DIR=$NANO_CONF_DIR/../pkg/All
|
---|
32 | NANO_PACKAGE_LIST="*"
|
---|
33 |
|
---|
34 |
|
---|
35 | # Wireless Leiden ports from $WL_PORTSDIR are copied OVER $PORTSDIR
|
---|
36 | PORTSDIR='/usr/ports'
|
---|
37 | WL_PORTSDIR="$NANO_CONF_DIR/../ports/"
|
---|
38 |
|
---|
39 | # Dirty quirk to allow comments in part below
|
---|
40 | PACKAGE_LIST=`cat <<EOF | sed -e 's/#.*$//g' | xargs
|
---|
41 | benchmarks/iperf
|
---|
42 | devel/py-yaml
|
---|
43 | #dns/dnsmasq
|
---|
44 | ftp/curl
|
---|
45 | lang/python2
|
---|
46 | lang/python
|
---|
47 | net/ladvd
|
---|
48 | net-mgmt/iftop
|
---|
49 | net-mgmt/net-snmp
|
---|
50 | net/mtr
|
---|
51 | net/isc-dhcp42-server
|
---|
52 | net/pen
|
---|
53 | ports-mgmt/pkg
|
---|
54 | security/sudo
|
---|
55 | security/ca_root_nss
|
---|
56 | sysutils/screen
|
---|
57 | sysutils/ucspi-tcp
|
---|
58 | www/apache24
|
---|
59 | www/tinyproxy
|
---|
60 |
|
---|
61 | # Extra WL ports
|
---|
62 | net/lvrouted
|
---|
63 | `
|
---|
64 | # Package target
|
---|
65 | PKG_MAKE_ARGS="PACKAGES=$(dirname $NANO_PACKAGE_DIR) BATCH=yes PACKAGE_BUILDING=yes"
|
---|
66 |
|
---|
67 | PKG_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 | OPTIONS_SET= APACHE FPING SYSLOG
|
---|
74 | OPTIONS_UNSET= PERL PERL_EMBEDDED X11
|
---|
75 | "
|
---|
76 |
|
---|
77 | ##NANO_PACKAGE_LIST=
|
---|
78 |
|
---|
79 | # Warning: set to 1 to debug make build errors
|
---|
80 | # Number of recurrent parrallel make builds
|
---|
81 | if `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"
|
---|
84 | else
|
---|
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}"
|
---|
88 | fi
|
---|
89 |
|
---|
90 | # Starting from soekris bios version 1.31 upwards boot0sio does not seems work
|
---|
91 | # anymore, but boot0 does (weird)
|
---|
92 | NANO_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)
|
---|
96 | NANO_PRUNE="$NANO_PRUNE usr/share/examples"
|
---|
97 | NANO_PRUNE="$NANO_PRUNE usr/share/syscons"
|
---|
98 | NANO_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
|
---|
101 | NANO_PRUNE="$NANO_PRUNE usr/share/pcvt"
|
---|
102 | NANO_PRUNE="$NANO_PRUNE usr/share/me"
|
---|
103 | NANO_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
|
---|
115 | CONF_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
|
---|
134 | WITHOUT_ATM=YES # geen ondersteuning Asynchronous Transfer Mode
|
---|
135 | WITHOUT_AUDIT=YES # geen event auditing / audit trails
|
---|
136 | WITHOUT_AUTHPF=YES # geen authenticating gateway user shell
|
---|
137 | WITHOUT_BLUETOOTH=YES # geen ondersteuning Bluetooth modules
|
---|
138 | WITHOUT_CALENDAR=YES # geen calendar reminder service gecompileerd
|
---|
139 | WITHOUT_CDDL=YES # Set to not build code licensed under Sun CDDL. (also ZFS)
|
---|
140 | WITHOUT_CPP=YES # Set to not build cpp(1).
|
---|
141 | WITHOUT_CVS=YES # geen cvs tools geinstalleerd
|
---|
142 | WITHOUT_DICT=YES # geen dictionary ondersteuning
|
---|
143 | WITHOUT_EXAMPLES=YES # geen voorbeeld configuratiebestanden
|
---|
144 | WITHOUT_FORTRAN=YES # geen ondersteuning fortran compilers
|
---|
145 | WITHOUT_GAMES=YES # geen games gecompileerd
|
---|
146 | WITHOUT_GCOV=YES # geen gcov test coverage program
|
---|
147 | WITHOUT_GDB=YES # geen gnu debugger gecompileerd
|
---|
148 | WITHOUT_GPIB=YES # geen ondersteuning gpib kaarten
|
---|
149 | WITHOUT_HTML=YES # geen html help bestanden gecompileerd
|
---|
150 | WITHOUT_I4B=YES # geen ondersteuning voor isdn
|
---|
151 | WITHOUT_IPX=YES # geen ondersteuning ipx protocols
|
---|
152 | WITHOUT_KERBEROS=YES # geen ondersteuning Kerberos authenticatie
|
---|
153 | WITHOUT_LOCALES=YES # geen ondersteuning lokalisatie
|
---|
154 | WITHOUT_LPR=YES # geen ondersteuning print services
|
---|
155 | WITHOUT_NIS=YES # geen ondersteuning network information system
|
---|
156 | WITHOUT_PROFILE=YES # Set to avoid compiling profiled libraries.
|
---|
157 | WITHOUT_RCMDS=YES # geen ondersteuning rcmds,
|
---|
158 | WITHOUT_RESCUE=YES # geen rescue bestanden gecompileerd
|
---|
159 | WITHOUT_SENDMAIL=YES # geen sendmail geinstalleerd
|
---|
160 | WITHOUT_SHAREDOCS=YES # geen share/docs directories
|
---|
161 | WITHOUT_SYSCONS=YES # geen syscon devices gecompileerd
|
---|
162 | '
|
---|
163 |
|
---|
164 | CONF_BUILD="
|
---|
165 | ${CONF_COMMON}
|
---|
166 | "
|
---|
167 |
|
---|
168 | CONF_INSTALL="
|
---|
169 | ${CONF_COMMON}
|
---|
170 | WITHOUT_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 APU board
|
---|
183 | # values for PCEngines blanc 2 GB cards
|
---|
184 | # C/H/S phys 945/64/63, logical 983/32/63
|
---|
185 | # drive 0x000f2ab0: PCHS=0/0/0 translation=lba LCHS=945/64/63 s=3813376
|
---|
186 | NANO_MEDIASIZE=`expr -e 4097802240 / 512`
|
---|
187 | NANO_HEADS=16
|
---|
188 | NANO_SECTS=63
|
---|
189 |
|
---|
190 | #NANO_MEDIASIZE=`expr 1952448512 / 512`
|
---|
191 | #NANO_HEADS=64
|
---|
192 | #NANO_SECTS=63
|
---|
193 |
|
---|
194 |
|
---|
195 | # Version tagging
|
---|
196 | cust_version_tag() (
|
---|
197 | VERSION_FILE="${NANO_WORLDDIR}/tools/wl-release.txt"
|
---|
198 | (
|
---|
199 | echo "Generated by `id -un`@`hostname -f` at `date`"
|
---|
200 | echo ""
|
---|
201 | echo "=== CONFIG specifics ==="
|
---|
202 | svn info ${NANO_CONF_DIR}/../ || exit 0
|
---|
203 | svn diff ${NANO_CONF_DIR}/../ || exit 0
|
---|
204 | echo "=== BEGIN CONFIG specifics ==="
|
---|
205 | ) > $VERSION_FILE
|
---|
206 | )
|
---|
207 |
|
---|
208 | # Takes a very long time (10+) minutes to generate this file on an ALIX board,
|
---|
209 | # not practical for quick debugging and configuration.
|
---|
210 | cust_openvpn_dhparam() (
|
---|
211 | DHFILE=${NANO_WORLDDIR}/etc/easy-rsa-keys/dh1024.pem
|
---|
212 | mkdir -p `dirname $DHFILE`
|
---|
213 | openssl dhparam -out $DHFILE 1024
|
---|
214 | )
|
---|
215 |
|
---|
216 |
|
---|
217 |
|
---|
218 | # Assuming we are running a safe envirionment where snooping could occur during or after the build
|
---|
219 | cust_set_root_password() (
|
---|
220 | if [ -n "${CFG_ROOT_PASSWORD}" ]; then
|
---|
221 | pprint 2 "Set root password using CFG_ROOT_PASSWORD variable"
|
---|
222 | chroot ${NANO_WORLDDIR} sh -c "echo '${CFG_ROOT_PASSWORD}' | pw usermod -h 0 -n root"
|
---|
223 | else
|
---|
224 | pprint 2 "Root password is <blank>, no password provided at variable CFG_ROOT_PASSWORD"
|
---|
225 | fi
|
---|
226 | )
|
---|
227 |
|
---|
228 |
|
---|
229 |
|
---|
230 | # EXPERIMENTAL patch like envirionment
|
---|
231 | # Using '*-nanobsd.patch' files to only specify the bare differences between the base/default file to
|
---|
232 | # keep us as close as possible to the base OS
|
---|
233 | # Patches are applied to the directory they live in
|
---|
234 | #cust_apply_nanobsd_patches() (
|
---|
235 | # for PATCHFILE in `find ${NANO_WORLDDIR} -regex '.*-nanobsd\.patch$'`; do
|
---|
236 | # cd `dirname ${PATCHFILE}`
|
---|
237 | # patch -t -N -p0 -i `basename ${PATCHFILE}`
|
---|
238 | # #XX: What to with installed patch files? Delete them for the time beeing
|
---|
239 | # rm -v ${PATCHFILE}
|
---|
240 | #done
|
---|
241 |
|
---|
242 |
|
---|
243 |
|
---|
244 | #)
|
---|
245 |
|
---|
246 |
|
---|
247 |
|
---|
248 | # Customize ntpd
|
---|
249 | cust_ntpd() (
|
---|
250 | chroot ${NANO_WORLDDIR} sh -c "ln -fs /usr/local/etc/ntp.drift /var/db/ntp.drift"
|
---|
251 | )
|
---|
252 |
|
---|
253 |
|
---|
254 | # Enable Serial TTYs and boot serial at 115200 baud
|
---|
255 | cust_serial_ttys() (
|
---|
256 | chroot ${NANO_WORLDDIR} sed -i '' -e '/ttyv[0-9]/s/on /off/' -e '/ttyu0/s/off/on/' -e '/ttyu0/s/dialup/ansi/' /etc/ttys
|
---|
257 | echo '-h -S115200' > ${NANO_WORLDDIR}/boot.config
|
---|
258 | )
|
---|
259 |
|
---|
260 |
|
---|
261 |
|
---|
262 | # Install files from specific relative location
|
---|
263 | cust_install_files () (
|
---|
264 | cd ${NANO_CONF_DIR}/../files
|
---|
265 | find . -print | grep -v -e /CVS -e .svn | cpio -dumpv ${NANO_WORLDDIR}
|
---|
266 | )
|
---|
267 |
|
---|
268 |
|
---|
269 | # Make tools available for root by default
|
---|
270 | cust_root_bin_to_tools() {
|
---|
271 | ln -s /tools ${NANO_WORLDDIR}/root/bin
|
---|
272 | }
|
---|
273 |
|
---|
274 |
|
---|
275 | # Prune no needed directories of image
|
---|
276 | cust_nano_prune () (
|
---|
277 | cd ${NANO_WORLDDIR}
|
---|
278 | for ENTRY in ${NANO_PRUNE}; do
|
---|
279 | rm -vfR ${ENTRY}
|
---|
280 | done
|
---|
281 | )
|
---|
282 |
|
---|
283 | # We actually do need an seperate /tmp, so undo the symlinking done in
|
---|
284 | # setup_nanobsd()
|
---|
285 | late_cust_unset_common_var_and_tmp() (
|
---|
286 | cd ${NANO_WORLDDIR}
|
---|
287 | rm tmp
|
---|
288 | mkdir -m 1777 tmp
|
---|
289 | )
|
---|
290 |
|
---|
291 |
|
---|
292 | # Fill /cfg wmth custom files, based on 'create_i386_diskimage ( )'
|
---|
293 | last_nano_fill_cfg () (
|
---|
294 | # Variables to be used
|
---|
295 | IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
|
---|
296 | MNT=${MAKEOBJDIRPREFIX}/_.mnt
|
---|
297 |
|
---|
298 | # Mount '/cfg' slize in image
|
---|
299 | MD=`mdconfig -a -t vnode -f ${IMG}`
|
---|
300 | mount /dev/${MD}s3 ${MNT}
|
---|
301 |
|
---|
302 | # Location of '/cfg' directory
|
---|
303 | cd ${NANO_CONF_DIR}/../cfg-files
|
---|
304 | find . -print | grep -v -e /CVS -e .svn | cpio -dumpv ${MNT}
|
---|
305 |
|
---|
306 |
|
---|
307 | # Leave in nice end state
|
---|
308 | umount ${MNT}
|
---|
309 | mdconfig -d -u ${MD}
|
---|
310 | ) > ${MAKEOBJDIRPREFIX}/_.fc 2>&1
|
---|
311 |
|
---|
312 | last_nano_disk_usage () (
|
---|
313 | # Variables to be used
|
---|
314 | IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
|
---|
315 | MNT=${MAKEOBJDIRPREFIX}/_.mnt
|
---|
316 |
|
---|
317 | # Mount root slize
|
---|
318 | MD=`mdconfig -a -t vnode -f ${IMG}`
|
---|
319 | mount /dev/${MD}s1a ${MNT}
|
---|
320 |
|
---|
321 | # Show disk usage (percent free) inc header
|
---|
322 | pprint 2 $(df -h | head -1)
|
---|
323 | pprint 2 "$(df -h | grep /dev/${MD})"
|
---|
324 |
|
---|
325 | # Leave in nice end state
|
---|
326 | umount ${MNT}
|
---|
327 | mdconfig -d -u ${MD}
|
---|
328 | )
|
---|
329 |
|
---|
330 | last_orders () (
|
---|
331 | last_nano_fill_cfg
|
---|
332 | last_nano_disk_usage
|
---|
333 | )
|
---|
334 |
|
---|
335 | # Ugly hack to 'escaping' pprint from inside a customize_cmd to output
|
---|
336 | # instead of a file
|
---|
337 | exec 3>/dev/stdout
|
---|
338 | # Progress Print
|
---|
339 | # Print $2 at level $1
|
---|
340 | pprint() {
|
---|
341 | if [ "$1" -le $PPLEVEL ]; then
|
---|
342 | printf "%.${1}s %s\n" "#####" "$2" 1>&3
|
---|
343 | fi
|
---|
344 | }
|
---|
345 |
|
---|
346 | # Cust macro`s gestart in onderstaande volgorde
|
---|
347 | # XXX: Determine size before installing all find of additions to see how much
|
---|
348 | # base we are actually using ## du -h -d 0
|
---|
349 | customize_cmd cust_pkgng
|
---|
350 | customize_cmd cust_install_files
|
---|
351 | customize_cmd cust_ntpd
|
---|
352 | customize_cmd cust_serial_ttys
|
---|
353 | customize_cmd cust_version_tag
|
---|
354 | customize_cmd cust_root_bin_to_tools
|
---|
355 | customize_cmd cust_allow_ssh_root
|
---|
356 | customize_cmd cust_openvpn_dhparam
|
---|
357 | customize_cmd cust_nano_prune
|
---|
358 | customize_cmd cust_set_root_password
|
---|
359 | #customize_cmd cust_apply_nanobsd_patches
|
---|
360 | late_customize_cmd late_cust_unset_common_var_and_tmp
|
---|
361 |
|
---|
362 | # Standard overwrite
|
---|
363 | if [ -r "$NANO_CONF_DIR/nanobsd.local" ]; then
|
---|
364 | . $NANO_CONF_DIR/nanobsd.local
|
---|
365 | fi
|
---|
366 |
|
---|
367 | # Extra config if existing is not suffient
|
---|
368 | if [ -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
|
---|
377 | fi
|
---|