<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
<book>
<title>FreeNAS Developers' Handbook</title>
<bookinfo>
<date>June 6, 2006</date>
<author>
<firstname>Olivier</firstname>
<surname>Cochard</surname>
</author>
<copyright>
<year>2005-2006</year>
<holder>FreeNAS Documentation Project.</holder>
</copyright>
<legalnotice>
<para>This document is based on the <ulink
url="http://doc.m0n0.ch/dev/">m0n0wall Developers'
Handbook</ulink></para>
<para>All rights reserved. Redistribution and use in any form, with or
without modification, are permitted provided that the following
conditions are met:</para>
<itemizedlist>
<listitem>
<para>Redistributions must retain the above copyright notice, this
list of conditions and the following disclaimer.</para>
</listitem>
</itemizedlist>
<itemizedlist>
<listitem>
<para>Neither the name of the FreeNAS Documentation Project nor the
names of its contributors may be used to endorse or promote products
derived from this documentation without specific prior written
permission.</para>
</listitem>
</itemizedlist>
<para>THIS DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS DOCUMENTATION OR THE ASSOCIATED SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.</para>
<para>October 2005</para>
</legalnotice>
</bookinfo>
<chapter>
<title>Using the sources</title>
<para>This is the easiest way for studing/modify FreeNAS.</para>
<sect1>
<title>Installation of the developpement environement</title>
<para>Install FreeBSD on your PC, following the standard
procedure.</para>
</sect1>
<sect1>
<title>Downloading the source</title>
<para>Download the FreeNAS sources on sourceforge, untar it, Edit the
file, modifying it, created the modified ISO.</para>
</sect1>
</chapter>
<chapter>
<title>Building FreeNAS from Scratch</title>
<para>This is the longest way for studing/modify FreeNAS, but with this
can be usefull if you want to add lot's of binary file or others...</para>
<sect1>
<title>Resources</title>
<para>Here is where I found some information about FreeBSD:</para>
<itemizedlist>
<listitem>
<para><ulink url="http://www.freebsd.org">Official FreeBSD
Website</ulink></para>
</listitem>
<listitem>
<para><ulink
url="http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/">FreeBSD
Handbook</ulink></para>
</listitem>
<listitem>
<para><ulink url="https://neon1.net/misc/minibsd.html">miniBSD -
reducing FreeBSD</ulink></para>
</listitem>
<listitem>
<para><ulink
url="ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/6.0/">Download
the FreeBSD 6.0-RC1 CD N°1</ulink></para>
</listitem>
</itemizedlist>
</sect1>
<sect1>
<title>Install FreeBSD for developers</title>
<sect2>
<title>Installation</title>
<para>Install FreeBSD with the developer distribution with ports
collection (I don't use FreeBSD jail).</para>
<para>In the beginning of the install process:</para>
<para>Create only 2 partition the root ("/") and the SWAP:
<remark>It's important because after we re-compile the system with
dynamically linked library, and the system can't boot if the /usr
directory is not on the same partition.</remark></para>
<para>In the last configuration step of the installation
process:</para>
<itemizedlist>
<listitem>
<para>Create a new user at the end and put it in the “wheel” group
(Mandatory for using the “su root” command).</para>
</listitem>
<listitem>
<para>Enable the SSHD daemon</para>
</listitem>
</itemizedlist>
</sect2>
<sect2>
<title>User and Shell customization</title>
<para>Install Bash Shell</para>
<para>Personally I prefer working with the Bash Sell.</para>
<para>Download and Install the Bash shell:</para>
<para><command>pkg_add -r bash</command></para>
<para>(“-r“ option is for remote downloading: FTP). Then, using this
command:</para>
<para><command>chpass username</command></para>
<para>and modify the shell with the Bash :
<code>/usr/local/bin/bash</code></para>
<para>Customizing the bash profile for displaying the actual directory
in the prompt:</para>
<para><command>cd</command></para>
<para><command>cp .profile .bash_profile</command></para>
<para>And put these lines at the end of this file:</para>
<para><code># set prompt: ``username@hostname:/directory $ ''
</code></para>
<para><code>PS1="[\u@\h:\w] " </code></para>
<para><code>case `id -u` in 0) </code></para>
<para><code>PS1="${PS1}# ";; *) </code></para>
<para><code>PS1="${PS1}$ ";; </code></para>
<para><code>esac</code></para>
</sect2>
<sect2>
<title>Updating sources</title>
<sect3>
<title>Install CVS</title>
<para>Download & Install CVS with this command:</para>
<para><command>pkg_add -r cvsup-without-gui</command></para>
</sect3>
<sect3>
<title>Configuring CVS</title>
<para>Configuring the supfile copy the example supfile on the /etc
with this command:</para>
<para><command>cp /usr/share/examples/cvsup/stable-supfile
/etc/supfile</command></para>
<para><command>cp /usr/share/examples/cvsup/ports-supfile
/etc/ports-supfile</command></para>
<para>Found the nearest CVSUP server of you on this mirror list:
<ulink
url="http://www.freebsd.org/doc/handbook/cvsup.html#CVSUP-MIRRORS"><uri>http://www.freebsd.org/doc/handbook/cvsup.html#CVSUP-MIRRORS</uri></ulink></para>
<para>Editing the /etc/supfile and /etc/ports-suppfile and modify
this line:</para>
<para><code><code>*default
host=cvsup.fr.FreeBSD.org</code></code></para>
</sect3>
<sect3>
<title>Update the sources</title>
<para><command>cvsup -g -L 2 /etc/supfile</command></para>
<para><command>cvsup -g -L 2 /etc/ports-supfile</command></para>
<para>Options explain:</para>
<itemizedlist>
<listitem>
<para>-g : not run GUI (command line)</para>
</listitem>
<listitem>
<para>-L2: print out detail (level 2 of verbosity).</para>
</listitem>
</itemizedlist>
</sect3>
</sect2>
<sect2>
<title>Re-Building World</title>
<para>After installing FreeBSD patches, rebuild (compile) all the
program with dynamic library for save disk space.</para>
<para>Editing /etc/make.conf:</para>
<para><command>vi /etc/make.conf</command></para>
<para>Create /etc/make.conf and put the following lines in it:</para>
<para><code>NO_SHARED=no</code></para>
<para>Then use this commands for re-build all the source: (take some
long time)</para>
<para><command>cd /usr/src</command></para>
<para><command>make -j4 buildworld</command></para>
<para><command>make buildkernel</command></para>
<para><command>make installkernel</command></para>
<para><command>reboot (in single user mode: boot -s from the loader
prompt)</command></para>
<para><command>fsck -p</command></para>
<para><command>mount -u /</command></para>
<para><command>mount -a -t ufs</command></para>
<para><command>swapon -a</command></para>
<para><command>adjkerntz -i</command></para>
<para><command>mergemaster -p</command></para>
<para><command>cd /usr/src</command></para>
<para><command>make installworld</command></para>
<para><command>make delete-old</command></para>
<para><command>mergemaster</command></para>
<para><command>reboot</command></para>
<para><command>make delete-old-libs</command></para>
</sect2>
<sect2>
<title>Rebulding port</title>
<para>You can upgrade all installed port (and library) with this
command:</para>
<para><command>cd /usr/ports</command></para>
<para><command>make index</command></para>
<para><command>pkgadd -r portupgrade</command></para>
<para><command>portversion -l "<"</command></para>
<para><command>portupgrade -arR</command></para>
</sect2>
</sect1>
<sect1>
<title>FreeNAS</title>
<para>Here is I will explain how to install the tools and PHP script use
for FreeNAS...</para>
<para>If this instruction are not clear, download the last FreeNAS
rootfilesystem .tgz file and compare the difference with yours.</para>
<sect2>
<title>Define the system variables</title>
<sect3>
<title>Working dirs</title>
<para>First step, create the path variable:</para>
<para><command>export
WORKINGDIR="/usr/local/freenas"</command></para>
<para><command>export
FREENAS="/usr/local/freenas/rootfs"</command></para>
<para><command>export
BOOTDIR="/usr/local/freenas/bootloader"</command></para>
<para><command>export
CDROOT="/usr/local/freenas/cdroot"</command></para>
</sect3>
</sect2>
<sect2>
<title>Building the root file system</title>
<sect3>
<title>Create the working dir</title>
<para>Second step, create the working directory:</para>
<para><command>mkdir /usr/local/freenas</command></para>
<para><command>mkdir /usr/local/freenas/rootfs</command></para>
</sect3>
<sect3>
<title>Generating the minimum root filesytem</title>
<para>Use the script <ulink
url="http://freenas.org/downloads/freenas-create-dirs.sh">freenas-create-dirs.sh</ulink>
(don't forget to change the MINIBSD_DIR variable with your setting
before using it):</para>
<para><command>fetch
http://freenas.org/downloads/freenas-create-dirs.sh</command></para>
<para><command>./freenas-create-dirs.sh</command> it will create the
root dir for you...</para>
<para>Here is the content of this script:</para>
<programlisting>#!/bin/sh
#
# This script was written by David Courtney of Ultradesic
# http://www.ultradesic.com
# E-Mail Contact: minibsd@ultradesic.com
#
# Adapted for FreeNAS by Olivier Cochard-Labbé (http://www.freenas.org)
MINIBSD_DIR=/usr/local/freenas/rootfs ;
if [ -d $MINIBSD_DIR ] ; then
echo ;
echo "$MINIBSD_DIR already exists. Remove the directory" ;
echo "before running this script." ;
echo ;
echo "Exiting..." ;
echo ;
exit ;
fi ;
mkdir $MINIBSD_DIR ;
cd $MINIBSD_DIR ;
mkdir boot ;
mkdir boot/kernel ;
mkdir bin ;
mkdir cf ;
mkdir ftmp ;
mkdir conf.default ;
mkdir dev ;
mkdir etc ;
mkdir etc/defaults ;
mkdir etc/inc ;
mkdir etc/pam.d ;
mkdir etc/ssh ;
mkdir lib ;
mkdir libexec ;
mkdir -m 0777 mnt ;
mkdir -m 0700 root ;
mkdir sbin ;
mkdir usr ;
mkdir usr/bin ;
mkdir usr/lib ;
mkdir usr/lib/aout ;
mkdir usr/libexec ;
mkdir usr/local ;
mkdir usr/local/bin;
mkdir usr/local/lib ;
mkdir usr/local/sbin ;
mkdir usr/local/www ;
mkdir usr/sbin ;
mkdir usr/share ;
mkdir tmp;
# share/empty mandatory for VSFTPD
mkdir usr/share/empty ;
mkdir var ;
#ln -s var/tmp tmp
# Creating symbolic links
ln -s cf/conf conf
ln -s /var/run/htpasswd usr/local/www/.htpasswd
ln -s /var/etc/resolv.conf etc/resolv.conf
ln -s /var/etc/master.passwd etc/master.passwd
ln -s /var/etc/passwd etc/passwd
ln -s /var/etc/group etc/group
ln -s /var/etc/pwd.db etc/pwd.db
ln -s /var/etc/spwd.db etc/spwd.db
ln -s /var/etc/crontab etc/crontab
ln -s /var/etc/ssh/sshd_config etc/ssh/sshd_config
ln -s /var/etc/ssh/ssh_host_dsa_key etc/ssh/ssh_host_dsa_key
ln -s /var/etc/pam.d/ftp etc/pam.d/ftp
ln -s /var/etc/pam.d/sshd etc/pam.d/sshd
ln -s /var/etc/pam.d/login etc/pam.d/login
ln -s /var/etc/nsswitch.conf etc/nsswitch.conf
ln -s /libexec/ld-elf.so.1 usr/libexec/ld-elf.so.1</programlisting>
<para></para>
</sect3>
<sect3>
<title>Directory explanation</title>
<para>Here is the explanation of this directories:</para>
<itemizedlist>
<listitem>
<para>/cf is where the Compact Flash card (or the hard disk, or
the floppy disk) is mounted later on</para>
</listitem>
<listitem>
<para>/conf.default contains the factory default
config.xml</para>
</listitem>
<listitem>
<para>/conf (or /cf/conf effectively due to the symlink)
contains the current config.xml</para>
</listitem>
<listitem>
<para>/ftmp is used to mount a temporary memory file system
during a firmware upgrade through the webGUI</para>
</listitem>
<listitem>
<para>/etc/inc contains PHP include files that are used by both
the boot scripts and the webGUI</para>
</listitem>
<listitem>
<para>/usr/local/www contains the webGUI pages</para>
</listitem>
<listitem>
<para>the symbolic link for .htpasswd is required as the boot
scripts will write the webGUI user/password to
/var/run/htpasswd</para>
</listitem>
<listitem>
<para>/boot are used by fdisk ans bsdlabel</para>
</listitem>
<listitem>
<para>/boot/kernel will contain the kernel modules</para>
</listitem>
<listitem>
<para>This directory will become the root '/' on the FreeNAS OS,
then it's normal that the symbolics links use link as
'/var/etc/' (that is create when FreeNAS boot).</para>
</listitem>
</itemizedlist>
</sect3>
</sect2>
<sect2>
<title>Copying required binaries</title>
<para>Download the file <ulink
url="http://www.freenas.org/downloads/freenas.files">freenas.files</ulink>
that will be use with the <ulink
url="http://www.freenas.org/downloads/mkmini.pl">mkmini.pl</ulink>:</para>
<para><command>fetch
http://www.freenas.org/downloads/freenas.files</command></para>
<para><command>fetch
http://www.freenas.org/downloads/mkmini.pl</command></para>
<para>This file contain the list of all the binary files used for this
distribution.</para>
<para>Install Perl with this command:</para>
<para><command>pkg_add -r perl</command></para>
<para>Use the mkmini Perl script with this command (it will copy the
file listed in freenas.files in the root directory:</para>
<para><command>perl mkmini.pl freenas.files /
$FREENAS</command></para>
</sect2>
<sect2>
<title>Preparing /etc</title>
<sect3>
<title>Installing the etc archive and PHP configuration
scripts</title>
<para>Download the <ulink
url="http://www.freenas.org/downloads/freenas-etc.tgz">freenas-etc.tgz</ulink>
and decompress it in the $FREENAS/ directory:</para>
<para><command>fetch
http//www.freenas.org/downloads/freenas-etc.tgz</command></para>
<para><command>tar -xzf freenas-etc.tgz -C
$FREENAS/</command></para>
<para>Make sure that the rc.* files int etc/rc have the execute
permission bits set (chmod 755).</para>
</sect3>
<sect3>
<title>Additional Notes</title>
<para>After editing the $FREENAS/etc/master.passwd, generate
newpassword database (pwd.db and spwd.db)by this command:</para>
<para><command>pwd_mkdb -p -d $FREENAS/etc
$FREENAS/etc/master.passwd</command></para>
<para>For saving the file in a tgz, use this command:</para>
<para><command>tar cfvz freenas-etc.tgz
$FREENAS/etc/*</command></para>
</sect3>
<sect3>
<title>Configuring platform variable</title>
<para>Adding the version:</para>
<para><command>echo "0.67b" >
$FREENAS/etc/version</command></para>
<para>Adding the version build time:</para>
<para><command>date >
$FREENAS/etc/version.buildtime</command></para>
<para>Adding the platform:</para>
<para>/etc/platform identifies the platform for which the image is
built and is very important, as the PHP scripts use it to determine
e.g. how the configuration is to be stored or which options should
be available in the webGUI. Possible values are:</para>
<itemizedlist>
<listitem>
<para>generic-pc</para>
</listitem>
<listitem>
<para>generic-pc-cdrom</para>
</listitem>
</itemizedlist>
<para><command>echo "generic-pc-cdrom" >
$FREENAS/etc/platform</command></para>
</sect3>
<sect3>
<title>Config file: config.xml</title>
<para>Download the latest default config.xml from <ulink
url="http://www.freenas.org/downloads/config.xml">http://www.freenas.org/downloads/config.xml</ulink>
and put it in $FREENAS/conf.default/config.xml:</para>
<para><command>cd $FREENAS/conf.default/</command></para>
<para><command>fetch http://www.freenas.org/downloads/config.xml
</command></para>
</sect3>
<sect3>
<title>Zone Info</title>
<para>FreeBSD keeps time zone information files in
/usr/share/zoneinfo. In order to save space, m0n0wall uses a
stripped down version of the contents of that directory and keeps
them in a tarball....Then FreeNAS do the same. Download zoneinfo.tgz
from <ulink
url="http://www.freenas.org/downloads/zoneinfo.tgz">http://www.freenas/org/downloads/zoneinfo.tgz</ulink>
and place it in $FREENAS/usr/share/zoneinfo.tgz.</para>
<para><command>cd $FREENAS/usr/share/</command></para>
<para><command>fetch
http://www.freenas.org/downloads/zoneinfo.tgz</command></para>
</sect3>
</sect2>
<sect2>
<title>Building the kernel</title>
<sect3>
<title>Adding specials drivers: A100U2 U2W-SCSI-Controller</title>
<para>Here is <ulink
url="http://www.freenas.org/downloads/bsd4a100.zip">FreeBSD drivers
for A100 SCSI controller</ulink> (based on Initio 1060
chipset).</para>
<para>Download and install the drivers:</para>
<para><command>mkdir a100</command></para>
<para><command>cd a100</command></para>
<para><command>fetch
http://www.freenas.org/downloads/bsd4a100.zip</command></para>
<para><command>gunzip bsd4a100.zip</command></para>
<para><command>cp a100.* /usr/src/sys/pci</command></para>
<para><command>echo "pci/a100.c optional ihb device-driver" >>
/usr/src/sys/conf/files</command></para>
</sect3>
<sect3>
<title>Compiling and compressing the kernel</title>
<para>Download the <ulink
url="http://www.freenas.org/downloads/FREENAS">FreeNAS customized
FreeBSD 6.1 kernel configuration file</ulink> and copy it to
/sys/i386/conf:</para>
<para><command>cd /sys/i386/conf/</command></para>
<para><command>fetch
http://www.freenas.org/downloads/FREENAS</command></para>
<para>Then execute the following commands to compile the kernel and
modules:</para>
<para><command>config FREENAS</command></para>
<para><command>cd ../compile/FREENAS/</command></para>
<para><command>make cleandepend; make depend</command></para>
<para><command>make</command></para>
<para>Compress the kernel using gzip:</para>
<para><command>gzip -9 kernel</command></para>
<para>The kernel will be installed later, as it doesn't go directly
into the root file system.</para>
<remark>If you want to modify the config file (for including modules
for example), don't forget to delete the
/sys/i386/compile/FREENAS_GENERIC directory, and re-start the config
command.</remark>
<note>
<para>If you have error message about the device "ihb", the
drivers a100 is not correctly installed. You can remove this line
from the kernel config file if you don't need them.</para>
</note>
</sect3>
<sect3>
<title>Installing the modules</title>
<para>Copy some geom module (vinum, gpt, mirror, concact, etc..) and
ntfs and ext2fs modules:</para>
<para><command>cp
/sys/i386/compile/FREENAS_GENERIC/modules/usr/src/sys/modules/geom/geom_vinum/geom_vinum.ko
$FREENAS/boot/kernel</command></para>
<para><command>cp
/sys/i386/compile/FREENAS_GENERIC/modules/usr/src/sys/modules/geom/geom_stripe/geom_stripe.ko
$FREENAS/boot/kernel</command></para>
<para><command>cp
/sys/i386/compile/FREENAS_GENERIC/modules/usr/src/sys/modules/geom/geom_concat/geom_concat.ko
$FREENAS/boot/kernel</command></para>
<para><command>cp
/sys/i386/compile/FREENAS_GENERIC/modules/usr/src/sys/modules/geom/geom_mirror/geom_mirror.ko
$FREENAS/boot/kernel</command></para>
<para><command>cp
/sys/i386/compile/FREENAS_GENERIC/modules/usr/src/sys/modules/geom/geom_gpt/geom_gpt.ko
$FREENAS/boot/kernel</command></para>
<para><command>cp
/sys/i386/compile/FREENAS_GENERIC/modules/usr/src/sys/modules/ntfs/ntfs.ko
$FREENAS/boot/kernel</command></para>
<para><command>cp
/sys/i386/compile/FREENAS_GENERIC/modules/usr/src/sys/modules/ext2fs/ext2fs.ko
$FREENAS/boot/kernel/</command></para>
</sect3>
<sect3>
<title>Installing the mbr</title>
<para>Copy the mbr file (this file is used by fdisk for creating
bootable install disk):</para>
<para><command>cp /boot/mbr $FREENAS/boot/</command></para>
</sect3>
</sect2>
<sect2>
<title>Building the software package</title>
<para>Here the list of software compiled and added to FreeNAS. For
some packages, the standard "./configure && make &&
make install" procedure can be used; others need a few extra configure
options to produce a small binary.</para>
<sect3>
<title>PHP</title>
<para>PHP Download the latest version of PHP 4.4 from <ulink
url="http://www.php.net">http://www.php.net</ulink> and decompress
as usual. Build/install as follows:</para>
<para><command>./configure --without-mysql --without-pear
--with-openssl --enable-discard-path</command></para>
<para><command>make</command></para>
<para><command>install -s sapi/cgi/php
$FREENAS/usr/local/bin</command></para>
<para>Put the following in $FREENAS/usr/local/lib/php.ini:</para>
<para><code>magic_quotes_gpc = Off </code></para>
<para><code>magic_quotes_runtime = Off </code></para>
<para><code>max_execution_time = 0 </code></para>
<para><code>max_input_time = 180 </code></para>
<para><code>register_argc_argv = Off </code></para>
<para><code>file_uploads = On </code></para>
<para><code>upload_tmp_dir = /ftmp </code></para>
<para><code>upload_max_filesize = 16M </code></para>
<para><code>post_max_size = 20M </code></para>
<para><code>html_errors = Off </code></para>
<para><code>include_path = ".:/etc/inc:/usr/local/www"</code></para>
</sect3>
<sect3>
<title>mini_httpd</title>
<para>Download mini_httpd 1.19 from <ulink
url="http://www.acme.com/software/mini_httpd/mini_httpd-1.19.tar.gz">http://www.acme.com/software/mini_httpd/mini_httpd-1.19.tar.gz</ulink>
and extract.</para>
<para>A custom patch needs to be applied that:</para>
<itemizedlist>
<listitem>
<para>adds a limit to the number of concurrent connections to
prevent DoS attacks (since mini_httpd is a forking web
server)</para>
</listitem>
<listitem>
<para>adds captive portal mode support</para>
</listitem>
<listitem>
<para>sets SCRIPT_FILENAME (for php)</para>
</listitem>
<listitem>
<para>fixes a bug where mini_httpd would exit if a TCP
connection was closed before mini_httpd had a chance to handle
it (ECONNABORTED)</para>
</listitem>
<listitem>
<para>adds "index.php" to the list of index file names</para>
</listitem>
<listitem>
<para>makes the error pages much more plain</para>
</listitem>
<listitem>
<para>doesn't add a Server: header</para>
</listitem>
<listitem>
<para>patches the Makefile to build mini_httpd with SSL
support</para>
</listitem>
</itemizedlist>
<para>Download the patch:</para>
<para><command>fetch
http://www.freenas.org/downloads/mini_httpd.c.patch</command></para>
<para>Apply the patch, compile and install as follows:</para>
<para><command>patch < mini_httpd.c.patch</command></para>
<para><command>make</command> <command>install -s mini_httpd
$FREENAS/usr/local/sbin</command></para>
</sect3>
<sect3>
<title>Lighthttpd (NOT USED IN FreeNAS: Personnal Notes)</title>
<para>Download, compile and install Lighthttpd (that support
WebDAV):</para>
<para><command>fetch
http://www.lighttpd.net/download/lighttpd-1.4.11.tar.gz</command></para>
<para><command>tar zxvf lighttpd-1.4.11.tar.gz</command></para>
<para><command>cd lighttpd-1.4.11</command></para>
<para><command>./configure --sysconfdir=/var/etc/ --enable-lfs
--without-mysql --without-ldap --with-openssl
--without-lua</command></para>
<para><command>make</command></para>
<para><command>make</command> <command>install -s mini_httpd
$FREENAS/usr/local/sbin</command></para>
</sect3>
<sect3>
<title>clog</title>
<para>Get the <ulink
url="http://www.freenas.org/downloads/clog-1.0.1.tar.gz">clog
patch</ulink> and the <ulink
url="http://www.freenas.org/downloads/syslogd_clog-current.tgz">syslog
patched file</ulink> (from the Pfsense project):</para>
<para><command>cd /usr/src/usr.bin/</command></para>
<para><command>fetch
http://www.freenas.org/downloads/clog-1.0.1.tar.gz</command></para>
<para><command>fetch
http://www.freenas.org/downloads/syslogd_clog-current.tgz</command></para>
<para><command>tar zxvf clog-1.0.1.tar.gz</command></para>
<para><command>tar zxvf syslogd_clog-current.tgz</command></para>
<para><command>cd syslogd</command></para>
<para><command>make</command></para>
<para><command>install -s syslogd
$FREENAS/usr/sbin/</command></para>
<para><command>cd ../clog</command></para>
<para><command>gcc clog.c -o clog</command></para>
<para><command>install -s clog $FREENAS/usr/sbin/</command></para>
</sect3>
<sect3>
<title>MSNTP</title>
<para>Compile and install the MSNTP ports:</para>
<para><command>cd /usr/ports/net/msntp/</command></para>
<para><command>make</command></para>
<para><command>install -s work/msntp-1.6/msntp
$FREENAS/usr/local/bin/</command></para>
<para>Then create this script:</para>
<para><command>vi
$FREENAS/usr/local/bin/runmsntp.sh</command></para>
<para>And put this command in:</para>
<programlisting>#!/bin/sh
# write our PID to file
echo $$ > $1
# execute msntp in endless loop; restart if it
# exits (wait 1 second to avoid restarting too fast in case
# the network is not yet setup)
while true; do
/usr/local/bin/msntp -r -P no -l $2 -x $3 $4
sleep 1
done</programlisting>
<para>And change this permission:</para>
<para><command>chmod +x
$FREENAS/usr/local/bin/runmsntp.sh</command></para>
</sect3>
<sect3>
<title>ataidle</title>
<para>Compile and install the ataidle ports:</para>
<para><command>cd /usr/ports/sysutils/ataidle</command></para>
<para><command>make</command></para>
<para><command>install -s work/ataidle-0.9/ataidle
$FREENAS/usr/local/sbin/</command></para>
</sect3>
<sect3>
<title>iscsi initiator</title>
<para>Download, compile and install the iscsi initaor:</para>
<para><command>fetch
ftp://ftp.cs.huji.ac.il/users/danny/freebsd/iscsi-16.tar.bz2</command></para>
<para><command>tar zxvf iscsi-16.tar.bz2</command></para>
<para><command>cd sys</command></para>
<para><command>ln -s /sys/kern .</command></para>
<para><command>ln -s /sys/tools .</command></para>
<para><command>cd modules/iscsi_initiator</command></para>
<para><command>make clean</command></para>
<para><command>ln -s ../.. @</command></para>
<para><command>make</command></para>
<para><command>cp iscsi_initiator.ko
$FREENAS/boot/kernel/</command></para>
<para><command>cd ../../../iscontrol/</command></para>
<para><command>make</command></para>
<para><command>install -s iscontrol
$FREENAS/usr/local/sbin/</command></para>
</sect3>
<sect3>
<title>Vsftp (Must be replaced by FTP server that support
UTF-8)</title>
<para>Compile and install the port::</para>
<para><command>cd /usr/ports/ftp/vsftpd</command></para>
<para><command>make</command></para>
<para><command>Don't select the two options
proposed</command></para>
<para><command>install -s work/vsftpd-2.0.4/vsftpd
$FREENAS/usr/local/sbin/</command></para>
</sect3>
<sect3>
<title>Samba (CIFS server)</title>
<para>Get the last Samba source:</para>
<para><command>fetch
http://us2.samba.org/samba/ftp/samba-latest.tar.gz </command></para>
<para><command>tar zxvf samba-latest.tar.gz</command></para>
<para><command>cd samba-3.0.22/source/</command></para>
<para>Then configure and make the source:</para>
<para><command>./configure --without-cups --with-ads --disable-cups
--without-ads --with-pam --with-ldapsam --with-acl-support
--with-winbind --with-pam_smbpass --with-logfilebase=/var/log/samba
--with-piddir=/var/run --with-privatedir=/var/etc/private
--with-configdir=/var/etc --with-lockdir=/var/run
--with-piddir=/var/run</command></para>
<para><command>(Fix samba bug: add this option too)
--with-shared-modules=idmap_rid</command></para>
<para><command>make</command></para>
<para>install samba:</para>
<para><command>install -s bin/smbd
$FREENAS/usr/local/sbin/</command></para>
<para><command>install -s bin/nmbd
$FREENAS/usr/local/sbin/</command></para>
<para><command>install -s bin/winbindd
$FREENAS/usr/local/sbin/</command></para>
<para><command>install -s bin/smbpasswd
$FREENAS/usr/local/bin/</command></para>
<para><command>install -s bin/net
$FREENAS/usr/local/bin/</command></para>
<para><command>install -s nsswitch/nss_winbind.so
$FREENAS/usr/local/lib/</command></para>
<para><command>install -s nsswitch/nss_wins.so
$FREENAS/usr/local/lib/</command></para>
<para><command>install -s nsswitch/pam_winbind.so
$FREENAS/usr/local/lib/</command></para>
<para><command>ln -s $FREENAS/usr/local/lib/nss_winbind.so
$FREENAS/usr/local/lib/nss_winbind.so.1</command></para>
<para><command>mkdir
$FREENAS/usr/local/samba/lib/idmap</command></para>
<para><command>install -s bin/rid.so
$FREENAS/usr/local/samba/lib/idmap</command></para>
<para><command>mkdir $FREENAS/usr/local/lib/samba</command></para>
<para><command>mkdir
$FREENAS/usr/local/lib/samba/vfs</command></para>
<para><command>mkdir
$FREENAS/usr/local/lib/samba/charset</command></para>
<para><command>mkdir
$FREENAS/usr/local/lib/samba/rpc</command></para>
<para><command>mkdir
$FREENAS/usr/local/lib/samba/pdb</command></para>
<para><command>cp bin/CP*.so
$FREENAS/usr/local/lib/samba/charset</command></para>
<para><command>cp codepages/*.dat
$FREENAS/usr/local/lib/samba/</command></para>
<para><command>cp po/*.*
$FREENAS/usr/local/lib/samba/</command></para>
</sect3>
<sect3>
<title>NFS</title>
<para>Install the NFS server with this commands:</para>
<para><command>cp /usr/sbin/nfsd $FREENAS/usr/sbin</command></para>
<para><command>cp /usr/sbin/mountd
$FREENAS/usr/sbin</command></para>
<para><command>cp /usr/sbin/rpcbind
$FREENAS/usr/sbin</command></para>
</sect3>
<sect3>
<title>Netatalk</title>
<para>Netatalk need the Database Berkeley for being
compiling,</para>
<para>install the db 4. 2 port (or using "pkg_add -r db42") :</para>
<para><command>cd /usr/ports/databases/db42</command></para>
<para><command>make install</command></para>
<para>Then, download, compile and install netatalk:</para>
<para><command>fetch
http://ovh.dl.sourceforge.net/sourceforge/netatalk/netatalk-2.0.3.tar.gz
</command></para>
<para><command>tar zxvf netatalk-2.0.3.tar.gz</command></para>
<para><command>cd netatalk-2.0.3</command></para>
<para><command> ./configure --bindir=/usr/local/bin
--sbindir=/usr/local/sbin --sysconfdir=/var/etc --localstatedir=/var
--enable-largefile --disable-tcp-wrappers --disable-cups --with-pam
--with-uams-path=/etc/uams/</command></para>
<para><command>install -s etc/afpd/afpd
$FREENAS/usr/local/sbin/</command></para>
<para><command>mkdir $FREENAS/etc/uams</command></para>
<para><command>cp etc/uams/.libs/uams_passwd.so
$FREENAS/etc/uams</command></para>
<para><command>cp etc/uams/.libs/uams_dhx_passwd.so
$FREENAS/etc/uams</command></para>
<para><command>cp etc/uams/.libs/uams_guest.so
$FREENAS/etc/uams</command></para>
<para><command>cp etc/uams/.libs/uams_randnum.so
$FREENAS/etc/uams</command></para>
<para><command>cd $FREENAS/etc/uams</command></para>
<para><command>ln -s uams_passwd.so uams_clrtxt.so</command></para>
<para><command>ln -s uams_dhx_passwd.so uams_dhx.so</command></para>
<para><command>cd $FREENAS/usr/local/lib/</command></para>
<para><command>cp /usr/local/lib/libdb-4.2.so.2 .</command></para>
<para><command>cd $FREENAS/usr/lib/</command></para>
<para><command>cp /usr/lib/librpcsvc.so.3 .</command></para>
</sect3>
<sect3>
<title>RSYNC</title>
<para>Download, compile and install RSYNC:</para>
<para><command>fetch
http://samba.anu.edu.au/ftp/rsync/rsync-2.6.8.tar.gz</command></para>
<para><command>tar zxvf rsync-2.6.8.tar.gz</command></para>
<para><command>cd rsync-2.6.8</command></para>
<para><command>./configure
--with-rsyncd-conf=/var/etc</command></para>
<para><command>make</command></para>
<para><command>install -s rsync
$FREENAS/usr/local/bin/</command></para>
</sect3>
<sect3>
<title>scponly</title>
<para>Compile and install the scponly ports:</para>
<para><command>cd /usr/ports/shells/scponly/</command></para>
<para>Edit the Makefile, and add these lines:</para>
<para>WITH_SCPONLY_RSYNC=YES</para>
<para>WITH_SCPONLY_SCP=YES</para>
<para>WITH_SCPONLY_WINSCP=YES</para>
<para><command>make</command></para>
<para><command>install -s work/scponly-4.4/scponly
$FREENAS/usr/local/bin/</command></para>
</sect3>
<sect3>
<title>e2fsck</title>
<para>Compile and install the UPnP SDK ports:</para>
<para><command>cd /usr/ports/sysutils/e2fsprogs/</command></para>
<para><command>make</command></para>
<para><command>install -s work/e2fsprogs-1.38/e2fsck/e2fsck
$FREENAS/usr/local/sbin/</command></para>
</sect3>
<sect3>
<title>SMART tools</title>
<para>Compile the SMART tools ports:</para>
<para><command>cd
/usr/ports/sysutils/smartmontools/</command></para>
<para><command>make</command></para>
<para><command>install -s work/smartmontools-5.36/smartctl
$FREENAS/usr/local/sbin/</command></para>
<para><command>install -s work/smartmontools-5.36/smartd
$FREENAS/usr/local/sbin/</command></para>
</sect3>
<sect3>
<title>aaccli (only from the CLI for the moment)</title>
<para>Compile the aaccli ports:</para>
<para><command>cd /usr/ports/sysutils/aaccli/</command></para>
<para><command>make</command></para>
<para><command>tar zxvf work/aaccli-1.0_0.tgz</command></para>
<para><command>cp work/bin/aaccli
$FREENAS/usr/local/bin/</command></para>
</sect3>
<sect3>
<title>beep</title>
<para>Compile the beep ports:</para>
<para><command>cd /usr/ports/audio/beep</command></para>
<para><command>make</command></para>
<para><command>install -s work/beep/beep
$FREENAS/usr/local/bin/</command></para>
</sect3>
<sect3>
<title>mDNSReponder (bonjour)</title>
<para>Use the mDNSResponder port:</para>
<para><command>cd /usr/ports/net/mDNSResponder</command></para>
<para><command>make</command></para>
<para>Untar, compil and install it:</para>
<para><command>install -s
work/mDNSResponder-107.5/mDNSPosix/build/prod/mDNSResponderPosix
$FREENAS/usr/local/sbin/</command></para>
</sect3>
</sect2>
<sect2>
<title>Building the boot loader</title>
<para>Use the script <ulink
url="http://www.freenas.org/downloads/freenas-create-bootdir.sh">freenas-create-bootdir.sh</ulink>
(don't forget to edit it before for setting the directory) for
generating the file needed for booting.</para>
<para>Here is the contents of this script:</para>
<programlisting>#!/bin/sh
#
# This script was written by David Courtney of Ultradesic
# http://www.ultradesic.com
# E-Mail Contact: minibsd@ultradesic.com
#
# Adapted for m0n0wall on FreeBSD 6.1 by Olivier Cochard-Labbé (http://www.freenas.org)
MINIBSD_DIR=/usr/local/freenas/bootloader ;
if [ -d $MINIBSD_DIR ] ; then
echo ;
echo "$MINIBSD_DIR already exists. Remove the directory" ;
echo "before running this script." ;
echo ;
echo "Exiting..." ;
echo ;
exit ;
fi ;
# Create the boot directory that will contain boot, and kernel
mkdir $MINIBSD_DIR ;
mkdir $MINIBSD_DIR/defaults
mkdir $MINIBSD_DIR/kernel
# Copy the file in this directory:
cp /boot/defaults/loader.conf $MINIBSD_DIR/defaults
cp /boot/loader $MINIBSD_DIR
cp /boot/boot $MINIBSD_DIR
cp /boot/mbr $MINIBSD_DIR
cp /boot/cdboot $MINIBSD_DIR
cp /boot/loader.rc $MINIBSD_DIR
cp /boot/loader.4th $MINIBSD_DIR
cp /boot/support.4th $MINIBSD_DIR
cp /boot/device.hints $MINIBSD_DIR
# Generate the loader.conf file using by bootloader
echo "mfsroot_load=\"YES\"" > $MINIBSD_DIR/loader.conf
echo "mfsroot_type=\"mfs_root\"" >> $MINIBSD_DIR/loader.conf
echo "mfsroot_name=\"/mfsroot\"" >> $MINIBSD_DIR/loader.conf
echo "autoboot_delay=\"-1\"" >> $MINIBSD_DIR/loader.conf
cp /sys/i386/compile/FREENAS/kernel.gz $MINIBSD_DIR/kernel</programlisting>
<para></para>
<para><note>
<para>If you don't want to use ACPI:</para>
<para>Adding this line to the loader.rc:</para>
<para><code>set hint.acpi.0.disabled="1"</code></para>
<para>For debug mode, add this line:</para>
<para><code>verbose_loading="YES"</code></para>
<para><code>boot_verbose=""</code></para>
<para>For serial support, add this line:</para>
<para><code>console="comconsole"</code></para>
</note></para>
</sect2>
<sect2>
<title>Adding the libraries</title>
<para>None of the dynamically linked libraries that are needed have
been added yet. This is because a Perl script, <ulink
url="http://www.freenas.org/downloads/mklibs.pl">mklibs.pl</ulink>,
can be run on the root file system to create a list of libraries that
are actually needed (mklibs.pl does this by running ldd on each
binary).</para>
<para><command>fetch http://www.freenas.org/downloads/mklibs.pl
</command></para>
<para><command>perl mklibs.pl $FREENAS >
freenas.libs</command></para>
<para><command>perl mkmini.pl freenas.libs / $FREENAS</command></para>
<para>Adding the PAM library:</para>
<para><command>cp -p /usr/lib/pam_*.so.3
$FREENAS/usr/lib</command></para>
<para>The LDAP PAM are not bulding by default:</para>
<para><command>cd /usr/ports/security/pam_ldap/</command></para>
<para><command>make install</command></para>
<para><command>cp -p /usr/local/lib/pam_ldap.so
$FREENAS/usr/local/lib</command></para>
<para>This script forget to copy this mandatory library :</para>
<para><command>cp /libexec/ld-elf.so.1
$FREENAS/libexec</command></para>
</sect2>
<sect2>
<title>Adding Web GUI</title>
<para>Download the <ulink
url="http://www.freenas.org/downloads/freenas-gui.tgz">FreeNAS GUI
files</ulink> and copy them to $FREENAS/usr/local/www</para>
<para>Make sure that all *.php files have the execute permission bits
set (chmod 755).</para>
<para><command>fetch
http://www.freenas.org/downloads/freenas-gui.tgz</command></para>
<para><command>tar -zxvf freenas-gui.tgz -C $FREENAS</command></para>
</sect2>
<sect2>
<title>Creating msfroot</title>
<para>This step will create the compressed system image that will be
run from the RAM disk.</para>
<para>First of all, a zero-filled image file needs to be created. The
current size is 32 MB, which should be enough to fit all the files in
the root file system. If you add big components, you may need to
increase this. However, don't make it much bigger than necessary, as
the MFS will take up as much space as you specify here, even if the
file system is not full.</para>
<para>Use the script <ulink
url="http://freenas.org/downloads/freenas-create-msfroot.sh">freenas-create-msfroot.sh</ulink>
(don't forget to edit it before for setting the directory):</para>
<para><command>fetch
http://freenas.org/downloads/freenas-create-msfroot.sh</command></para>
<para><command>./freenas-create-msfroot.sh</command></para>
<para>Here is the contents of this script:</para>
<programlisting>#!/bin/sh
# Generate the mfs ROOT file system
#Setting directory
WORKINGDIR="/usr/local/freenas"
FREENAS="/usr/local/freenas/rootfs"
CDROOT="/usr/local/freenas/cdroot"
BOOTDIR="/usr/local/freenas/bootloader"
#lauching the script
# Remove old file
if [ $WORKINGDIR/mfsroot.gz ] ; then
echo ;
echo "mfsroot.gz already exists. Removing this file" ;
echo ;
rm $WORKINGDIR/mfsroot.gz;
#exit ;
fi ;
# umount the /mnt directory
umount /mnt
# Remove the memory file
mdconfig -d -u 0
# Create a 32Mb empty file
dd if=/dev/zero of=$WORKINGDIR/mfsroot bs=1k count=32768
# Configure this file as a virtual disk
mdconfig -a -t vnode -f $WORKINGDIR/mfsroot -u 0
# Create Label on this disk
bsdlabel -w md0 auto
# format it
newfs -b 8192 -f 1024 -o space -m 0 /dev/md0c
# Mount it
mount /dev/md0c /mnt
# Copy the file on it
cd /mnt
tar -cf - -C $FREENAS ./ | tar -xvpf -
cd $WORKINGDIR
# umount the /mnt directory
umount /mnt
# Remove the memory file
mdconfig -d -u 0
echo Compresing....
gzip -9 mfsroot</programlisting>
<para></para>
</sect2>
<sect2>
<title>Creating the image (for hard drive or CF)</title>
<para>This is very similar to creating the mfsroot.</para>
<para>Use the script <ulink
url="http://www.freenas.org/downloads/freenas-create-msfroot.sh">freenas-create-image.sh</ulink>
(don't forget to edit it before for setting the directory):</para>
<para><command>fetch
http://www.freenas.org/downloads/freenas-create-image.sh</command></para>
<para><command>./freenas-create-image.sh</command></para>
<para>it will create the image file for you...</para>
<para>Here is the content of this script:</para>
<programlisting>#!/bin/sh
# FreeNAS script for generating .img
# setting variables
FREENAS="/usr/local/freenas/rootfs"
WORKINGDIR="/usr/local/freenas"
CDROOT="/usr/local/freenas/imgroot"
BOOTDIR="/usr/local/freenas/bootloader"
PLATFORM="generic-pc"
VERSION=`cat $FREENAS/etc/version`
ISOFILENAME="FreeNAS-$PLATFORM-$VERSION.img"
# Remove old directory
if [ -d $CDROOT ] ; then
echo ;
echo "$CDROOT already exists. Removing this directory" ;
echo ;
echo ;
rm -rf $CDROOT;
#exit ;
fi ;
if [ $WORKINGDIR/$ISOFILENAME ] ; then
echo ;
echo "$ISOFILENAME already exists. Removing this directory" ;
echo ;
echo ;
rm $WORKINGDIR/$ISOFILENAME;
#exit ;
fi ;
echo $PLATFORM > $FREENAS/etc/platform
date > $FREENAS/etc/version.buildtime
$WORKINGDIR/freenas-create-mfsroot.sh
echo Generating $CDROOT folder
mkdir $CDROOT
#Creating a 16Mb empty file
dd if=/dev/zero of=image.bin bs=1k count=18432
#use this file as a virtual RAM disk
mdconfig -a -t vnode -f image.bin -u 0
#Create partition on this disk
fdisk -BI -b $BOOTDIR/mbr /dev/md0
#Create label on this disk
bsdlabel -B -w -b $BOOTDIR/boot /dev/md0 auto
bsdlabel md0 >/tmp/label.$$
bsdlabel md0 |
egrep unused |
sed "s/c:/a:/" |
sed "s/unused/4.2BSD/" >>/tmp/label.$$
bsdlabel -R -B md0 /tmp/label.$$
rm -f /tmp/label.$$
#Create filesystem on this disk
newfs -b 8192 -f 1024 -o space -m 0 /dev/md0a
#Mount this disk
mount /dev/md0a $CDROOT
cp $WORKINGDIR/mfsroot.gz $CDROOT
mkdir $CDROOT/boot
mkdir $CDROOT/boot/kernel $CDROOT/boot/defaults
mkdir $CDROOT/conf
cp $FREENAS/conf.default/config.xml $CDROOT/conf
cp $BOOTDIR/kernel/kernel.gz $CDROOT/boot/kernel
cp $BOOTDIR/boot $CDROOT/boot
cp $BOOTDIR/loader $CDROOT/boot
cp $BOOTDIR/loader.conf $CDROOT/boot
cp $BOOTDIR/loader.rc $CDROOT/boot
cp $BOOTDIR/loader.4th $CDROOT/boot
cp $BOOTDIR/support.4th $CDROOT/boot
cp $BOOTDIR/defaults/loader.conf $CDROOT/boot/defaults/
cp $BOOTDIR/device.hints $CDROOT/boot
umount $CDROOT
mdconfig -d -u 0
gzip -9 image.bin
mv image.bin.gz $ISOFILENAME
# Cleaning directory and temp file
if [ $WORKINGDIR/mfsroot.gz ] ; then
echo ;
echo "cleaning mfsroot.gz" ;
echo ;
rm $WORKINGDIR/mfsroot.gz
fi;
if [ -d $CDROOT ] ; then
echo ;
echo "cleaning $CDROOT by Removing this directory" ;
echo ;
echo ;
rm -rf $CDROOT;
fi ;</programlisting>
</sect2>
<sect2>
<title>Creating CD-ROM</title>
<sect3>
<title>Installing CDRTools</title>
<para>Before to create a Bootable CD, we must install
CRDTools:</para>
<para><command>cd /usr/ports/sysutils/cdrtools</command></para>
<para><command>make</command></para>
<para><command>make install</command></para>
</sect3>
<sect3>
<title>Create the bootable ISO file</title>
<para>Use the script <ulink
url="http://www.freenas.org/downloads/freenas-create-msfroot.sh">freenas-create-cd.sh</ulink>
(don't forget to edit it before for setting the directory):</para>
<para><command>fetch
http://www.freenas.org/downloads/freenas-create-cd.sh</command></para>
<para><command>./freenas-create-cd.sh</command></para>
<para>it will create the bootable CD ISO file for you...</para>
<para>Here is the content of this file:</para>
<programlisting>#!/bin/sh
# FreeNAS script for generating iso file
FREENAS="/usr/local/freenas/rootfs"
WORKINGDIR="/usr/local/freenas"
CDROOT="/usr/local/freenas/cdroot"
BOOTDIR="/usr/local/freenas/bootloader"
PLATFORM="generic-pc-cdrom"
VERSION=`cat $FREENAS/etc/version`
ISOFILENAME="FreeNAS-$VERSION.iso"
#remove old directory
if [ -d $CDROOT ] ; then
echo ;
echo "$CDROOT already exists. Removing this directory" ;
echo "before running this script." ;
echo ;
#echo "Exiting..." ;
echo ;
rm -rf $CDROOT;
#exit ;
fi ;
echo "$PLATFORM" > $FREENAS/etc/platform
date > $FREENAS/etc/version.buildtime
$WORKINGDIR/freenas-create-mfsroot.sh
rm $WORKINGDIR/$ISOFILENAME
echo Generating $CDROOT folder
mkdir $CDROOT
cp $WORKINGDIR/mfsroot.gz $CDROOT
mkdir $CDROOT/boot
mkdir $CDROOT/boot/kernel $CDROOT/boot/defaults
cp $BOOTDIR/kernel/kernel.gz $CDROOT/boot/kernel
cp $BOOTDIR/cdboot $CDROOT/boot
cp $BOOTDIR/loader $CDROOT/boot
cp $BOOTDIR/loader.conf $CDROOT/boot
cp $BOOTDIR/loader.rc $CDROOT/boot
cp $BOOTDIR/loader.4th $CDROOT/boot
cp $BOOTDIR/support.4th $CDROOT/boot
cp $BOOTDIR/defaults/loader.conf $CDROOT/boot/defaults/
cp $BOOTDIR/device.hints $CDROOT/boot
###### BEGIN: NEW RELEASE CHANGE ######
$WORKINGDIR/freenas-create-image.sh
cp $WORKINGDIR/FreeNAS-generic-pc-$VERSION.img $CDROOT/FreeNAS-generic-pc.gz
###### END: NEW RELEASE CHANGE ######
mkisofs -b "boot/cdboot" -no-emul-boot -A "FreeNAS CD-ROM image" -c "boot/boot.catalog" -d -r -publisher "freenas.org" -p "Olivier Cochard" -V "freenas_cd" -o "$ISOFILENAME" $CDROOT
if [ -d $CDROOT ] ; then
echo ;
echo "Cleaning directory" ;
echo ;
echo ;
rm -rf $CDROOT;
rm mfsroot.gz;
#exit ;
fi ;
</programlisting>
<para></para>
</sect3>
</sect2>
<sect2>
<title>PXE Boot (to be Finish)</title>
<sect3>
<title>Long way</title>
<para>Create the tftpboot folder:</para>
<para><command>mkdir /tftpboot</command></para>
<para><command>$TFTPBOOT=/tftpboot</command></para>
<para><command>export TFTBOOT</command></para>
<para><command></command></para>
<para>Recompile the PXE boot loader for booting from TFTP in the
place of NFS:</para>
<para><command>cd /sys/boot</command></para>
<para><command>make clean</command></para>
<para><command>make LOADER_TFTP_SUPPORT=yes</command></para>
<para><command>cp /usr/obj/usr/src/sys/boot/i386/pxeldr/pxeboot
$TFTPBOOT</command></para>
<para><command>cp mfsroot.gz $TFTPBOOT</command></para>
<para>Create a new directory to hold the contents of the CD-ROM in
$CDROOT.</para>
<para>Then copying the file on the /tftpboot folder:</para>
<para>cp $BOOTDIR/kernel/kernel.gz $TFTPBOOT/boot/kernel</para>
<para>cp $BOOTDIR/kernel/acpi.ko $TFTPBOOT/boot/kernel</para>
<para></para>
</sect3>
</sect2>
</sect1>
</chapter>
<chapter>
<title>FreeNAS in details (TO BE FINISH)</title>
<sect1>
<title>Initial startup script</title>
<para>This section describe the scripts in /etc and /etc/inc</para>
<sect2>
<title>Files lists</title>
<para>Here are the files used:</para>
<table>
<title>Startup files listing</title>
<tgroup cols="3">
<tbody>
<row>
<entry align="center">dir</entry>
<entry align="center">filename</entry>
<entry align="center">description</entry>
</row>
<row>
<entry></entry>
<entry>config.xml</entry>
<entry>XML configuration file</entry>
</row>
<row>
<entry>/etc/</entry>
<entry>rc</entry>
<entry>First launched script</entry>
</row>
<row>
<entry>/etc/</entry>
<entry>rc.bootup</entry>
<entry>Launch all the services.</entry>
</row>
<row>
<entry>/etc/</entry>
<entry>rc.banner</entry>
<entry>Display version and IP information</entry>
</row>
<row>
<entry>/etc/</entry>
<entry>rc.initial</entry>
<entry>Configuration menu</entry>
</row>
<row>
<entry>/etc/</entry>
<entry>rc.initial.setports</entry>
<entry>Link physical interface with name</entry>
</row>
<row>
<entry>/etc/</entry>
<entry>rc.initial.setlanip</entry>
<entry>Configure the IP adress of "lan" interface</entry>
</row>
<row>
<entry>/etc/</entry>
<entry>rc.initial.password</entry>
<entry>Reset the password for WebGUI</entry>
</row>
<row>
<entry>/etc/</entry>
<entry>rc.initial.defaults</entry>
<entry>reset the configuration</entry>
</row>
<row>
<entry>/etc/</entry>
<entry>rc.initial.reboot</entry>
<entry>Reboot the system</entry>
</row>
<row>
<entry>/etc/</entry>
<entry>rc.initial.ping</entry>
<entry>Ping an IP adress</entry>
</row>
<row>
<entry>/etc/</entry>
<entry>rc.initial.install</entry>
<entry>Install FreeNAS on harddrive or CF</entry>
</row>
<row>
<entry>/etc/inc/</entry>
<entry>global.inc</entry>
<entry>Set the global variable</entry>
</row>
<row>
<entry>/etc/inc/</entry>
<entry>config.inc</entry>
<entry>Parse the config file</entry>
</row>
<row>
<entry>/etc/inc/</entry>
<entry>functions.inc</entry>
<entry>Group the files</entry>
</row>
<row>
<entry>/etc/inc/</entry>
<entry>xmlparse.inc</entry>
<entry>Parse the XML config file</entry>
</row>
<row>
<entry>/etc/inc/</entry>
<entry>util.inc</entry>
<entry>Lot's of utilities</entry>
</row>
<row>
<entry>/etc/inc/</entry>
<entry>system.inc</entry>
<entry>Configure system part (hostname, hosts,etc..)</entry>
</row>
<row>
<entry>/etc/inc/</entry>
<entry>interface.inc</entry>
<entry>Configure interface (loopack, Ethernet, etc..)</entry>
</row>
<row>
<entry>/etc/inc/</entry>
<entry>disks.inc</entry>
<entry>Manage disk and mount point</entry>
</row>
<row>
<entry>/etc/inc/</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry>/etc/inc/</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry>/etc/inc/</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry>/etc/inc/</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry>/etc/inc/</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry>/etc/inc/</entry>
<entry></entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
<sect2>
<title>Scripts description</title>
<sect3>
<title>rc</title>
<sect4>
<title>Description</title>
<para>It's the first script start.</para>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>set the PATH and HOME variable</para>
</listitem>
<listitem>
<para>TESTING: Force the mount of / to RW</para>
</listitem>
<listitem>
<para>Make some directory in /var</para>
</listitem>
<listitem>
<para>Adjust local time CMOS clock to reflect time zone
changes and keep current timezone offset for the kernel</para>
</listitem>
<listitem>
<para>Create an initial utmp file</para>
</listitem>
<listitem>
<para>Run ldconfig</para>
</listitem>
<listitem>
<para>launch /etc/rc.bootup</para>
</listitem>
<listitem>
<para>launch /etc/rc.banner</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>rc.bootup</title>
<sect4>
<title>Description</title>
<para>This script launch all the services.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>global.inc</para>
</listitem>
<listitem>
<para>config.inc</para>
</listitem>
<listitem>
<para>functions.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<para>Here is what it does exactly:</para>
<orderedlist>
<listitem>
<para>It set the “Booting” variable</para>
</listitem>
<listitem>
<para>Parse all the configuration (with config.inc)</para>
</listitem>
<listitem>
<para>Launch all the starting functions (with
functions.inc)</para>
</listitem>
<listitem>
<para>Unset the “booting” variable</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>rc.banner</title>
<sect4>
<title>Description</title>
<para>This script display version and IP information.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>config.inc</para>
</listitem>
<listitem>
<para>functions.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Get the version and bultime in /etc/version and
/etc/builtime</para>
</listitem>
<listitem>
<para>Display this information</para>
</listitem>
<listitem>
<para>Display all IP information for all interface</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>rc.initial</title>
<sect4>
<title>Description</title>
<para>This script display the console menu and launch the initial
configuration script.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>None.</para>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Check if console is disabled</para>
</listitem>
<listitem>
<para>Display the menu</para>
</listitem>
<listitem>
<para>Launch the initial script from menu selected</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>rc.initial.setports</title>
<sect4>
<title>Description</title>
<para>This script is launched by the menu (rc.initial) and
configure link the physical interface with a name.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>config.inc</para>
</listitem>
<listitem>
<para>functions.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Use get_interface_list()</para>
</listitem>
<listitem>
<para>Ask for configuring Vlan</para>
</listitem>
<listitem>
<para>Ask for interface name</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>rc.initial.setlanip</title>
<sect4>
<title>Description</title>
<para>This script is launched by the menu (rc.initial) and
configure the IP of the interface "lan".</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>config.inc</para>
</listitem>
<listitem>
<para>functions.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Ask the IP address and test the result with
is_ipaddr()</para>
</listitem>
<listitem>
<para>Ask the Subnet Mask and test the result with
is_numeric() and between 1 and 31</para>
</listitem>
<listitem>
<para>If the Web interface is in HTTPS mode, ask for HTTP mode
(Why??)</para>
</listitem>
<listitem>
<para>Save the configuration: write_config()</para>
</listitem>
<listitem>
<para>Configure the IP adresse:
interfaces_lan_configure()</para>
</listitem>
<listitem>
<para>Display the new IP adress</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>rc.initial.password</title>
<sect4>
<title>Description</title>
<para>This script is launched by the menu (rc.initial) reset the
password to the default.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>config.inc</para>
</listitem>
<listitem>
<para>functions.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Ask for confirmation</para>
</listitem>
<listitem>
<para>Change the password</para>
</listitem>
<listitem>
<para>Save the configuration: write_config()</para>
</listitem>
<listitem>
<para>Configure the password:
system_password_configure()</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>rc.initial.defaults</title>
<sect4>
<title>Description</title>
<para>This script is launched by the menu (rc.initial) reset the
configuration file.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>config.inc</para>
</listitem>
<listitem>
<para>functions.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Ask for confirmation</para>
</listitem>
<listitem>
<para>Reset the configuration: reset_factory_defaults()</para>
</listitem>
<listitem>
<para>Reboot the system: system_reboot_sync()</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>rc.initial.reboot</title>
<sect4>
<title>Description</title>
<para>This script is launched by the menu (rc.initial) reboot the
system.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>config.inc</para>
</listitem>
<listitem>
<para>functions.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Ask for confirmation</para>
</listitem>
<listitem>
<para>Reboot the system: system_reboot_sync()</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>rc.initial.ping</title>
<sect4>
<title>Description</title>
<para>This script is launched by the menu (rc.initial) ping an IP
adress.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>config.inc</para>
</listitem>
<listitem>
<para>functions.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Ask for the IP adress</para>
</listitem>
<listitem>
<para>Launch the external ping command</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>rc.initial.install</title>
<sect4>
<title>Description</title>
<para>This script is launched by the menu (rc.initial) install
FreeNAS on an harddrive or CF.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>config.inc</para>
</listitem>
<listitem>
<para>functions.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Display the ATA drive detected: external command
"atacontrol list"</para>
</listitem>
<listitem>
<para>Ask for the CD-ROM drive name</para>
</listitem>
<listitem>
<para>Ask for the harddrive/CF name</para>
</listitem>
<listitem>
<para>Mount the CD-ROM drive: external commad
"mount_cd9660"</para>
</listitem>
<listitem>
<para>Copy the FreeNAS image to the ATA drive: external
command "gunzip ||dd"</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>disk.inc</title>
<para>This script manage disk detection and volume mountage.</para>
<para>TO DO:</para>
<para>- Using dmesg message for adding information to a
variable?</para>
<para>- Detecte physical disks and partitions.</para>
<para>- Menu disk: Put in variable the formattet result of
(atacontrol list ) the line that contain "ad" only.</para>
<para>- Menu partition, (fdisk) where we see all the existing
partitions, create, mount, etc....</para>
<para></para>
<sect4>
<title>Description</title>
<para>This script manage the detected disks:</para>
<para>- Saving disk detection information in XML</para>
<para>- For check missing disk after a reboot ?</para>
<para>- Create directory /mnt/device</para>
<para>- mount the device configured in</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>config.inc</para>
</listitem>
<listitem>
<para>functions.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Ask for confirmation</para>
</listitem>
<listitem>
<para>Change the password</para>
</listitem>
<listitem>
<para>Save the configuration: write_config()</para>
</listitem>
<listitem>
<para>Configure the password:
system_password_configure()</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>global.inc</title>
<sect4>
<title>Description</title>
<para>This script defines the global variables (paths, etc) in
array variable $g.</para>
</sect4>
</sect3>
<sect3>
<title>config.inc</title>
<sect4>
<title>Description</title>
<para>This script looks for and loads the XML config file.</para>
<para>It defines some functions too.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>global.inc</para>
</listitem>
<listitem>
<para>util.inc</para>
</listitem>
<listitem>
<para>xmlparse.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Get the platform type: cdrom, cf, etc…</para>
</listitem>
<listitem>
<para>If we are in « booting » mode then it :</para>
<orderedlist>
<listitem>
<para>Look for the file “config.xml” on all possible
storage place</para>
</listitem>
<listitem>
<para>Write the storage place in the file “cfdevice »
(whitch is use by the upgrade script «
rc.firmware”)</para>
</listitem>
<listitem>
<para>Create the fstab with the partition containing the
file “config.xml”</para>
</listitem>
<listitem>
<para>Mount all filesystem</para>
</listitem>
</orderedlist>
</listitem>
<listitem>
<para>In parse mode (variable “noparseconfig” NOT set):</para>
<orderedlist>
<listitem>
<para>Lock the config filen: config_lock()</para>
</listitem>
<listitem>
<para>If there is a config.xml in the cache : use it, else
:</para>
<orderedlist>
<listitem>
<para>In “cdrom” and “booting”: Ask for insering a
floppy disk for the configuration save and
reset_factory_defaults()</para>
</listitem>
</orderedlist>
</listitem>
<listitem>
<para>Load the config.xml in the variable $config :
parse_xml_config()</para>
</listitem>
<listitem>
<para>Test the config file version : Display a warning if
the config file is more recent than m0n0wall</para>
</listitem>
<listitem>
<para>Create the config cache</para>
</listitem>
<listitem>
<para>Unlock the config file: config_unlock()</para>
</listitem>
<listitem>
<para>make alias table (for faster lookups):
alias_make_table()</para>
</listitem>
</orderedlist>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>xmlparse.inc</title>
<sect4>
<title>Description</title>
<para>This script looks for and loads the XML config file.</para>
<para>It defines some functions too.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>global.inc</para>
</listitem>
<listitem>
<para>util.inc</para>
</listitem>
<listitem>
<para>xmlparse.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Get the platform type: cdrom, cf, etc…</para>
</listitem>
<listitem>
<para>If we are in « booting » mode then it :</para>
<orderedlist>
<listitem>
<para>Look for the file “config.xml” on all possible
storage place</para>
</listitem>
<listitem>
<para>Write the storage place in the file “cfdevice »
(whitch is use by the upgrade script «
rc.firmware”)</para>
</listitem>
<listitem>
<para>Create the fstab with the partition containing the
file “config.xml”</para>
</listitem>
<listitem>
<para>Mount all filesystem</para>
</listitem>
</orderedlist>
</listitem>
<listitem>
<para>In parse mode (variable “noparseconfig” NOT set):</para>
<orderedlist>
<listitem>
<para>Lock the config filen: config_lock()</para>
</listitem>
<listitem>
<para>If there is a config.xml in the cache : use it, else
:</para>
<orderedlist>
<listitem>
<para>In “cdrom” and “booting”: Ask for insering a
floppy disk for the configuration save and
reset_factory_defaults()</para>
</listitem>
</orderedlist>
</listitem>
<listitem>
<para>Load the config.xml in the variable $config :
parse_xml_config()</para>
</listitem>
<listitem>
<para>Test the config file version : Display a warning if
the config file is more recent than m0n0wall</para>
</listitem>
<listitem>
<para>Create the config cache</para>
</listitem>
<listitem>
<para>Unlock the config file: config_unlock()</para>
</listitem>
<listitem>
<para>make alias table (for faster lookups):
alias_make_table()</para>
</listitem>
</orderedlist>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>system.inc</title>
<sect4>
<title>Description</title>
<para>This script defined all the function called “system_*” that
are used for the configuration of the system itself (hostname,
syslog, routing, etc…).</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>function.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>Here is the list of defined functions:</para>
<para></para>
<table>
<title>Functions lists</title>
<tgroup cols="2">
<tbody>
<row>
<entry align="center">Name</entry>
<entry align="center">Descriptions</entry>
</row>
<row>
<entry>system_resolvconf_generate()</entry>
<entry>Generate the resolv.conf file</entry>
</row>
<row>
<entry>system_hosts_generate()</entry>
<entry>Generate the hosts file</entry>
</row>
<row>
<entry>system_hostname_configure()</entry>
<entry>Configure the hostname</entry>
</row>
<row>
<entry>system_routing_configure()</entry>
<entry>Clean up and install IP routes</entry>
</row>
<row>
<entry>system_routing_enable()</entry>
<entry>Enable IP forwarding</entry>
</row>
<row>
<entry>system_syslogd_start()</entry>
<entry>Generate the syslog file and process</entry>
</row>
<row>
<entry>system_pccard_start()</entry>
<entry>Launch PCcard service</entry>
</row>
<row>
<entry>system_webgui_start()</entry>
<entry>Configure and start mini_httpd</entry>
</row>
<row>
<entry>system_password_configure()</entry>
<entry>Generate the htpasswd file</entry>
</row>
<row>
<entry>system_timezone_configure()</entry>
<entry>Generate /etc/local/timezone</entry>
</row>
<row>
<entry>system_ntp_configure()</entry>
<entry>Start ntp client with the timeserver
configured</entry>
</row>
<row>
<entry>system_reboot()</entry>
<entry></entry>
</row>
<row>
<entry>system_reboot_sync()</entry>
<entry></entry>
</row>
<row>
<entry>system_reboot_cleanup()</entry>
<entry></entry>
</row>
<row>
<entry>system_do_shell_commands()</entry>
<entry></entry>
</row>
<row>
<entry>system_do_extensions()</entry>
<entry></entry>
</row>
<row>
<entry>system_console_configure()</entry>
<entry></entry>
</row>
<row>
<entry>system_dmesg_save()</entry>
<entry>Save dmesg to dmesg.boot</entry>
</row>
<row>
<entry>system_set_harddisk_standby()</entry>
<entry></entry>
</row>
<row>
<entry>system_polling_configure()</entry>
<entry></entry>
</row>
<row>
<entry>system_set_termcap()</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
</sect4>
</sect3>
<sect3>
<title>functions.inc</title>
<sect4>
<title>Description</title>
<para>This script load all the functions listed above.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>system.inc</para>
</listitem>
<listitem>
<para>interfaces.inc</para>
</listitem>
<listitem>
<para>services.inc</para>
</listitem>
</itemizedlist>
</sect4>
</sect3>
</sect2>
</sect1>
<sect1>
<title>Web Interface</title>
<para>This section describe the PHP file in /usr/local/www</para>
<sect2>
<title>Files lists</title>
<para></para>
<table>
<title>Files lists</title>
<tgroup cols="2">
<colspec align="center" />
<thead>
<row>
<entry align="center">name</entry>
<entry align="center">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left">index.php</entry>
<entry>Start page that display system information</entry>
</row>
<row>
<entry align="left">fbegin.inc</entry>
<entry>Page header and Left menu</entry>
</row>
<row>
<entry align="left">fend.inc</entry>
<entry>Page food (link to licence)</entry>
</row>
<row>
<entry align="left">guiconfig.inc</entry>
<entry>Define global variable and functions</entry>
</row>
<row>
<entry align="left">disks_show.php</entry>
<entry>Display detected phyisical disks</entry>
</row>
<row>
<entry align="left">isks_mount.php</entry>
<entry>Display the mount point</entry>
</row>
<row>
<entry align="left">disks_mount_edit.php</entry>
<entry>Add a mount point</entry>
</row>
<row>
<entry align="left">disks_tools.php</entry>
<entry>Provide some tools: Format, check, etc..</entry>
</row>
<row>
<entry align="left"></entry>
<entry></entry>
</row>
<row>
<entry align="left"></entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
<sect2>
<title>Scripts descriptions</title>
<para></para>
<sect3>
<title>index.php</title>
<sect4>
<title>Description</title>
<para>This is the start page that display some system
information.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>guiconfig.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Include fbegin.inc</para>
</listitem>
<listitem>
<para>display some system information</para>
</listitem>
<listitem>
<para>Include fend.inc</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>fbegin.inc</title>
<sect4>
<title>Description</title>
<para>This page display the header and the left menu.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>none</para>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>display the hostname on the page header</para>
</listitem>
<listitem>
<para>display the left menu</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>fend.inc</title>
<sect4>
<title>Description</title>
<para>This page is the page fooder: display the copyright and the
link to the licence</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>none</para>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>display the copyright and the link to the licence
page</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>guiconfig.inc</title>
<sect4>
<title>Description</title>
<para>This file define the global variable and functions that will
be used with the other pages.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>config.inc</para>
</listitem>
<listitem>
<para>functions.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Define the header for no caching</para>
</listitem>
<listitem>
<para>Define the dirty path</para>
</listitem>
<listitem>
<para>Define lot's of common variable</para>
</listitem>
<listitem>
<para>Define lot's of functions</para>
</listitem>
</orderedlist>
</sect4>
<sect4>
<title>Functions define</title>
<para></para>
<table>
<title>List of functions define in guiconfig.inc</title>
<tgroup cols="2">
<colspec align="center" />
<thead>
<row>
<entry align="center">name</entry>
<entry align="center">description</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left">do_input_validation($postdata,
$reqdfields, $reqdfieldsn, $input_errors)</entry>
<entry>check for bad control characters</entry>
</row>
<row>
<entry
align="left">print_input_errors($input_errors)</entry>
<entry></entry>
</row>
<row>
<entry align="left">exec_rc_script($scriptname)</entry>
<entry></entry>
</row>
<row>
<entry
align="left">exec_rc_script_async($scriptname)</entry>
<entry></entry>
</row>
<row>
<entry align="left">verify_gzip_file($fname)</entry>
<entry></entry>
</row>
<row>
<entry align="left">print_info_box_np($msg)</entry>
<entry></entry>
</row>
<row>
<entry align="left">print_info_box($msg)</entry>
<entry></entry>
</row>
<row>
<entry align="left">format_bytes($bytes)</entry>
<entry></entry>
</row>
<row>
<entry align="left">get_std_save_message($ok)</entry>
<entry></entry>
</row>
<row>
<entry align="left">pprint_address($adr)</entry>
<entry></entry>
</row>
<row>
<entry align="left">pprint_port($port)</entry>
<entry></entry>
</row>
<row>
<entry align="left">filter_rules_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">nat_rules_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">nat_1to1_rules_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">nat_server_rules_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">nat_out_rules_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">pptpd_users_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">captiveportal_users_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">staticroutes_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">hosts_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">domainoverrides_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">staticmaps_sort($if)</entry>
<entry></entry>
</row>
<row>
<entry align="left">aliases_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">ipsec_mobilekey_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">proxyarp_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">passthrumacs_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">allowedips_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">wol_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left">ipsec_ca_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left"></entry>
<entry></entry>
</row>
<row>
<entry align="left">mount_sort()</entry>
<entry></entry>
</row>
<row>
<entry align="left"></entry>
<entry></entry>
</row>
<row>
<entry align="left"></entry>
<entry></entry>
</row>
<row>
<entry align="left"></entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
</sect4>
</sect3>
<sect3>
<title>disks_show.php</title>
<sect4>
<title>Description</title>
<para>This page display the detected ATA and SCSI drive
detected.</para>
<para>It will be use for check that the hardware RAID disks are
invisible to FreeNAS (because managed by the RAID Bios).</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>guiconfig.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Display the result of "atacontrol list" and "camcontrol
devlist -v" command</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>disks_mount.php</title>
<sect4>
<title>Description</title>
<para>This page display the configured mount point.</para>
<para>Bug: the < and > character are bad interpreted in
HTML. Must use htmlspecialchar().</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>guiconfig.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Display the result of "atacontrol list" and "camcontrol
devlist -v" command (OR use the config file, and show NEW and
MISSING disks)</para>
</listitem>
<listitem>
<para>Link to ADD/REMOVE disks</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>disks_mount_edit.php</title>
<sect4>
<title>Description</title>
<para>This page permit to add/edit a mount point</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>guiconfig.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Ask for mount information: device, fstype and
options</para>
</listitem>
</orderedlist>
</sect4>
</sect3>
<sect3>
<title>disks_tools.php</title>
<sect4>
<title>Description</title>
<para>This page offer this service: format and chek an hard
drive.</para>
</sect4>
<sect4>
<title>Requirements</title>
<para>This script "require once":</para>
<itemizedlist>
<listitem>
<para>guiconfig.inc</para>
</listitem>
</itemizedlist>
</sect4>
<sect4>
<title>Algorithm</title>
<para>This script does:</para>
<orderedlist>
<listitem>
<para>Display the result of "atacontrol list" and "camcontrol
devlist -v" command</para>
</listitem>
<listitem>
<para></para>
</listitem>
</orderedlist>
</sect4>
</sect3>
</sect2>
</sect1>
</chapter>
</book>