<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>funcptr - FreeBSD</title>
    <subtitle>An engineer&#x27;s technical notebook</subtitle>
    <link rel="self" type="application/atom+xml" href="https://funcptr.net/os/freebsd/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://funcptr.net/"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2013-12-11T00:10:11+00:00</updated>
    <id>https://funcptr.net/os/freebsd/atom.xml</id>
    <entry xml:lang="en">
        <title>Building custom ports with Poudriere and Portshaker</title>
        <published>2013-12-11T00:10:11+00:00</published>
        <updated>2013-12-11T00:10:11+00:00</updated>
        
        <author>
          <name>
            Scott Sturdivant
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://funcptr.net/2013/using-portshaker-with-poudriere/"/>
        <id>https://funcptr.net/2013/using-portshaker-with-poudriere/</id>
        
        <content type="html" xml:base="https://funcptr.net/2013/using-portshaker-with-poudriere/">&lt;p&gt;&lt;em&gt;Guest post by &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;ScottSturdivant&quot;&gt;Scott Sturdivant&lt;&#x2F;a&gt;.&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Maintaining custom ports and integrating them into your build process doesn&#x27;t
need to be difficult.  The documentation surrounding this process however is
either non-existent, or lacking in its clarity.  At the end of the day, it really
is as simple as maintaining a repository whose structure matches the ports tree
layout, then managing that repository and the standard ports tree
with &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.freshports.org&#x2F;ports-mgmt&#x2F;portshaker&#x2F;&quot;&gt;portshaker&lt;&#x2F;a&gt;, and finally handing the end result off to &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20140108191325&#x2F;https:&#x2F;&#x2F;fossil.etoilebsd.net&#x2F;poudriere&#x2F;doc&#x2F;trunk&#x2F;doc&#x2F;index.wiki&quot;&gt;poudriere&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;your-custom-repository&quot;&gt;Your Custom Repository&lt;&#x2F;h2&gt;
&lt;p&gt;For this example, we&#x27;ll assume a &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;git-scm.com&quot;&gt;git&lt;&#x2F;a&gt; repo is used and that you&#x27;re already
familiar with how to build &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.freebsd.org&#x2F;&quot;&gt;FreeBSD&lt;&#x2F;a&gt; &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.freebsd.org&#x2F;ports&#x2F;&quot;&gt;ports&lt;&#x2F;a&gt;.  We&#x27;ll also assume that we
have but a single port that we&#x27;re maintaining and that it is called &lt;code&gt;myport&lt;&#x2F;code&gt;.
The hierarchy of your repo should simply be &lt;code&gt;category&#x2F;myport&lt;&#x2F;code&gt;.  We&#x27;ll refer to
this repo simply as &lt;code&gt;myrepo&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;portshaker&quot;&gt;Portshaker&lt;&#x2F;h2&gt;
&lt;p&gt;Portshaker is the tool responsible for taking multiple ports sources and then
merging them down into a single target.  In our case, we have two sources: our
git repo (&lt;code&gt;myrepo&lt;&#x2F;code&gt;) containing &lt;code&gt;myport&lt;&#x2F;code&gt;, and the standard FreeBSD ports tree.
We aim to merge this down into a single ports tree that poudriere will then use
for its builds.&lt;&#x2F;p&gt;
&lt;p&gt;To configure portshaker, add the following to the
&lt;code&gt;&#x2F;usr&#x2F;local&#x2F;etc&#x2F;portshaker.conf&lt;&#x2F;code&gt; file:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;# vim:set syntax=sh:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;# $Id: portshaker.conf.sample 116 2008-09-30 16:15:02Z romain.tartiere $&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;#---[ Base directory for mirrored Ports Trees ]---&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;mirror_base_dir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;&#x2F;var&#x2F;cache&#x2F;portshaker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;#---[ Directories where to merge ports ]---&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;ports_trees&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;default&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;use_zfs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;no&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;poudriere_ports_mountpoint&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;&#x2F;usr&#x2F;local&#x2F;poudriere&#x2F;ports&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;default_poudriere_tree&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;default&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;default_merge_from&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;freebsd myrepo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Some key points here are that the two items listed in for the
&lt;code&gt;default_merge_from&lt;&#x2F;code&gt; argument need to have scripts present in the
&lt;code&gt;&#x2F;usr&#x2F;local&#x2F;etc&#x2F;portshaker.d&lt;&#x2F;code&gt; directory.  Further more, the combination of the
&lt;code&gt;poudriere_ports_mountpoint&lt;&#x2F;code&gt; and &lt;code&gt;default_poudriere_tree&lt;&#x2F;code&gt; needs to be a ports
tree that is then registered with poudriere.&lt;&#x2F;p&gt;
&lt;p&gt;Next, we need to tell portshaker how to go off and fetch our two types of ports
trees, &lt;code&gt;freebsd&lt;&#x2F;code&gt; and &lt;code&gt;myrepo&lt;&#x2F;code&gt;.  For the &lt;code&gt;freebsd&lt;&#x2F;code&gt; ports tree, create
&lt;code&gt;&#x2F;usr&#x2F;local&#x2F;etc&#x2F;portshaker.d&#x2F;freebsd&lt;&#x2F;code&gt; with the following contents and make it
executable:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;#!&#x2F;bin&#x2F;sh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;font-style: italic;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;usr&#x2F;local&#x2F;share&#x2F;portshaker&#x2F;portshaker.subr&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;method&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;portsnap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;run_portshaker_command&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; $*&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Next, create a similar script to handle our repository containing our custom
port.  &lt;code&gt;&#x2F;usr&#x2F;local&#x2F;etc&#x2F;portshaker.d&#x2F;myrepo&lt;&#x2F;code&gt; should contain the following and
similarly be executable:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;#!&#x2F;bin&#x2F;sh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;font-style: italic;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;usr&#x2F;local&#x2F;share&#x2F;portshaker&#x2F;portshaker.subr&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;method&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;git_clone_uri&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;scottsturdivant&#x2F;packaging.git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;git_branch&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;master&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;run_portshaker_command&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; $*&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Obviously replace the &lt;code&gt;git_clone_uri&lt;&#x2F;code&gt; and &lt;code&gt;git_branch&lt;&#x2F;code&gt; variables to reflect
your actual configuration.  For more information about the values and what they
can contain, consult &lt;code&gt;man portshaker.d&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Now, portshaker should be all set.  Execute &lt;code&gt;portshaker -U&lt;&#x2F;code&gt; to update your
&lt;code&gt;merge_from&lt;&#x2F;code&gt; ports trees (&lt;code&gt;freebsd&lt;&#x2F;code&gt; and &lt;code&gt;myrepo&lt;&#x2F;code&gt;).  You&#x27;ll see the standard
&lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.freebsd.org&#x2F;cgi&#x2F;man.cgi?query=portsnap&amp;amp;sektion=8&quot;&gt;portsnap&lt;&#x2F;a&gt; fetch and extract process as well as a git clone.  After a good
bit of time, these will both be present in the &lt;code&gt;&#x2F;var&#x2F;cache&#x2F;portshaker&lt;&#x2F;code&gt;
directory.  Go ahead and merge them together by executing &lt;code&gt;portshaker -M&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Hooray!  You now have &lt;code&gt;&#x2F;usr&#x2F;local&#x2F;poudriere&#x2F;ports&#x2F;default&#x2F;ports&lt;&#x2F;code&gt; that is a
combination of the normal ports tree and your custom one.&lt;&#x2F;p&gt;
&lt;p&gt;We&#x27;re effectively complete with configuring portshaker.  Whenever your port is
updated, just re-run &lt;code&gt;portshaker -U&lt;&#x2F;code&gt; and &lt;code&gt;portshaker -M&lt;&#x2F;code&gt; to grab the latest
changes and perform the merge.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;poudriere&quot;&gt;Poudriere&lt;&#x2F;h2&gt;
&lt;p&gt;Poudriere is a good tool for building ports.  We will use it to handle our
merged directory.  Begin by configuring poudriere
(&lt;code&gt;&#x2F;usr&#x2F;local&#x2F;etc&#x2F;poudriere.conf&lt;&#x2F;code&gt;):&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;ini&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;NO_ZFS&lt;&#x2F;span&gt;&lt;span&gt;=yes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;FREEBSD_HOST&lt;&#x2F;span&gt;&lt;span&gt;=ftp:&#x2F;&#x2F;ftp.freebsd.org&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;RESOLV_CONF&lt;&#x2F;span&gt;&lt;span&gt;=&#x2F;etc&#x2F;resolv.conf&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;BASEFS&lt;&#x2F;span&gt;&lt;span&gt;=&#x2F;usr&#x2F;local&#x2F;poudriere&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;USE_PORTLINT&lt;&#x2F;span&gt;&lt;span&gt;=no&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;USE_TMPFS&lt;&#x2F;span&gt;&lt;span&gt;=yes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;DISTFILES_CACHE&lt;&#x2F;span&gt;&lt;span&gt;=&#x2F;usr&#x2F;ports&#x2F;distfiles&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;CHECK_CHANGED_OPTIONS&lt;&#x2F;span&gt;&lt;span&gt;=yes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Really there&#x27;s nothing here that is specific to the problem at hand, so feel
free to consult the provided configuration file to tune it to your needs.&lt;&#x2F;p&gt;
&lt;p&gt;Now, the step that &lt;em&gt;is&lt;&#x2F;em&gt; specific is to set poudriere up with a ports tree that
it does not manage, specifically our resultant merged directory.  If you
consult &lt;code&gt;man poudriere&lt;&#x2F;code&gt;, it specifies that for the &lt;code&gt;ports&lt;&#x2F;code&gt; subcommand, there is
a &lt;code&gt;-m method&lt;&#x2F;code&gt; switch which controls the methodology used to create the ports
tree.  By default, it is portsnap.  This is confusing as in our case, we do not
want poudriere to actually do anything.  We want it to just use an existing
path.  Fortunately, there is a way!&lt;&#x2F;p&gt;
&lt;p&gt;The poudriere wiki has an entry for using the &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20130817160004&#x2F;https:&#x2F;&#x2F;fossil.etoilebsd.net&#x2F;poudriere&#x2F;doc&#x2F;trunk&#x2F;doc&#x2F;use_system_ports_tree.wiki&quot;&gt;system ports tree&lt;&#x2F;a&gt;, so we
adopt it for our needs by executing:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;poudriere&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; ports&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -c -F -f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; none&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -M&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;usr&#x2F;local&#x2F;poudriere&#x2F;ports&#x2F;default&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;    -p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; default&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;If you&#x27;ve consulted the poudriere manpage, you&#x27;ll see that the &lt;code&gt;-F&lt;&#x2F;code&gt; and &lt;code&gt;-f&lt;&#x2F;code&gt;
switches both reference ZFS in their help.  As we&#x27;re not using ZFS, it&#x27;s not
clear how they will behave.  However, in conjunction with the custom mountpoint
(&lt;code&gt;-M &#x2F;usr&#x2F;local&#x2F;poudriere&#x2F;ports&#x2F;default&lt;&#x2F;code&gt;), we ultimately wind up with what we
want, a ports tree that poudriere can use, but does not manage:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# poudriere ports -l&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;PORTSTREE            METHOD     PATH&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;default              -          &#x2F;usr&#x2F;local&#x2F;poudriere&#x2F;ports&#x2F;default&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Note that this resulting PATH is the combination of the
&lt;code&gt;poudriere_ports_mountpoint&lt;&#x2F;code&gt; and &lt;code&gt;default_poudriere_tree&lt;&#x2F;code&gt; variables present in
our &lt;code&gt;&#x2F;usr&#x2F;local&#x2F;etc&#x2F;portshaker.conf&lt;&#x2F;code&gt; configuration file.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;building-software-from-your-custom-ports-tree&quot;&gt;Building software from your custom ports tree&lt;&#x2F;h2&gt;
&lt;p&gt;Go ahead and create your jail(s) like you normally would (i.e.
&lt;code&gt;poudriere -c -j 92amd64 -V 9.2-RELEASE -a amd64&lt;&#x2F;code&gt;) and any other configuration
you would like, and then go ahead and build &lt;code&gt;myport&lt;&#x2F;code&gt; with
&lt;code&gt;poudriere bulk -j 92amd64 -p default category&#x2F;myport&lt;&#x2F;code&gt;.  Success!&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>IPv6 -- getaddrinfo() and bind() ordering with V6ONLY</title>
        <published>2012-08-07T22:39:56+00:00</published>
        <updated>2012-08-07T22:39:56+00:00</updated>
        
        <author>
          <name>
            
              Delta Regeer
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://funcptr.net/2012/ipv6-and-getaddrinfo/"/>
        <id>https://funcptr.net/2012/ipv6-and-getaddrinfo/</id>
        
        <content type="html" xml:base="https://funcptr.net/2012/ipv6-and-getaddrinfo/">&lt;p&gt;Recently I ran into an issue that took me a while to sort out, and it is
regarding inconsistent behaviour on various OS&#x27;s with regards to IPv6 sockets
(&lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;9699919799&#x2F;basedefs&#x2F;sys_socket.h.html&quot;&gt;&lt;code&gt;AF_INET6&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-20120807afvspf-1&quot;&gt;&lt;a href=&quot;#fn-20120807afvspf&quot;&gt;1&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;) and calling &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.freebsd.org&#x2F;cgi&#x2F;man.cgi?query=bind&amp;amp;apropos=0&amp;amp;sektion=2&amp;amp;manpath=FreeBSD+9.0-RELEASE&amp;amp;arch=default&amp;amp;format=html&quot;&gt;&lt;code&gt;bind(2)&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; after getting the
results back from &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.freebsd.org&#x2F;cgi&#x2F;man.cgi?query=getaddrinfo&amp;amp;apropos=0&amp;amp;sektion=3&amp;amp;manpath=FreeBSD+9.0-RELEASE&amp;amp;arch=default&amp;amp;format=html&quot;&gt;&lt;code&gt;getaddrinfo(3)&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;A call to &lt;code&gt;getaddrinfo()&lt;&#x2F;code&gt; with the hints set to &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;9699919799&#x2F;basedefs&#x2F;sys_socket.h.html&quot;&gt;&lt;code&gt;AF_UNSPEC&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; in &lt;code&gt;ai_family&lt;&#x2F;code&gt;
and &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.freebsd.org&#x2F;cgi&#x2F;man.cgi?query=getaddrinfo&amp;amp;apropos=0&amp;amp;sektion=3&amp;amp;manpath=FreeBSD+9.0-RELEASE&amp;amp;arch=default&amp;amp;format=html&quot;&gt;&lt;code&gt;AI_PASSIVE&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; in &lt;code&gt;ai_flags&lt;&#x2F;code&gt; will return to us 1 or more results that we
can &lt;code&gt;bind()&lt;&#x2F;code&gt; to. Sample code for that looks like this:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;struct&lt;&#x2F;span&gt;&lt;span&gt; addrinfo hints,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; *&lt;&#x2F;span&gt;&lt;span&gt;addrlist;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;memset&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D7DBE0;&quot;&gt;hints&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; sizeof&lt;&#x2F;span&gt;&lt;span&gt;(hints));&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;&#x2F;&#x2F; Ask for TCP&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;hints.ai_socktype &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; SOCK_STREAM;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;&#x2F;&#x2F; Any family works for us ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;hints.ai_family &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; AF_UNSPEC;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;&#x2F;&#x2F; Set some hints&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;hints.ai_flags &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    AI_PASSIVE    &lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;|&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; &#x2F;&#x2F; We want to use this with bind&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    AI_ADDRCONFIG;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;  &#x2F;&#x2F; Only return IPv4 or IPv6 if they are configured&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;int&lt;&#x2F;span&gt;&lt;span&gt; rv;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; ((rv &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt; getaddrinfo&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;7020&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; &amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D7DBE0;&quot;&gt;hints&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; &amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D7DBE0;&quot;&gt;addrlist&lt;&#x2F;span&gt;&lt;span&gt;))&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt; !=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span&gt;) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;    fprintf&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;(stderr,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;getaddrinfo: &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;%s&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt; gai_strerror&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;(rv))&lt;&#x2F;span&gt;&lt;span&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;    return&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;&#x2F;&#x2F; Use the list in *addrlist&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;for&lt;&#x2F;span&gt;&lt;span&gt; (addr &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; addrlist; addr &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;!=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span&gt;; addr &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; addr&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span&gt;ai_next) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;    &#x2F;&#x2F; use *addr as appropriate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;&#x2F;&#x2F; Clean up the memory from getaddrinfo()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;freeaddrinfo&lt;&#x2F;span&gt;&lt;span&gt;(addrlist);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;On Linux there are two entries returned when the host it is run on has both
IPv4 and IPv6 enabled. An &lt;code&gt;AF_INET&lt;&#x2F;code&gt; which was followed by an &lt;code&gt;AF_INET6&lt;&#x2F;code&gt;. Now,
it is not said that you are required to use all of the results that are
returned, but if you want to listen on all address families it is off course
suggested.&lt;&#x2F;p&gt;
&lt;p&gt;Following the steps below for each of the returned results should result in
having 1 or more different sockets that are bound to a single port.&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Create the socket()&lt;&#x2F;li&gt;
&lt;li&gt;Set any socket options you want (&lt;code&gt;SO_REUSEADDR&lt;&#x2F;code&gt; for example)&lt;&#x2F;li&gt;
&lt;li&gt;Then bind() the socket&lt;&#x2F;li&gt;
&lt;li&gt;After that call listen() (followed off course by accept() on the socket)&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;Only for some unknown reason (and &lt;code&gt;errno&lt;&#x2F;code&gt; is no help) &lt;code&gt;bind()&lt;&#x2F;code&gt; fails when you
get to the &lt;code&gt;AF_INET6&lt;&#x2F;code&gt;, which was returned second. Searching online as to why
the bind would fail doesn&#x27;t give you any good results and the thing that is
even worse is that if you run the same code on another platform such as
&lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.freebsd.org&quot;&gt;FreeBSD&lt;&#x2F;a&gt;, &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;openindiana.org&quot;&gt;OpenIndiana&lt;&#x2F;a&gt; or &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20120808044613&#x2F;http:&#x2F;&#x2F;www.apple.com&#x2F;osx&#x2F;&quot;&gt;Mac OS X&lt;&#x2F;a&gt; no such failure exists. However
I started suspecting something was up when I started looking at the output from
&lt;code&gt;netstat -lan | grep 7020&lt;&#x2F;code&gt; on Mac OS X. Where 7020 is the port I passed into
&lt;code&gt;getaddrinfo()&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;tcp46      0      0  *.7020                 *.*  LISTEN     &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;tcp4       0      0  *.7020                 *.*  LISTEN &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Wait a minute ... one of the sockets is on both IPv4 and on IPv6. Some more
time spent searching the internet I came across &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;rfc3493#page-22&quot;&gt;RFC 3493 section 5.3&lt;&#x2F;a&gt;,
which is titled &quot;&lt;code&gt;IPV6_V6ONLY&lt;&#x2F;code&gt; option for &lt;code&gt;AF_INET6&lt;&#x2F;code&gt; Sockets&quot;.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;As stated in section &amp;lt;3.7 Compatibility with IPv4 Nodes&amp;gt;, &lt;code&gt;AF_INET6&lt;&#x2F;code&gt; sockets
may be used for both IPv4 and IPv6 communications.  Some applications may
want to restrict their use of an &lt;code&gt;AF_INET6&lt;&#x2F;code&gt; socket to IPv6 communications
only.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;This was going down the right route, so I changed my code so that in the steps
listed above in number 2 I added the following code if the socket type is
&lt;code&gt;AF_INET6&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; (&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;setsockopt&lt;&#x2F;span&gt;&lt;span&gt;(sockfd, IPPROTO_IPV6, IPV6_V6ONLY,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; &amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D7DBE0;&quot;&gt;yes&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; sizeof&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;int&lt;&#x2F;span&gt;&lt;span&gt;))&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt; ==&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;    close&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;(sockfd)&lt;&#x2F;span&gt;&lt;span&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;    fprintf&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;(stderr,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;setsockopt: &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;%s&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; IPV6_V6ONLY&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt; strerror&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;(errno))&lt;&#x2F;span&gt;&lt;span&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;    continue&lt;&#x2F;span&gt;&lt;span&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The RFC 3493 section 5.3 also states that this option should be turned off by
default, which means that all IPv6 sockets can also communicate over IPv4. Thus
technically setting the option manually in code the best way to fix the issue.
FreeBSD has had this feature turned on (as in IPv6 sockets can only communicate
with IPv6 and NOT IPv4) since 5.x.&lt;&#x2F;p&gt;
&lt;p&gt;The biggest issue is that the remaining operating systems (OS X and
OpenIndiana) don&#x27;t have the same behaviour as Linux which makes troubleshooting
this issue more difficult than it should be. The issue is that the RFC doesn&#x27;t
specify what exactly the operating should do when it encounters a request to
bind to the same port on IPv4 and IPv6. The only place where I have found this
documented is in &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.amazon.com&#x2F;Network-Programming-Jun-ichiro-itojun-Hagino&#x2F;dp&#x2F;1555583180&quot;&gt;&quot;IPv6 Network Programming&quot;&lt;&#x2F;a&gt; under &quot;Tips in IPv6
Programming&quot; chapter 4, section 4, appropriately titled &quot;bind(2) Ordering and
Conflicts&quot;.&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;p&gt;If you get a &lt;code&gt;bind()&lt;&#x2F;code&gt; error when attempting to bind to an &lt;code&gt;AF_INET6&lt;&#x2F;code&gt; socket
please make sure that you set the socket option &lt;code&gt;IPV6_V6ONLY&lt;&#x2F;code&gt; on the &lt;code&gt;AF_INET6&lt;&#x2F;code&gt;
socket. The default as required by RFC 3493 is to have that option be off. The
default is wrong, and the RFC should have been more specific regarding what the
right behaviour is when attempting to bind on an &lt;code&gt;AF_INET6&lt;&#x2F;code&gt; socket when already
bound on an &lt;code&gt;AF_INET&lt;&#x2F;code&gt; while &lt;code&gt;IPV6_V6ONLY&lt;&#x2F;code&gt; is set to false.&lt;&#x2F;p&gt;
&lt;p&gt;The full code that I used for testing, along with a little bit more information
is available as a &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;gist.github.com&#x2F;3231892&quot;&gt;gist on github&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn-20120807afvspf&quot;&gt;
&lt;p&gt;The old BSD style &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.freebsd.org&#x2F;cgi&#x2F;man.cgi?query=socket&amp;amp;apropos=0&amp;amp;sektion=2&amp;amp;manpath=FreeBSD+9.0-RELEASE&amp;amp;arch=default&amp;amp;format=html&quot;&gt;&lt;code&gt;socket()&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; called for defines
starting with &lt;code&gt;PF_&lt;&#x2F;code&gt; such as &lt;code&gt;PF_INET&lt;&#x2F;code&gt; and &lt;code&gt;PF_INET6&lt;&#x2F;code&gt; with the &lt;code&gt;PF&lt;&#x2F;code&gt; standing for
protocol family. POSIX starts them with &lt;code&gt;AF_&lt;&#x2F;code&gt;, and calls them an address
family. On almost every operating system &lt;code&gt;PF_INET&lt;&#x2F;code&gt; is the same as &lt;code&gt;AF_INET&lt;&#x2F;code&gt;. If
the define doesn&#x27;t exist you can always create it. &lt;a href=&quot;#fr-20120807afvspf-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;section&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>FreeBSD 8.2 to 9.0 update with ZFS on root (mirror)</title>
        <published>2012-04-24T18:36:20+00:00</published>
        <updated>2012-04-24T18:36:20+00:00</updated>
        
        <author>
          <name>
            
              Delta Regeer
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://funcptr.net/2012/freebsd-8-2-to-9-0-update-with-zfs-on-root/"/>
        <id>https://funcptr.net/2012/freebsd-8-2-to-9-0-update-with-zfs-on-root/</id>
        
        <content type="html" xml:base="https://funcptr.net/2012/freebsd-8-2-to-9-0-update-with-zfs-on-root/">&lt;p&gt;Upgrading from one version of FreeBSD to another has become much simpler with
&lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.daemonology.net&#x2F;freebsd-update&#x2F;&quot;&gt;&lt;code&gt;freebsd-update&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; than before, a full rebuild of the FreeBSD kernel&#x2F;world
source used to be required (other upgrade paths existed but were not widely
touted). &lt;code&gt;freebsd-update&lt;&#x2F;code&gt; works extremely well when using UFS as your file
system, there are however some gotcha&#x27;s that one needs to look out for when
using FreeBSD Root on ZFS. Two machines needed upgrading, both are running with
a ZFS root mirror on FreeBSD 8.2-RELEASE. I had followed the &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;wiki.freebsd.org&#x2F;RootOnZFS&#x2F;GPTZFSBoot&#x2F;Mirror&quot;&gt;FreeBSD Root on
ZFS (mirror)&lt;&#x2F;a&gt; wiki article and everything has been running smoothly ever
since.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  pool: zroot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; state: ONLINE&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; scrub: scrub completed after 0h35m with 0 errors on Mon Mar  5 10:58:19 2012&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;config:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    NAME           STATE     READ WRITE CKSUM&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    zroot          ONLINE       0     0     0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      mirror       ONLINE       0     0     0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        gpt&#x2F;disk0  ONLINE       0     0     0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        gpt&#x2F;disk1  ONLINE       0     0     0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;errors: No known data errors&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Wanting to take advantage of some of the advancements made in &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.freebsd.org&#x2F;releases&#x2F;9.0R&#x2F;announce.html&quot;&gt;FreeBSD
9.0-RELEASE&lt;&#x2F;a&gt; such as the updated ZFS, a bug that was fixed that stopped
jails from owning a ZFS file system, improved dtrace, and better IPv6 support
required that the plunge be taken and an upgrade was in order.  There were a
couple reports of people having done source upgrades and then having issues
booting their system, but I found one &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;lists.freebsd.org&#x2F;pipermail&#x2F;freebsd-questions&#x2F;2012-January&#x2F;237308.html&quot;&gt;mailling list post&lt;&#x2F;a&gt; that suggested
that everything went well using &lt;code&gt;freebsd-update&lt;&#x2F;code&gt;, so that is the route I went
with.&lt;&#x2F;p&gt;
&lt;p&gt;I read through the entirety of the &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.FreeBSD.org&#x2F;releases&#x2F;9.0R&#x2F;relnotes-detailed.html#UPGRADE&quot;&gt;FreeBSD 9.0-ERLEASE Release Notes&lt;&#x2F;a&gt;
before moving forward to make sure I didn&#x27;t miss any important changes that
would cause my system to not restart correctly or would require changing system
configuration files before attempting the upgrade. I would advise you to do the
same.&lt;&#x2F;p&gt;
&lt;p&gt;I ran &lt;code&gt;freebsd-update -r 9.0-RELEASE upgrade&lt;&#x2F;code&gt; and after accepting the list of
components that were installed, I got an error saying:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# freebsd-update -r 9.0-RELEASE upgrade&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Looking up update.FreeBSD.org mirrors... 4 mirrors found.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Fetching metadata signature for 8.2-RELEASE from update2.freebsd.org... done.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Fetching metadata index... done.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Inspecting system... done.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;The following components of FreeBSD seem to be installed:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kernel&#x2F;generic src&#x2F;base src&#x2F;bin src&#x2F;cddl src&#x2F;contrib src&#x2F;crypto src&#x2F;etc&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;src&#x2F;games src&#x2F;gnu src&#x2F;include src&#x2F;krb5 src&#x2F;lib src&#x2F;libexec src&#x2F;release&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;src&#x2F;rescue src&#x2F;sbin src&#x2F;secure src&#x2F;share src&#x2F;sys src&#x2F;tools src&#x2F;ubin&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;src&#x2F;usbin world&#x2F;base world&#x2F;catpages world&#x2F;dict world&#x2F;doc world&#x2F;games&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;world&#x2F;info world&#x2F;lib32 world&#x2F;manpages&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;The following components of FreeBSD do not seem to be installed:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;world&#x2F;proflibs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Does this look reasonable (y&#x2F;n)? y&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Fetching metadata signature for 9.0-RELEASE from update2.freebsd.org... done.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Fetching metadata index... done.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;The update metadata is correctly signed, but&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;failed an integrity check.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Cowardly refusing to proceed any further.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Specifically the line stating &quot;Cowardly refusing to proceed further&quot;, a quick
&lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;google.com&#x2F;&quot;&gt;Google&lt;&#x2F;a&gt; later I found the &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;lists.freebsd.org&#x2F;pipermail&#x2F;freebsd-stable&#x2F;2011-October&#x2F;064321.html&quot;&gt;9.0-RC1 mailling list post&lt;&#x2F;a&gt; that suggested
the following one line fix:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;sed&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -i&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;#39;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -e&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;s&#x2F;=_&#x2F;=%@_&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;usr&#x2F;sbin&#x2F;freebsd-update&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;After that quick fix, a re-run of &lt;code&gt;freebsd-update&lt;&#x2F;code&gt; functioned without issues
and finished, showing me what it would change, asking me if it seemed
acceptable and telling me what it was going to remove and what was going to be
installed.&lt;&#x2F;p&gt;
&lt;p&gt;Next we run &lt;code&gt;freebsd-update&lt;&#x2F;code&gt; for the first time in this three step process:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;freebsd-update&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; install&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Don&#x27;t restart yet (although it tells you to)! We need to go back and make sure
we update the boot records first.&lt;&#x2F;p&gt;
&lt;p&gt;Going back to the &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;lists.freebsd.org&#x2F;pipermail&#x2F;freebsd-questions&#x2F;2012-January&#x2F;237308.html&quot;&gt;mailling list post made by Magnus Strahlert&lt;&#x2F;a&gt;, I made note
of the following:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Had to upgrade the gpt bootcode as instructed when upgrading the zpool for
the system to boot.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;This is the only comment that worried me, and nowhere in the email thread does
the poster describe what commands he ran. In any case I figure he meant
re-running the boot code commands from the FreeBSD Root on ZFS wiki article:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;gpart&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; bootcode&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -b&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;boot&#x2F;pmbr&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;boot&#x2F;gptzfsboot&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -i&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; da0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;gpart&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; bootcode&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -b&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;boot&#x2F;pmbr&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;boot&#x2F;gptzfsboot&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -i&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; da1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;After running these commands, it told me that it had updated the boot code and then I ran:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;shutdown&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; now&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;After the machine came back online (it is in those moments when you have a
small heartattack when the machine doesn&#x27;t come up as fast as you had expected
...) you log back in and run:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;freebsd-update&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; install&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This will install all of the updated binaries that came with FreeBSD 9.0, at
this point FreeBSD update will tell you to upgrade all installed software and
ports, and then run &lt;code&gt;freebsd-update&lt;&#x2F;code&gt; one more time to remove all unnecessary
shared libraries. If you want to have certain software continue functioning,
yet you want &lt;code&gt;freebsd-update&lt;&#x2F;code&gt; to remove any other remaining old 8.x files, you
can install &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.freshports.org&#x2F;misc&#x2F;compat8x&#x2F;&quot;&gt;&lt;code&gt;misc&#x2F;compat8x&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; from the ports tree. This is the suggested
route to go if you want to keep the 8.x libraries around for compatibility
reasons.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;font-style: italic;&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;usr&#x2F;ports&#x2F;misc&#x2F;compat8x&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;make&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; install clean&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;# or&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;# portmaster misc&#x2F;compat8x&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I use &lt;code&gt;portmaster&lt;&#x2F;code&gt; and the following command will simply rebuild every port
installed on the system:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;portmaster&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -aPf&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The &lt;code&gt;-P&lt;&#x2F;code&gt; to &lt;code&gt;portmaster&lt;&#x2F;code&gt; means look for package and if available use it,
otherwise build from port.&lt;&#x2F;p&gt;
&lt;p&gt;Run &lt;code&gt;freebsd-update&lt;&#x2F;code&gt; one last time:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;freebsd-update&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; install&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Since we are running ZFS we will most likely also want to upgrade our pool to
the latest version of ZFS to take advantage of any new goodies (such as
deduplication!), upgrading a zpool is easy:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;zpool&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; upgrade zroot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;That upgrades to the latest pool version, now we will want to upgrade our
existing file systems to the latest version of ZFS, do note that this will make
them incompatible with older file system verisons (so if you use zfs send for
backups, your other endpoint will need to be of the same ZFS version)&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;zfs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; upgrade&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # List all ZFS file systems that need to be upgraded&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;zfs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; upgrade&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -a&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # Upgrade all file systems&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;After this one last reboot to make sure that all the processes come back online
using the newer libraries and that you didn&#x27;t accidentally miss something.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;shutdown&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; now&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;At this point the system has been upgraded from FreeBSD 8.0-RELEASE to FreeBSD
9.0-RELEASE and has all of the latest updates and enhancements.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>NAT with PF on an interface with multiple IP addresses</title>
        <published>2011-09-08T02:40:00+00:00</published>
        <updated>2011-09-08T02:40:00+00:00</updated>
        
        <author>
          <name>
            
              Delta Regeer
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://funcptr.net/2011/nat-with-pf-on-an-interface/"/>
        <id>https://funcptr.net/2011/nat-with-pf-on-an-interface/</id>
        
        <content type="html" xml:base="https://funcptr.net/2011/nat-with-pf-on-an-interface/">&lt;p&gt;If you want to do NAT for your currently running jail instances on FreeBSD so
that they can have outgoing connections you could try the following &lt;code&gt;pf.conf&lt;&#x2F;code&gt;
to set up NAT on the interface that the jails have their IP addresses on.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ext_if=&amp;quot;em0&amp;quot;    # The network card your default gateway is on&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;jail_if=&amp;quot;lo1&amp;quot;   # The interface that your jails have IP addresses on&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# Set some options&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;set optimization aggressive&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;set block-policy drop&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;set skip on lo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# NAT on the external interface when coming from the jail interface&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nat on $ext_if from $jail_if:network:0 to any -&amp;gt; ($ext_if)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# We just pass everything&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pass quick all&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;What I have done is create IP addresses within the private network range
(&lt;code&gt;10&#x2F;8&lt;&#x2F;code&gt;, &lt;code&gt;172.16&#x2F;12&lt;&#x2F;code&gt;, &lt;code&gt;192.168&#x2F;16&lt;&#x2F;code&gt;) on the &lt;code&gt;lo1&lt;&#x2F;code&gt; interface. These can&#x27;t be in
the &lt;code&gt;127&#x2F;8&lt;&#x2F;code&gt; range because those addresses can&#x27;t be NAT&#x27;ed (not sure if this is
a limitation in pf or if this is a FreeBSD limitation), which is a shame
because using &lt;code&gt;127.1.0.1&#x2F;24&lt;&#x2F;code&gt; would be pretty awesome in my opinion.&lt;&#x2F;p&gt;
&lt;p&gt;What I did find though is that the above will not work correctly if your main
network card (the one your default gateway is on, in the example &lt;code&gt;em0&lt;&#x2F;code&gt;)
contains multiple IP addresses. At that point the syntax &lt;code&gt;($ext_if)&lt;&#x2F;code&gt; does not
function correctly and will cause packet loss&#x2F;drop. &lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-2011-09-08freebsdversion-1&quot;&gt;&lt;a href=&quot;#fn-2011-09-08freebsdversion&quot;&gt;1&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;&lt;&#x2F;p&gt;
&lt;p&gt;So instead of using the syntax above we simply replace &lt;code&gt;($ext_if)&lt;&#x2F;code&gt; with the
actual IP address of the interface. This takes care of the issue and will let
your jails have proper internet access without issues.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ext_if=&amp;quot;em0&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;jail_if=&amp;quot;lo1&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;set optimization aggressive&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;set block-policy drop&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;set skip on lo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nat on $ext_if from $jail_if:network:0 to any -&amp;gt; 192.168.1.2 # Your IP! &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pass quick all&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The other way you can solve this problem off course is to provide your jails
with IP addresses within the same range that go to your default gateway thereby
solving the problem of needing to NAT in the first place.&lt;&#x2F;p&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn-2011-09-08freebsdversion&quot;&gt;
&lt;p&gt;Do note that I am using FreeBSD 8.2, so this may
be fixed in the new FreeBSD 9 that is due to be released soon. &lt;a href=&quot;#fr-2011-09-08freebsdversion-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;section&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>FreeBSD running within KVM: Serial Console</title>
        <published>2011-08-21T18:53:52+00:00</published>
        <updated>2011-08-21T18:53:52+00:00</updated>
        
        <author>
          <name>
            
              Delta Regeer
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://funcptr.net/2011/freebsd-running-within-kvm-serial-console/"/>
        <id>https://funcptr.net/2011/freebsd-running-within-kvm-serial-console/</id>
        
        <content type="html" xml:base="https://funcptr.net/2011/freebsd-running-within-kvm-serial-console/">&lt;p&gt;Instead of using virtualisation technology such as VMWare of VirtualBox I
decided to give the new &lt;a rel=&quot;external&quot; title=&quot;Kernel based Virtual Machine&quot; href=&quot;http:&#x2F;&#x2F;www.linux-kvm.org&#x2F;page&#x2F;Main_Page&quot;&gt;KVM&lt;&#x2F;a&gt; technology that is included with Linux. It is
fast, and has been extremely reliable. However I wanted to be able to access
the console on the guest FreeBSD instances.&lt;&#x2F;p&gt;
&lt;p&gt;I used virt-manager, a graphical tool, to set up everything, including creating
the virtual machine, I didn&#x27;t want to have to deal with XML configuration files
and whatnot. After installing FreeBSD there are a few changes I made to get a
virtual console working, this allows &lt;code&gt;virsh console &amp;lt;domain&amp;gt;&lt;&#x2F;code&gt; to function
as expected.&lt;&#x2F;p&gt;
&lt;p&gt;First we add a new file to the root file system (which should be the first
slice on the drive):&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;font-style: italic;&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;-Dh&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; &amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;boot.config&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;See &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.freebsd.org&#x2F;cgi&#x2F;man.cgi?query=boot.config&amp;amp;sektion=5&quot;&gt;man 5 boot.config&lt;&#x2F;a&gt; for more information. Basically -D says that FreeBSD
should boot with a dual console configuration (built-in over VGA) and serial
console, and -h says to force the serial console to on.&lt;&#x2F;p&gt;
&lt;p&gt;If you were to reboot now and use the virsh command:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;virsh&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; console FreeBSD&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;you would see the system go through the boot process and show output starting
from when the boot block gains control, at this point however you still have no
way to login to this new console since we never specified that we wanted any
ttys on the serial console, for that we need to edit &#x2F;etc&#x2F;ttys.&lt;&#x2F;p&gt;
&lt;p&gt;We are looking for the ttyu0 entry, we want to make sure to change dialup to
vt100, and off to on, so that it should look like this:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ttyu0   &amp;quot;&#x2F;usr&#x2F;libexec&#x2F;getty std.9600&amp;quot;   vt100   on secure&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now when we reboot once more we will get the usual login display that we have
come to expect of console on FreeBSD, and we can login over the serial console.
This way we don&#x27;t have to open up the virtual machine manager to get a console,
and can continue to do almost everything from a terminal window.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>PostgreSQL setup for external connections</title>
        <published>2011-08-16T17:48:54+00:00</published>
        <updated>2011-08-16T17:48:54+00:00</updated>
        
        <author>
          <name>
            
              Delta Regeer
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://funcptr.net/2011/postgresql-setup-for-external-connections/"/>
        <id>https://funcptr.net/2011/postgresql-setup-for-external-connections/</id>
        
        <content type="html" xml:base="https://funcptr.net/2011/postgresql-setup-for-external-connections/">&lt;p&gt;PostgreSQL is a fantastic open-source RDBMS which is extremely powerful, once
installed on FreeBSD getting it set up is pretty simple. We do want to change
some of the defaults though. By default the system will be set up to trust any
user using the local socket to connect as any user to any database.&lt;&#x2F;p&gt;
&lt;p&gt;By setting up the &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;8.2&#x2F;static&#x2F;app-initdb.html&quot;&gt;&lt;code&gt;initdb&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; flags we can change how PostgreSQL generates
the default configuration files. Adding &lt;code&gt;-A md5&lt;&#x2F;code&gt; tells it to use the &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;8.2&#x2F;static&#x2F;auth-methods.html#AUTH-PASSWORD&quot;&gt;md5
authentication mechanism&lt;&#x2F;a&gt;, which requires that passwords sent over the wire
are md5 hashed.&lt;&#x2F;p&gt;
&lt;p&gt;Add the following to &lt;a rel=&quot;external&quot; title=&quot;man 5 rc.conf&quot; href=&quot;http:&#x2F;&#x2F;www.freebsd.org&#x2F;cgi&#x2F;man.cgi?query=rc.conf&amp;amp;sektion=5&quot;&gt;&lt;code&gt;&#x2F;etc&#x2F;rc.conf&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; for the initdb flags, and enable
PostgreSQL as a service:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;postgresql_initdb_flags=&amp;quot;-D &#x2F;usr&#x2F;local&#x2F;pgsql&#x2F;data -W -A md5&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;postgresql_enable=&amp;quot;YES&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And then run:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;&#x2F;usr&#x2F;local&#x2F;etc&#x2F;rc.d&#x2F;postgresql&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; initdb&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This will initialise and create the configuration as well as setting up some of
the default tables. You will want to navigate to the folder specified in the
&lt;code&gt;initdb_flags&lt;&#x2F;code&gt; above:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;font-style: italic;&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;usr&#x2F;local&#x2F;pgsql&#x2F;data&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;this is where you will find the files that we are going to modify next to get
PostgreSQL set up to listen to connections coming in on a private network
(&lt;code&gt;192.168.1.1&#x2F;24&lt;&#x2F;code&gt;) and where we allow connections coming in from servers on
that network. This is strictly for setting up PostgreSQL in a situation where
you have multiple servers accessing it as a client on a private network.&lt;&#x2F;p&gt;
&lt;p&gt;After this we need to modify a few files to get it to listen to TCP&#x2F;IPv4
connections, first we start with &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;8.2&#x2F;static&#x2F;runtime-config-connection.html#RUNTIME-CONFIG-CONNECTION-SETTINGS&quot;&gt;&lt;code&gt;postgresql.conf&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; and add:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;ini&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;listen_addresses&lt;&#x2F;span&gt;&lt;span&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;127.0.0.1,192.168.1.1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Then in &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;8.2&#x2F;static&#x2F;auth-pg-hba-conf.html&quot;&gt;&lt;code&gt;pg_hba.conf&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; we add a new line:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;host	all		all		192.168.1.1&#x2F;24		md5&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This allows anyone in the 192.168.1.1&#x2F;24 range to connect to our PostgreSQL
instance and to use the databases. This is exactly what we want to allow, now
we start PostgreSQL using the rc script:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;&#x2F;usr&#x2F;local&#x2F;etc&#x2F;rc.d&#x2F;postgresql&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; start&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Setting up jails with multiple IPs and providing it with internet access</title>
        <published>2011-08-15T15:40:04+00:00</published>
        <updated>2011-08-15T15:40:04+00:00</updated>
        
        <author>
          <name>
            
              Delta Regeer
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://funcptr.net/2011/setting-up-jails-with-multiple-ips-and-providing-it-with-internet-access/"/>
        <id>https://funcptr.net/2011/setting-up-jails-with-multiple-ips-and-providing-it-with-internet-access/</id>
        
        <content type="html" xml:base="https://funcptr.net/2011/setting-up-jails-with-multiple-ips-and-providing-it-with-internet-access/">&lt;p&gt;I have multiple VMs up and running and generally I have an internal to the
VMs only network set up, in the current project I am working on I have
three completely different networks set up.&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;DHCP assigned network that routes to the outside network on the host (192.168.0.1&#x2F;24)&lt;&#x2F;li&gt;
&lt;li&gt;An internal to the VM&#x27;s network interface (10.99.12.1&#x2F;24)&lt;&#x2F;li&gt;
&lt;li&gt;A network that is tied to the host&#x27;s wireless network (setup to be an AP) (10.99.11.1&#x2F;24)&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;So within my FreeBSD VM I have the following: &lt;code&gt;em0&lt;&#x2F;code&gt;, &lt;code&gt;em1&lt;&#x2F;code&gt;, &lt;code&gt;em2&lt;&#x2F;code&gt; as
&quot;network cards&quot;. In my FreeBSD VM, I am creating two jails that are going
to contain different pieces of server software. The jails need IP&#x27;s in
the following ranges, 10.99.12.1&#x2F;24 (to connect to another VM),
10.99.11.1&#x2F;24 (Wifi network) and then it needs to have an IP address that
is considered &quot;local&quot; and we can NAT on, so in addition to the above
networks we also needed to add another network. The easiest way to create
new interface with IP addresses is using a bridge. They can be assigned
IP addresses, which is all we need.&lt;&#x2F;p&gt;
&lt;p&gt;At this point inside of a jail it kinda looks like this:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;em0: flags=8843&amp;lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&amp;gt; metric 0 mtu 1500&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    options=209b&amp;lt;RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ether 52:54:00:6b:6a:49&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    media: Ethernet autoselect (1000baseT &amp;lt;full-duplex&amp;gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    status: active&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;em1: flags=8843&amp;lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&amp;gt; metric 0 mtu 1500&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    options=209b&amp;lt;RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ether 52:54:00:2f:a5:55&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    inet 10.99.12.4 netmask 0xffffffff broadcast 10.99.12.4&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    media: Ethernet autoselect (1000baseT &amp;lt;full-duplex&amp;gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    status: active&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;em2: flags=8843&amp;lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&amp;gt; metric 0 mtu 1500&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    options=209b&amp;lt;RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ether 52:54:00:bb:b6:43&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    inet 10.99.11.14 netmask 0xffffffff broadcast 10.99.11.14&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    media: Ethernet autoselect (1000baseT &amp;lt;full-duplex&amp;gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    status: active&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;lo0: flags=8049&amp;lt;UP,LOOPBACK,RUNNING,MULTICAST&amp;gt; metric 0 mtu 16384&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    options=3&amp;lt;RXCSUM,TXCSUM&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;bridge0: flags=8843&amp;lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&amp;gt; metric 0 mtu 1500&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ether da:de:63:c9:55:6c&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    inet 10.0.1.4 netmask 0xffffffff broadcast 10.0.1.4&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;code&gt;em0&lt;&#x2F;code&gt; doesn&#x27;t have an address since that is our DHCP address, &lt;code&gt;em1&lt;&#x2F;code&gt;,
&lt;code&gt;em2&lt;&#x2F;code&gt; and &lt;code&gt;bridge0&lt;&#x2F;code&gt; all have IP addresses, in the jail configuration the
&lt;code&gt;bridge0&lt;&#x2F;code&gt; IP address is listed first, and thus when something binds or
sends it sends from that IP address. The thing is that at this point the
jail does not have internet access.&lt;&#x2F;p&gt;
&lt;p&gt;Jails inherit the routing table from their host environment (yes, you
can compile in more routing tables ... but I don&#x27;t want to modify stock),
any traffic that goes to the outside is going to go out over the default
route, thing is you&#x27;d expect that traffic to show up on &lt;code&gt;bridge0&lt;&#x2F;code&gt; where
the IP address exists, instead using &lt;code&gt;tcpdump&lt;&#x2F;code&gt; you see it show up on
&lt;code&gt;em0&lt;&#x2F;code&gt;, which is where the default route is. I would have expected having
to do NAT on the bridge, not just the external interface.&lt;&#x2F;p&gt;
&lt;p&gt;Here is the &lt;code&gt;pf&lt;&#x2F;code&gt; configuration.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ext_if=&amp;quot;em0&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;jail_if=&amp;quot;bridge0&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;set optimization aggressive&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;set block-policy drop&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;set skip on lo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nat on $ext_if from $jail_if:network:0 to any -&amp;gt; ($ext_if)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pass quick all&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And we&#x27;ve got internet within our jail.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Moving from mod_fastcgi to mod_fcgid</title>
        <published>2009-08-25T23:22:03+00:00</published>
        <updated>2010-11-14T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Delta Regeer
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://funcptr.net/2009/moving-from-mod-fastcgi-to-mod-fcgid/"/>
        <id>https://funcptr.net/2009/moving-from-mod-fastcgi-to-mod-fcgid/</id>
        
        <content type="html" xml:base="https://funcptr.net/2009/moving-from-mod-fastcgi-to-mod-fcgid/">&lt;p&gt;Update: I&#x27;ve since moved to a PHP-FPM with &lt;code&gt;mod_fastcgi&lt;&#x2F;code&gt; based setup which works
much better than &lt;code&gt;mod_fcgid&lt;&#x2F;code&gt; could ever dream of, taking process management away
from Apache and putting it where it actually makes sense has improved server
load and improved website speed. See my new &lt;a href=&quot;&#x2F;2010&#x2F;apache-mod-fastcgi-and-php-with-php-fpm&#x2F;&quot;&gt;PHP-FPM with mod_fastcgi
post&lt;&#x2F;a&gt; for more information.&lt;&#x2F;p&gt;
&lt;p&gt;--&lt;&#x2F;p&gt;
&lt;p&gt;Errors, all they cause is trouble. The dreaded 500 error showed up when
visiting my favourite tech website, the one I am the administrator for. This
time I had enough, there was going to be no more playing around with PHP
settings, attempting to figure out why PHP was suddenly dying and or why
&lt;code&gt;mod_fastcgi&lt;&#x2F;code&gt; refused to retry a select() when it failed due to a system
signal.&lt;&#x2F;p&gt;
&lt;p&gt;The server in question runs Apache in MPM worker mode since a threaded Apache
is going to be faster than a pre-fork, besides this server does not have as
much memory so it seemed to be better to have multiple threads rather than
multiple processes, each of which would have their own memory segment. There
however is the issue that this server also needs to run PHP, the accepted
method to do so is to use &lt;code&gt;mod_php&lt;&#x2F;code&gt; along with Apache; however PHP is not thread
safe.&lt;&#x2F;p&gt;
&lt;p&gt;The alternative is FastCGI, basically it spawns PHP processes as a separate
stand-alone process, with their own memory space, much like Apache pre-fork,
however now when one process grows to big, or when a process is no longer
needed it can be cleaned up, keeping memory to a minimum. Also, FastCGI is
perfectly thread safe, this means that with Apache running in MPM worker mode
we could now still run our PHP scripts even when they were not thread safe.&lt;&#x2F;p&gt;
&lt;p&gt;Setting up &lt;code&gt;mod_fastcgi&lt;&#x2F;code&gt; is not that hard, it takes some httpd.conf
configuration values, and off course the loadmodule is assumed here:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# Set up mod_fastcgi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;IfModule `mod_fastcgi`.c&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    FastCgiIpcDir &#x2F;var&#x2F;tmp&#x2F;fcgi-ipc&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    FastCgiConfig -autoUpdate -singleThreshold 100 -killInterval 300 -idle-timeout 240 -pass-header HTTP_AUTHORIZATION&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    AddHandler  fastcgi-script              .fcgi .fcg .fpl&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Action      application&#x2F;x-httpd-php5    &#x2F;fastcgi-bin&#x2F;php5.fcgi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    AddType     application&#x2F;x-httpd-php5    .php .php5&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;&#x2F;IfModule&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# Set up the script alias, basically anything in this directory gets executed as a fastcgi script&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ScriptAlias &#x2F;fastcgi-bin&#x2F; &amp;quot;&#x2F;usr&#x2F;local&#x2F;www&#x2F;fastcgi-bin&#x2F;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;Location &#x2F;fastcgi-bin&#x2F;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Options ExecCGI &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    SetHandler fastcgi-script&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Order allow,deny&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Allow from all&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;&#x2F;Location&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Because of errors that &lt;code&gt;mod_fastcgi&lt;&#x2F;code&gt; was throwing out at me, I figured
&lt;code&gt;mod_fcgid&lt;&#x2F;code&gt; is worth a try. However all of the configurations I found required
me to add an FCGIWrapper line into each of my VirtualHost blocks, which was an
immediate no-no since there is well over 100 of those on the server, and I&#x27;d
rather spend my time doing other things.&lt;&#x2F;p&gt;
&lt;p&gt;With some trial and error, and some Googling I put the following together for
&lt;code&gt;mod_fcgid&lt;&#x2F;code&gt;, tested it out, and once it worked perfectly set Apache off running
with the following configuration:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# Set up mod_fcgid&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;IfModule `mod_fcgid`.c&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    AddHandler  fcgid-script                 .fcgi .fcg .fpl&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    IPCCommTimeout 60&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    SocketPath  &#x2F;var&#x2F;tmp&#x2F;fcgi-ipc&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Action      application&#x2F;x-httpd-php5    &#x2F;fastcgi-bin&#x2F;php5.fcgi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    AddType     application&#x2F;x-httpd-php5    .php .php5&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;&#x2F;IfModule&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# Set up the script alias, basically anything in this directory gets executed as a fastcgi script&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ScriptAlias &#x2F;fastcgi-bin&#x2F; &amp;quot;&#x2F;usr&#x2F;local&#x2F;www&#x2F;fastcgi-bin&#x2F;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;Location &#x2F;fastcgi-bin&#x2F;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Options ExecCGI &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    SetHandler fcgid-script&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Order allow,deny&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Allow from all&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;&#x2F;Location&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Notice how similar they both are, that was the whole goal. &lt;code&gt;mod_fcgid&lt;&#x2F;code&gt; was
supposed to be a drop in replacement, and thankfully it was. PHP was served as
it once was, with a twist.&lt;&#x2F;p&gt;
&lt;p&gt;The php5.fcgi script is as follows for those of you trying to set this up as
well:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;#!&#x2F;bin&#x2F;sh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;# To use your own php.ini, comment the next line and uncomment the following one&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;#PHPRC=&amp;quot;&#x2F;usr&#x2F;local&#x2F;etc&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;#export PHPRC&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;PHP_FCGI_CHILDREN&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;4&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;export&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt; PHP_FCGI_CHILDREN&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;font-style: italic;&quot;&gt;exec&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;usr&#x2F;local&#x2F;bin&#x2F;php-cgi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Some things that that intrigued me is that my php processes seemed to be capped
now. Where &lt;code&gt;mod_fastcgi&lt;&#x2F;code&gt; would spawn processes but never remove them or kill
them when they were no longer needed, &lt;code&gt;mod_fcgid&lt;&#x2F;code&gt; keeps the running php
processes to a sane limit instantly starting new processes when required to
handle the requests coming in. This means that the server now has more free
memory for MySQL, or file caches which has helped speed up other types of
transfers as well. Even with the relatively short time that &lt;code&gt;mod_fcgid&lt;&#x2F;code&gt; has
been in place it has been faster, more reliable and more sane than
&lt;code&gt;mod_fastcgi&lt;&#x2F;code&gt;. Whichever one you pick, make sure to benchmark your server and
check your error logs to solve common issues, the issue may not be what FastCGI
module you picked but rather PHP itself that is causing the errors!&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>FreeBSD GEOM striping and concatenation</title>
        <published>2006-12-13T06:44:20+00:00</published>
        <updated>2006-12-13T06:44:20+00:00</updated>
        
        <author>
          <name>
            
              Delta Regeer
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://funcptr.net/2006/freebsd-geom-striping-and-concatenation/"/>
        <id>https://funcptr.net/2006/freebsd-geom-striping-and-concatenation/</id>
        
        <content type="html" xml:base="https://funcptr.net/2006/freebsd-geom-striping-and-concatenation/">&lt;p&gt;Some of the hard drives in my FreeBSD box. Just a little back-story:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;dev&#x2F;ad0 - 20 GB&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;dev&#x2F;ad1 - 40 GB&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;dev&#x2F;ad2 - 100 GB&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;dev&#x2F;ad3 - 60 GB&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;dev&#x2F;da0 - 8 GB&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;dev&#x2F;da1 - 8 GB&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I had already made a &lt;code&gt;gstripe(8)&lt;&#x2F;code&gt; out of the two SCSI drives, &lt;code&gt;da[1|2]&lt;&#x2F;code&gt;,
however I wanted to see if I could do the same with &lt;code&gt;ad[1|2|3]&lt;&#x2F;code&gt;. As I did
not want to resort to gvinum, which is rather heavy, and I was unable to
figure out how it worked. The entire point behind gstripe is that since it
is striped, the writes&#x2F;reads are faster since it writes&#x2F;reads to all the
drives at the same time. So first I tried:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;gstripe&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; label&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -v&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; st1 &#x2F;dev&#x2F;ad1 &#x2F;dev&#x2F;ad2 &#x2F;dev&#x2F;ad3&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;That however complained that it would only use 40 GB&#x27;s on all of the
drives, since the smallest drive in the collection was 40 GB. I then read
up on &lt;code&gt;gconcat(8)&lt;&#x2F;code&gt;, which concatenates all the drives together to look
like one big drive, without the speed improvement of striping. So I
figured, since FreeBSD&#x27;s gstripe is GEOM based, it should not care about
what the underlying data sink is, just that it is a device, so just maybe
this could work:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;gconcat&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; label&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -v&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; gb100 &#x2F;dev&#x2F;ad1 &#x2F;dev&#x2F;ad3&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;So now I had created a 100 GB &quot;hd&quot; at &lt;code&gt;&#x2F;dev&#x2F;concat&#x2F;gb100&lt;&#x2F;code&gt;. I now did what
I was planning to do:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;gstripe&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; label&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -v&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; st1 &#x2F;dev&#x2F;ad2 &#x2F;dev&#x2F;concat&#x2F;gb100&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;No problem. I now had 180.48 GB, of which only about 166 GB was usable.
Which is still excellent. As it still came with a speed improvement.
Followed up with the standard advice from &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;www.freebsd.org&#x2F;doc&#x2F;en_US.ISO8859-1&#x2F;books&#x2F;handbook&#x2F;geom-striping.html&quot;&gt;the handbook&lt;&#x2F;a&gt; I did the
following:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;bsdlabel&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -wB&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;dev&#x2F;stripe&#x2F;st1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;newfs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -U&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;dev&#x2F;stripe&#x2F;st1a&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;mount&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;dev&#x2F;stripe&#x2F;st1a &#x2F;mnt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Which got me the following:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;dev&#x2F;stripe&#x2F;st1a    180G    5.5G    161G     3%    &#x2F;mnt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Full:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Filesystem          Size    Used   Avail Capacity  Mounted on&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;dev&#x2F;ad0s1a         496M     63M    393M    14%    &#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;devfs               1.0K    1.0K      0B   100%    &#x2F;dev&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;dev&#x2F;ad0s1e         496M    230K    456M     0%    &#x2F;tmp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;dev&#x2F;ad0s1f          15G    2.2G     11G    17%    &#x2F;usr&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;dev&#x2F;ad0s1d         1.4G    115M    1.2G     9%    &#x2F;var&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;dev&#x2F;stripe&#x2F;st0a     16G    4.0K     15G     0%    &#x2F;usr&#x2F;scsi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;dev&#x2F;stripe&#x2F;st1a    180G    5.5G    161G     3%    &#x2F;mnt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Next up I might actually add &lt;code&gt;gdbe(8)&lt;&#x2F;code&gt; or &lt;code&gt;geli(8)&lt;&#x2F;code&gt; even in front of the
stripe, so that I will have an encrypted stripe. Talk about stacking.
Might give gvinum a try sometime.&lt;&#x2F;p&gt;
&lt;p&gt;All working:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;keyhole# gconcat status&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        Name  Status  Components&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;concat&#x2F;gb100      UP  ad1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                      ad3&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;keyhole# gstripe status&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      Name  Status  Components&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;stripe&#x2F;st0      UP  da0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                    da1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;stripe&#x2F;st1      UP  ad2&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                    concat&#x2F;gb100&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;</content>
        
    </entry>
    <entry xml:lang="en">
        <title>FastCGI quick and dirty</title>
        <published>2006-09-13T00:19:31+00:00</published>
        <updated>2006-09-13T00:19:31+00:00</updated>
        
        <author>
          <name>
            
              Delta Regeer
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://funcptr.net/2006/fastcgi-quick-and-dirty/"/>
        <id>https://funcptr.net/2006/fastcgi-quick-and-dirty/</id>
        
        <content type="html" xml:base="https://funcptr.net/2006/fastcgi-quick-and-dirty/">&lt;p&gt;In this quick and dirty guide for FreeBSD I will assume you have already
compiled and installed PHP5 with fcgi mode enabled, which can be checked by
running:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;&#x2F;usr&#x2F;local&#x2F;bin&#x2F;php-cgi&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; --version&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I will also assume you have installed &lt;code&gt;mod_fastcgi&lt;&#x2F;code&gt; from &lt;code&gt;www&#x2F;mod_fastcgi&lt;&#x2F;code&gt;
in the ports.&lt;&#x2F;p&gt;
&lt;p&gt;Create the fast cgi ipc temp dir, make sure you place this somewhere it will
keep existing:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;font-style: italic;&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;var&#x2F;tmp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;var&#x2F;tmp&#x2F;fcgi-ipc&#x2F;dynamic&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;chmod&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -R&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0777&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;var&#x2F;tmp&#x2F;fcgi-ipc&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Let&#x27;s create the directory where we are going to place our PHP wrapper, this
config is for server wide using the same FastCGI PHP config. This is on
purpose, since it will allow server wide PHP usage. If you want you could then
split it up into virtualhosts if one required a standalone php running for
that.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;usr&#x2F;local&#x2F;www&#x2F;fastcgi-bin&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;chmod&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 755&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;usr&#x2F;local&#x2F;www&#x2F;fastcgi-bin&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Next up we create the very simple wrapper:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;cat&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; &amp;lt;&amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; EOF&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; &amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;usr&#x2F;local&#x2F;www&#x2F;fastcgi-bin&#x2F;php5.fcgi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;#!&#x2F;bin&#x2F;sh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;# To use your own php.ini, comment the next line and uncomment the following one&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;#PHPRC=&amp;quot;&#x2F;usr&#x2F;local&#x2F;etc&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;export PHPRC&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;PHP_FCGI_CHILDREN=8&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;export PHP_FCGI_CHILDREN&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;exec &#x2F;usr&#x2F;local&#x2F;bin&#x2F;php-cgi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;EOF&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Set &lt;code&gt;PHP_FCGI_CHILDREN&lt;&#x2F;code&gt; to whatever value you want, that is how many processes
it will use. I suggest the standard which is 8, if you make it more, you use
more ram, you make it less Apache will have to wait if all of the PHP
processes are in use.&lt;&#x2F;p&gt;
&lt;p&gt;Next up, make it executable:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;chmod&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; +x &#x2F;usr&#x2F;local&#x2F;www&#x2F;fastcgi-bin&#x2F;php5.fcgi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Last but not least, edit &lt;code&gt;httpd.conf&lt;&#x2F;code&gt; and make sure to add a comment in front
of the &lt;code&gt;mod_php5&lt;&#x2F;code&gt; line, and uncomment the &lt;code&gt;mod_fastcgi&lt;&#x2F;code&gt; line. Then add this
to the end of your Apache config:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;IfModule mod_fastcgi.c&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    FastCgiIpcDir &#x2F;var&#x2F;tmp&#x2F;fcgi-ipc&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    FastCgiConfig  -pass-header HTTP_AUTHORIZATION&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    AddHandler  fastcgi-script              .fcgi .fcg .fpl&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Action      application&#x2F;x-httpd-php5    &#x2F;fastcgi-bin&#x2F;php5.fcgi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    AddType     application&#x2F;x-httpd-php5    .php .php5&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;&#x2F;IfModule&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ScriptAlias &#x2F;fastcgi-bin&#x2F; &amp;quot;&#x2F;usr&#x2F;local&#x2F;www&#x2F;fastcgi-bin&#x2F;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;Location &#x2F;fastcgi-bin&#x2F;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Options ExecCGI&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    SetHandler fastcgi-script&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Order allow,deny&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Allow from all&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;&#x2F;Location&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;That&#x27;s it. Restart apache and watch as the first time you access a PHP script
FastCGI will spawn several of them, and they start serving requests. Load
usage may seem higher, that is because unlike Apache the standalone running
PHP&#x27;s handle the jobs as they come in with whatever one is first, Apache will
try to put as much work in one of its preforked modules. As the PHP processes
come and go through FastCGI the memory usage will go up and down. Mine has
an average of about 300 MB, which is very good compared to the 800 MB Apache
with &lt;code&gt;mod_php&lt;&#x2F;code&gt; would rack up.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Backup Script</title>
        <published>2006-09-09T00:33:02+00:00</published>
        <updated>2006-09-09T00:33:02+00:00</updated>
        
        <author>
          <name>
            
              Delta Regeer
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://funcptr.net/2006/backup-script/"/>
        <id>https://funcptr.net/2006/backup-script/</id>
        
        <content type="html" xml:base="https://funcptr.net/2006/backup-script/">&lt;p&gt;I was working on some backup scripts and I decided I might as well generalise
almost all of it (I am sorry about the hard coded paths) so almost anyone can
come grab it and use it on their servers. The shell script is pretty self
explanatory and I am not very good at documenting code, so the script source
itself is your best bet as to why I did something some way. This script is in
production use on several servers I administrate, I hope someone can use it as
well.&lt;&#x2F;p&gt;
&lt;p&gt;Documentation on how to use it:&lt;&#x2F;p&gt;
&lt;p&gt;A backup script which will mount &lt;code&gt;&#x2F;backup&lt;&#x2F;code&gt;, then use rsync to copy files from
&lt;code&gt;&#x2F;usr&#x2F;home&lt;&#x2F;code&gt; to &lt;code&gt;&#x2F;backup&#x2F;yyyy-mm-dd&lt;&#x2F;code&gt;. After it is done, it will remove the
oldest backup, 14 days ago. All paths are hardcoded.&lt;&#x2F;p&gt;
&lt;p&gt;If a file &lt;code&gt;.exclude&lt;&#x2F;code&gt; is in a user&#x27;s homedir, it is looked at, and is used to
exclude certain directories or files from the rsync. For example:&lt;&#x2F;p&gt;
&lt;p&gt;In &lt;code&gt;&#x2F;usr&#x2F;home&#x2F;xistence&#x2F;.exclude&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;public_html&#x2F;iso&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;No trailing slash, this will cause the folder
&lt;code&gt;&#x2F;usr&#x2F;home&#x2F;xistence&#x2F;public_html&#x2F;iso&lt;&#x2F;code&gt; to not be backed up. This might be for
various reasons, but for this example it is because backing up GB sized files
should not be something that is done, only because it takes ages and wastes
valuable space.&lt;&#x2F;p&gt;
&lt;p&gt;Thing to keep in mind is, if you want to backup a 40 GB HD, with 22 GB used,
to keep even a 3 day backup of that would require 3 * 22 GB, or 66 GB of
available space on the backup drive. It is therefore in one&#x27;s best interest
to exclude very large files, and back them up in a different method since
they are most likely not going to change much across revisions.&lt;&#x2F;p&gt;
&lt;p&gt;This script should be set to cron every 30 minutes, as rsync will do one full
backup when the day changes, and then from there on do incremental backups.&lt;&#x2F;p&gt;
&lt;p&gt;Maybe removing the &lt;code&gt;--delete&lt;&#x2F;code&gt; option might help with customers that delete
files and expect them to still be in the backup for that day, this way
however if a file is removed it will still exist in the backup until it is
deleted after 14 days.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;#!&#x2F;usr&#x2F;local&#x2F;bin&#x2F;bash&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;# This file REQUIRES bash, and can not be run under &#x2F;bin&#x2F;sh!&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;###&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # Copyright 2006 Delta Regeer. All rights  reserved.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; #&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # Redistribution and use in source and binary forms, with or without&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # modification, are permitted provided that the following conditions&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # are met:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # 1. Redistributions of source code must retain the above copyright&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; #    notice, this list of conditions and the following disclaimer.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # 2. Redistributions in binary form must reproduce the above copyright&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; #    notice, this list of conditions and the following disclaimer in the&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; #    documentation and&#x2F;or other materials provided with the distribution.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; #&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS&amp;#39;&amp;#39; AND&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # SUCH DAMAGE.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; #&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # The views and conclusions contained in the software and  documentation are&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # those of the authors and should not be  interpreted as representing official&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; # policies, either expressed  or implied, of bsdPanel project.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; #&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;###&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;for&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt; HOMEDIR&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; `&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;&#x2F;usr&#x2F;bin&#x2F;find&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;usr&#x2F;home&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -type&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -maxdepth&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt; grep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -v&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;^.$&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;`&lt;&#x2F;span&gt;&lt;span&gt;;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt; do&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;	if&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt; -f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt; $HOMEDIR&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;.exclude ];&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt; then&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;font-style: italic;&quot;&gt;		echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;Exclude found for &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;$HOMEDIR&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;		while&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;font-style: italic;&quot;&gt; read&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; line&lt;&#x2F;span&gt;&lt;span&gt;;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt; do&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;			if&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;${&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;line&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt; !=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; ];&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt; then&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;				# They are missing a full path, we will be nice and add it&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;				TMPLINE&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;$HOMEDIR&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;$line&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;				line&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;$TMPLINE&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;			fi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;font-style: italic;&quot;&gt;			echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;	Excluding &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;$line&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;font-style: italic;&quot;&gt;			echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt; $line&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; &amp;gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;tmp&#x2F;exclude.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;$$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;		done&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt; $HOMEDIR&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;.exclude&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;	fi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;done&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;mount&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt; grep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;backup&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; $?&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt; -ne&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span&gt; ];&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt; then&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;	&#x2F;sbin&#x2F;mount&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;backup&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;	if&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; $?&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt; -ne&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span&gt; ];&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt; then&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;		logger&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -s -p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; user.err&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -t&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; backup&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;Backup drive could not be mounted! Bailing!&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;		&#x2F;sbin&#x2F;umount&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;backup&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;font-style: italic;&quot;&gt;		exit&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;	fi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;fi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;BACKUPDIR&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;&#x2F;backup&#x2F;`&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;date&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;+%Y-%m-%d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;`&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;OLDDIR&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;&#x2F;backup&#x2F;`&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;date&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -v-14d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;+%Y-%m-%d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;`&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt; ! -d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt; $BACKUPDIR&lt;&#x2F;span&gt;&lt;span&gt; ];&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt; then&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;	mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt; $BACKUPDIR&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;fi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; $?&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt; -ne&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span&gt; ];&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt; then&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;	logger&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -s -p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; user.err&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -t&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; backup&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;Could not create backup folder &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;$BACKUPDIR&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;. Bailing!&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;	&#x2F;sbin&#x2F;umount&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;backup&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;font-style: italic;&quot;&gt;	exit&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;fi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;# We got this far, now we have to run rsync. Rsync is very verbose on purpose&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;&#x2F;usr&#x2F;local&#x2F;bin&#x2F;rsync&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -av --relative --delete&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;usr&#x2F;home&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt; $BACKUPDIR&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; --exclude-from=&#x2F;tmp&#x2F;exclude.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;$$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; $?&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt; -ne&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span&gt; ];&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt; then&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;	logger&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -s -p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; user.err&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -t&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; backup&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;rsync failed. Do not trust backup (&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;$BACKUPDIR&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;	&#x2F;sbin&#x2F;umount&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;backup&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;font-style: italic;&quot;&gt;	exit&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;fi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C5E478;font-style: italic;&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;Backup complete! Deleting oldest backup (14 days ago)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt; -d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt; $OLDDIR&lt;&#x2F;span&gt;&lt;span&gt; ];&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt; then&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;	rm&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -rf&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt; $OLDDIR&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C792EA;font-style: italic;&quot;&gt;fi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;&#x2F;sbin&#x2F;umount&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;backup&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;&#x2F;bin&#x2F;rm&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; &#x2F;tmp&#x2F;exclude.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;$$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;logger&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -s -p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; user.notice&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -t&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; backup&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;Backup complete at &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;$BACKUPDIR&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D9F5DD;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;</content>
        
    </entry>
</feed>
