FreeNAS Code
This project has moved to github - see https://github.com/freenas
Brought to you by:
cochard,
mattolander
# FreeNAS NanoBSD configuration file # # NanoBSD port support added from Gitoyen: # http://www.gitoyen.net/Howto-NanoBSD-quagga-router ################## Common section ################# # Name of this NanoBSD build. (Used to construct workdir names) NANO_NAME=FreeNAS # Source tree directory NANO_SRC=/usr/src # Where nanobsd additional files live under the source tree NANO_TOOLS=tools/tools/nanobsd/FreeNAS # Where cust_pkg() finds packages to install NANO_PACKAGE_DIR=${NANO_SRC}/${NANO_TOOLS}/Pkg NANO_PACKAGE_LIST="*" # Object tree directory # default is subdir of /usr/obj # XXX: MAKEOBJDIRPREFIX handling... ? # Need to configure this variable because it's used in the pkg_add function NANO_OBJ=/usr/obj/nanobsd.${NANO_NAME}.${TARGET_ARCH} # The directory to put the final images # default is ${NANO_OBJ} #NANO_DISKIMGDIR="" # Parallel Make NANO_PMAKE="make -j 3" # Need to set early the NANO_ARCH variable for being use in the add_port function # TARGET_ARCH was generated by the make script NANO_ARCH=${TARGET_ARCH} # Options to put in make.conf during buildworld only CONF_BUILD='' # Options to put in make.conf during installworld only # Do not use: WITHOUT_TOOLCHAIN=YES, because installing port need it CONF_INSTALL='' # Options to put in make.conf during both build- & installworld. # See the file /usr/src/tools/build/options for details # WITHOUT_INFO= incompatible for installing a dependency of Quagga # WITHOUT_FORTH= incompatible with boot flags (to be confirm). # WITHOUT_GROFF= incompatible because Needed for installing openldap (need by samba) CONF_WORLD=' WITHOUT_ACCT= WITHOUT_APM= WITHOUT_ASSERT_DEBUG= WITHOUT_ATM= WITHOUT_AUDIT= WITHOUT_AUTHPF= WITHOUT_BIND= WITHOUT_BIND_DNSSEC= WITHOUT_BIND_ETC= WITHOUT_BIND_LIBS_LWRES= WITHOUT_BIND_MTREE= WITHOUT_BIND_NAMED= WITHOUT_BIND_UTILS= WITHOUT_BLUETOOTH= WITHOUT_CALENDAR= WITHOUT_CTM= WITHOUT_CVS= WITHOUT_DICT= WITHOUT_EXAMPLES= WITHOUT_FLOPPY= WITHOUT_FREEBSD_UPDATE= WITHOUT_GAMES= WITHOUT_GCOV= WITHOUT_GDB= WITHOUT_GPIB= WITHOUT_HTML= WITHOUT_IPFILTER= WITHOUT_IPFW= WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_JAIL= WITHOUT_KERBEROS= WITHOUT_KERBEROS_SUPPORT= WITHOUT_LEGACY_CONSOLE= WITHOUT_LIB32= WITHOUT_LOCALES= WITHOUT_LOCATE= WITHOUT_LPR= WITHOUT_MAIL= WITHOUT_MAILWRAPPER= WITHOUT_MAN= WITHOUT_NCP= WITHOUT_NDIS= WITHOUT_NETCAT= WITHOUT_NIS= WITHOUT_NLS= WITHOUT_NLS_CATALOGS= WITHOUT_NS_CACHING= WITHOUT_PORTSNAP= WITHOUT_RCMDS= WITHOUT_RESCUE= WITHOUT_ROUTED= WITHOUT_SENDMAIL= WITHOUT_SHAREDOCS= WITHOUT_SSP= WITHOUT_SYSCONS= WITHOUT_SYSINSTALL= WITHOUT_TELNET= ' # Customize commands. NANO_CUSTOMIZE="" # Late customize commands. NANO_LATE_CUSTOMIZE="" # Newfs paramters to use NANO_NEWFS="-b 4096 -f 512 -i 8192 -O1 -m 0" # Target media size in 512 bytes sectors NANO_MEDIASIZE=1200000 # Number of code images on media (1 or 2) NANO_IMAGES=2 # 0 -> Leave second image all zeroes so it compresses better. # 1 -> Initialize second image with a copy of the first NANO_INIT_IMG2=0 # Size of code file system in 512 bytes sectors # If zero, size will be as large as possible. NANO_CODESIZE=0 # Size of configuration file system in 512 bytes sectors # Cannot be zero. NANO_CONFSIZE=2048 # Size of data file system in 512 bytes sectors # If zero: no partition configured. # If negative: max size possible # This filesystem is used for archive configuration and # for user customized scripts or tool NANO_DATASIZE=2048 # Size of the /etc ramdisk in 512 bytes sectors NANO_RAM_ETCSIZE=10240 # Size of the /tmp+/var ramdisk in 512 bytes sectors NANO_RAM_TMPVARSIZE=10240 # Media geometry, only relevant if bios doesn't understand LBA. NANO_SECTS=63 NANO_HEADS=16 # Boot0cfg configuration mode NANO_BOOT0CFG="-o packet -s 1 -m 3" # Backing type of md(4) device # Can be "file" or "swap" NANO_MD_BACKING="file" # Label name # Alphacharacter only NANO_GLABEL_SYS="FreeNAS" NANO_GLABEL_CFG="cfg" NANO_GLABEL_DATA="sysdata" # Progress Print level PPLEVEL=3 # Need to check if this function works with cross-compiling architecture!!!! # Recursive complex fonction: Generate one function for each ports add_port () { port=`echo $1 | sed -e 's/\//_/'` # Check if package allready exist # Need to: # 1. check ARCH of this package! # 2. Add a trap cd /usr/ports/$1 PKG_NAME=`make package-name` if [ -f ${NANO_OBJ}/ports/packages/All/${PKG_NAME}.tbz ]; then # Pkg file found: Generate add_pkg_NAME function eval " add_pkg_${port} () { #Need to create ${NANO_OBJ}/ports in this add_pkg_${port} function if [ ! -d \${NANO_OBJ}/ports ]; then mkdir -p \${NANO_OBJ}/ports/distfiles mkdir -p \${NANO_OBJ}/ports/packages fi mkdir -p \${NANO_WORLDDIR}/usr/ports/packages mkdir -p \${NANO_WORLDDIR}/usr/ports/distfiles mount -t unionfs -o noatime \${NANO_OBJ}/ports/packages \ \${NANO_WORLDDIR}/usr/ports/packages mount -t unionfs -o noatime \${NANO_OBJ}/ports/distfiles \ \${NANO_WORLDDIR}/usr/ports/distfiles chroot \${NANO_WORLDDIR} /bin/sh -exc \ 'cd /usr/ports/packages/All;pkg_add -F ${PKG_NAME}.tbz' umount \${NANO_WORLDDIR}/usr/ports/packages umount \${NANO_WORLDDIR}/usr/ports/distfiles rmdir \${NANO_WORLDDIR}/usr/ports/packages rmdir \${NANO_WORLDDIR}/usr/ports/distfiles rmdir \${NANO_WORLDDIR}/usr/ports } customize_cmd add_pkg_${port} " else # No pkg file: Generate add_port_NAME function eval " add_port_${port} () { #Need to create ${NANO_OBJ}/ports in this add_port_${port} function if [ ! -d \${NANO_OBJ}/ports ]; then mkdir -p \${NANO_OBJ}/ports/distfiles mkdir -p \${NANO_OBJ}/ports/packages fi mkdir -p \${NANO_WORLDDIR}/usr/ports/packages mkdir -p \${NANO_WORLDDIR}/usr/ports/distfiles mount -t unionfs -o noatime /usr/src \ \${NANO_WORLDDIR}/usr/src mount -t unionfs -o noatime /usr/ports \ \${NANO_WORLDDIR}/usr/ports mount -t unionfs -o noatime \${NANO_OBJ}/ports/packages \ \${NANO_WORLDDIR}/usr/ports/packages mount -t unionfs -o noatime \${NANO_OBJ}/ports/distfiles \ \${NANO_WORLDDIR}/usr/ports/distfiles mkdir -p \${NANO_WORLDDIR}/dev mount -t devfs devfs \${NANO_WORLDDIR}/dev mkdir -p \${NANO_WORLDDIR}/usr/pobj mkdir -p \${NANO_WORLDDIR}/usr/workdir cp /etc/resolv.conf \${NANO_WORLDDIR}/etc/resolv.conf # Improvement: Don't know why package-recursive don't works here chroot \${NANO_WORLDDIR} /bin/sh -exc \ 'env TARGET=${NANO_ARCH} TARGET_ARCH=${NANO_ARCH} make WRKDIRPREFIX=/usr/workdir -C /usr/ports/$1 \ package BATCH=yes $2 clean' rm \${NANO_WORLDDIR}/etc/resolv.conf rm -rf \${NANO_WORLDDIR}/usr/obj rm -rf \${NANO_WORLDDIR}/usr/pobj rm -rf \${NANO_WORLDDIR}/usr/workdir umount \${NANO_WORLDDIR}/dev umount \${NANO_WORLDDIR}/usr/ports/packages umount \${NANO_WORLDDIR}/usr/ports/distfiles umount \${NANO_WORLDDIR}/usr/ports umount \${NANO_WORLDDIR}/usr/src rmdir \${NANO_WORLDDIR}/usr/ports/packages rmdir \${NANO_WORLDDIR}/usr/ports/distfiles rmdir \${NANO_WORLDDIR}/usr/ports } customize_cmd add_port_${port} " fi } ##### General library # Libiconv is needed by lot's of port: add_port "converters/libiconv" "-DNO_INSTALL_MANPAGES -DFORCE_PKG_REGISTER" # Gettext is need for allmost all ports add_port "devel/gettext" "-DNO_INSTALL_MANPAGES -DFORCE_PKG_REGISTER" # pkg-config is need by fuse and lighttpd add_port "devel/pkg-config" "-DNO_INSTALL_MANPAGES -DNOPORTDOCS" # Webmin and samba compilation need perl add_port "lang/perl5.8" "-DWITHOUT_PERL_MALLOC -DWITH_PERL_64BITINT -DNO_INSTALL_MANPAGES" #### FreeNAS webGUI add_port "security/p5-Net-SSLeay" "-DNO_INSTALL_MANPAGES -DNOPORTDOCS" add_port "security/p5-Authen-PAM" "-DNO_INSTALL_MANPAGES -DNOPORTDOCS" add_port "sysutils/webmin" "-DNO_INSTALL_MANPAGES -DNOPORTDOCS" #### Disks Mangement add_port "sysutils/smartmontools" "-DNO_INSTALL_MANPAGES -DNOPORTDOCS" # NTFS-3g add_port "sysutils/fusefs-libs" "-DNOPORTDOCS -DNO_INSTALL_MANPAGES" add_port "sysutils/fusefs-kmod" "-DNOPORTDOCS -DNO_INSTALL_MANPAGES" add_port "devel/libublio" "-DNOPORTDOCS -DNO_INSTALL_MANPAGES" add_port "sysutils/fusefs-ntfs" "-DNOPORTDOCS -DNO_INSTALL_MANPAGES -DWITH_UBLIO" #### Network protocols # iSCSI target add_port "net/istgt" "-DNOPORTDOCS -DNO_INSTALL_MANPAGES" # Samba add_port "security/heimdal" "-DNOPORTDOCS -DNO_INSTALL_MANPAGES" add_port "net/openldap24-client" "-DNOPORTDOCS -DNO_INSTALL_MANPAGES" add_port "devel/libexecinfo" "-DNOPORTDOCS -DNO_INSTALL_MANPAGES" add_port "devel/popt" "-DNOPORTDOCS -DNO_INSTALL_MANPAGES" add_port "net/samba33" "-DNOPORTDOCS -DNO_INSTALL_MANPAGES -DWITHOUT_CUPS -DWITH_SYSLOG -DWITH_QUOTAS -DWITH_EXP_MODULES -DWITH_ACL_SUPPORT -DWITH_PAM_SMBPASS -DWITH_ADS" # netatalk: For Apple network add_port "security/libgpg-error" "-DNOPORTDOCS -DNO_INSTALL_MANPAGES" add_port "security/libgcrypt" "-DNOPORTDOCS -DNO_INSTALL_MANPAGES" add_port "databases/db41" "-DNOPORTDOCS -DNO_INSTALL_MANPAGES" add_port "net/netatalk" "-DNOPORTDOCS -DNO_INSTALL_MANPAGES" ### Extra stuf # The webserver is not mandatory (webmin include a webserver) add_port "devel/pcre" "-DNO_INSTALL_MANPAGES -DNOPORTDOCS" # I don't want spawn-fcgi! Why the option -DWITHOUT_SPAWNFCGI is not used !!! #add_port "www/spawn-fcgi" "-DNO_INSTALL_MANPAGES -DNOPORTDOCS" # Lighttpd, for Webdav, need theses libs: add_port "misc/e2fsprogs-libuuid" "-DNO_INSTALL_MANPAGES -DNOPORTDOCS" add_port "databases/sqlite3" "-DNO_INSTALL_MANPAGES -DNOPORTDOCS" add_port "textproc/libxml2" "-DNO_INSTALL_MANPAGES -DNOPORTDOCS" # And, at last, lighttpd: add_port "www/lighttpd" "-DNO_INSTALL_MANPAGES -DFORCE_PKG_REGISTER -DWITH_WEBDAV -DWITH_BZIP2 -DWITHOUT_SPAWNFCGI" # Add a text editor that support syntax colorization (usefull for edit shell script) add_port "editors/vim-lite" "-DWITHOUT_X11 -DNO_INSTALL_MANPAGES" # Add a simple mail sender (replace sendmail, don't forget /etc/mail/mailer.conf) # Can't compile it under NanoBSD, erreur log: #===> Building for ssmtp-2.62.3 #cc -DSTDC_HEADERS=1 -DHAVE_LIMITS_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYSLOG_H=1 -DHAVE_UNISTD_H=1 -DRETSIGTYPE=void -DHAVE_VPRINTF=1 -DHAVE_GETHOSTNAME=1 -DHAVE_SOCKET=1 -DHAVE_STRDUP=1 -DHAVE_STRSTR=1 -DLOGFILE=1 -DREWRITE_DOMAIN=1 -DHAVE_SSL=1 -DINET6=1 -DMD5AUTH=1 -DSSMTPCONFDIR=\"/usr/local/etc/ssmtp\" -DCONFIGURATION_FILE=\"/usr/local/etc/ssmtp/ssmtp.conf\" -DREVALIASES_FILE=\"/usr/local/etc/ssmtp/revaliases\" -O2 -pipe -I/usr/include -fno-strict-aliasing amd64 -c -o ssmtp.o ssmtp.c #cc: amd64: No such file or directory #gmake: *** [ssmtp.o] Erreur 1 # add_port "mail/ssmtp" "-DWITHOUT_USERPREFS -DWITH_LOGFILE -DWITH_MD5AUTH -DNOPORTDOCS -DNO_INSTALL_MANPAGES" cleanup_ports () { # The build tools are installed only if ports are compiled, then don't exist otherwize. # Need to prevent auto exist of this script set +e chroot ${NANO_WORLDDIR} /bin/sh -exc \ 'pkg_delete gmake* libtool* gawk* ' set -e } customize_cmd cleanup_ports # FreeNAS custom function freenas_custom () { # Copy BSDRP information files cp -v ${NANO_TOOLS}/AUTHORS ${NANO_WORLDDIR}/root/ cp -v ${NANO_TOOLS}/LICENSE ${NANO_WORLDDIR}/root/ # Disable reverse DNS in sshd: echo "UseDNS no" >> ${NANO_WORLDDIR}/etc/ssh/sshd_config # Set ssmtp permission (mail/ssmtp/files/pkg-install.in) # Theses permission are normally allready set by installing ssmtp ?? #chroot ${NANO_WORLDDIR} /bin/sh -exc \ #'chown root:ssmtp /usr/local/sbin/ssmtp' #chroot ${NANO_WORLDDIR} /bin/sh -exc \ #'chmod g+s /usr/local/sbin/ssmtp' #chroot ${NANO_WORLDDIR} /bin/sh -exc \ #'chown -R root:ssmtp /usr/local/etc/ssmtp' #chroot ${NANO_WORLDDIR} /bin/sh -exc \ #'chmod 750 /usr/local/etc/ssmtp' #chroot ${NANO_WORLDDIR} /bin/sh -exc \ #'chmod 640 /usr/local/etc/ssmtp/*' # Compress the kernel (save 3Mb) if [ -f ${NANO_WORLDDIR}/boot/kernel/kernel ] then gzip -v9 ${NANO_WORLDDIR}/boot/kernel/kernel fi # Remove info and man pages if [ -d ${NANO_WORLDDIR}/usr/local/info ] then rm -f ${NANO_WORLDDIR}/usr/local/info/*.* fi if [ -d ${NANO_WORLDDIR}/usr/local/man ] then rm -f ${NANO_WORLDDIR}/usr/local/man/man1/*.gz rm -f ${NANO_WORLDDIR}/usr/local/man/man3/*.gz fi # Remove doc folder DOCS_TO_REMOVE=' doc/gettext doc/libasprintf doc/libiconv doc/snmp ' for c in $DOCS_TO_REMOVE do if [ -d ${NANO_WORLDDIR}/usr/local/share/$c ] then rm -rf ${NANO_WORLDDIR}/usr/local/share/$c fi done # Remove info files (save 2 Mb) if [ -d ${NANO_WORLDDIR}/usr/share/info ] then rm -f ${NANO_WORLDDIR}/usr/share/info/*.gz fi # Remove all include files (16Mb) # Warning include files ARE needed for Webmin ?!?? # TO DO: Need to compile these files before and compile them after..... if [ -d ${NANO_WORLDDIR}/usr/include ] then #rm -rf ${NANO_WORLDDIR}/usr/include/* rm -rf ${NANO_WORLDDIR}/usr/include/dlmalloc rm -rf ${NANO_WORLDDIR}/usr/include/net-snmp fi # Remove some files FILES_TO_REMOVE=' usr/sbin/config ' for c in $FILES_TO_REMOVE do if [ -f ${NANO_WORLDDIR}/$c ] then rm -rf ${NANO_WORLDDIR}/$c fi done # About removing all gcc suite # How to found the list of all binary files members of gcc suite ? # This do not prevent to rebuild a BSDRP image easly because there is # an installworld that is done before to (re)build ports } # Enable only serial system only freenas_console_serial () { # Enable getty on console sed -i "" -e /tty[du]0/s/off/on/ ${NANO_WORLDDIR}/etc/ttys sed -i "" -e /tty[du]0/s/dialup/vt100/ ${NANO_WORLDDIR}/etc/ttys # Disable getty on syscons devices sed -i "" -e '/^ttyv[0-8]/s/ on/ off/' ${NANO_WORLDDIR}/etc/ttys # Tell loader to use serial console early. echo " -h" > ${NANO_WORLDDIR}/boot.config # Customize loader.conf file: echo 'boot_serial="YES"' >> ${NANO_WORLDDIR}/boot/loader.conf echo 'comconsole_speed="9600"' >> ${NANO_WORLDDIR}/boot/loader.conf echo 'console="comconsole"' >> ${NANO_WORLDDIR}/boot/loader.conf } # Enable use of keyboard/vga and serial # ###### Warning #### # BUG TO FIX: Don't boot if no serial port available! # freenas_console_dual () { sed -i "" -e /tty[du]0/s/off/on/ ${NANO_WORLDDIR}/etc/ttys sed -i "" -e /tty[du]0/s/dialup/vt100/ ${NANO_WORLDDIR}/etc/ttys # Tell loader to use serial and vga console. echo " -D" > ${NANO_WORLDDIR}/boot.config # Customize loader.conf file: echo 'boot_multicons="YES"' >> ${NANO_WORLDDIR}/boot/loader.conf echo 'boot_serial="YES"' >> ${NANO_WORLDDIR}/boot/loader.conf echo 'comconsole_speed="9600"' >> ${NANO_WORLDDIR}/boot/loader.conf echo 'console="comconsole,vidconsole"' >> ${NANO_WORLDDIR}/boot/loader.conf } # Standard vga console, with serial port configured as vt100 console freenas_console_vga () { sed -i "" -e /tty[du]0/s/off/on/ ${NANO_WORLDDIR}/etc/ttys sed -i "" -e /tty[du]0/s/dialup/vt100/ ${NANO_WORLDDIR}/etc/ttys } # Set physical disk layout for generic USB of 1Gb UsbDevice Generic 1000 # Install Custom scripts and config files customize_cmd cust_install_files # Need to execute the bsdrp_custom after the cust_install_files customize_cmd freenas_custom # Allow root login via ssh customize_cmd cust_allow_ssh_root