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