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