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