<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Bsd on Geek Cabinet</title>
    <link>https://geekcabi.net/tags/bsd/</link>
    <description>Recent content in Bsd on Geek Cabinet</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 14 Feb 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://geekcabi.net/tags/bsd/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Check for Updates to OPNSense from the Command Line</title>
      <link>https://geekcabi.net/posts/opnsense-check-update/</link>
      <pubDate>Tue, 14 Feb 2023 00:00:00 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/opnsense-check-update/</guid>
      <description>&lt;p&gt;As part of my morning routine, I have a few scripts I run to make sure my laptop and servers are up to date.&lt;/p&gt;
&lt;p&gt;Rather than login to the web GUI of my OPNSense firewall, I created an alias to check for updates from the CLI.&lt;/p&gt;
&lt;p&gt;Add the following line to &lt;code&gt;.bash_aliases&lt;/code&gt; or directly to &lt;code&gt;.bashrc&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;alias check-update=&amp;#39;sudo /usr/local/opnsense/scripts/firmware/launcher.sh check&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;There are a few small, but interesting, additional steps required for the alias to work over a &amp;ldquo;non-interactive&amp;rdquo; SSH session.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>As part of my morning routine, I have a few scripts I run to make sure my laptop and servers are up to date.</p>
<p>Rather than login to the web GUI of my OPNSense firewall, I created an alias to check for updates from the CLI.</p>
<p>Add the following line to <code>.bash_aliases</code> or directly to <code>.bashrc</code>:</p>
<pre tabindex="0"><code>alias check-update=&#39;sudo /usr/local/opnsense/scripts/firmware/launcher.sh check&#39;
</code></pre><p>There are a few small, but interesting, additional steps required for the alias to work over a &ldquo;non-interactive&rdquo; SSH session.</p>
<p>First, include the <code>-t</code> parameter with ssh to force the use of a psuedo-tty (so sudo will work). And instead of calling the alias directly, invoke bash and pass the alias as the command. The combined flags of <code>-ic</code> to bash make all that work together. (Credit goes to <a href="https://www.cyberciti.biz/faq/use-bash-aliases-ssh-based-session/" rel="noopener" target="_blank" class="external">Cyberciti.biz</a> for explaining these options to me.)</p>
<p>All of the above results in allowing me to run this from my terminal:</p>
<pre tabindex="0"><code>me@macbookpro:~ ssh -t opnsense /usr/local/bin/bash -ic &#39;check-update&#39;
</code></pre><p>resulting in output similar to the following:</p>
<pre tabindex="0"><code>Updating OPNsense repository catalogue...
Fetching meta.conf: . done
Fetching packagesite.pkg: .......... done
Processing entries: .......... done
OPNsense repository update completed. 822 packages processed.
All repositories are up to date.
Checking integrity... done (0 conflicting)
Your packages are up to date.
Checking for upgrades (0 candidates): . done
Processing candidates (0 candidates): . done
Checking integrity... done (0 conflicting)
Your packages are up to date.
</code></pre>]]></content:encoded>
    </item>
    
    <item>
      <title>OPNSense and BSD Boot Environments</title>
      <link>https://geekcabi.net/posts/opnsense-boot-environments/</link>
      <pubDate>Fri, 04 Nov 2022 00:00:00 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/opnsense-boot-environments/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve been using OPNSense for my home firewall for many years now, and I previously ran it as a VM in a Proxmox virtual server. That worked great for my purposes, but I&amp;rsquo;ve since upgraded to a dedicated physical device (Protectli) running OPNSense and I love it.&lt;/p&gt;
&lt;p&gt;However, with the migration away from a VM, I lost the ability to create a snapshot of the system prior to an upgrade - just in case something went wrong I could easily roll back.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I&rsquo;ve been using OPNSense for my home firewall for many years now, and I previously ran it as a VM in a Proxmox virtual server. That worked great for my purposes, but I&rsquo;ve since upgraded to a dedicated physical device (Protectli) running OPNSense and I love it.</p>
<p>However, with the migration away from a VM, I lost the ability to create a snapshot of the system prior to an upgrade - just in case something went wrong I could easily roll back.</p>
<p>Recently I learned about BSD Boot Environments and the <a href="https://www.gsp.com/cgi-bin/man.cgi?topic=BECTL" rel="noopener" target="_blank" class="external">bectl utility</a> and how they can help fill that gap!</p>
<ol>
<li>
<p>Login via SSH and start a shell session</p>
</li>
<li>
<p>List any current/previoius boot environment (BE) snapshots</p>
</li>
</ol>
<pre tabindex="0"><code>root@opnsense-fw:~ # bectl list
BE     Active Mountpoint Space Created
22.7.2 -      -          1.04G 2021-09-05 10:57
22.7.4 -      -          388M  2022-09-02 09:28
22.7.5 NR     /          4.09G 2022-10-05 08:58
</code></pre><p>In the &ldquo;Active&rdquo; column, the &ldquo;N&rdquo; stands for &ldquo;Now&rdquo; and &ldquo;R&rdquo; is &ldquo;Reboot&rdquo;, showing which BE is active now vs after the next reboot.</p>
<ol start="3">
<li>Create and activate a new BE</li>
</ol>
<pre tabindex="0"><code>root@opnsense-fw:~ # bectl create [new_version]
root@opnsense-fw:~ # bectl activate [new_version]
</code></pre><ol start="4">
<li>Reboot and upgrade</li>
<li>Validate BE; Remove oldest BE</li>
</ol>
<pre tabindex="0"><code>root@opnsense-fw:~ # bectl list
BE     Active Mountpoint Space Created
22.7.2 -      -          1.04G 2021-09-05 10:57
22.7.4 -      -          896M  2022-09-02 09:28
22.7.5 NR     /          4.84G 2022-10-05 08:58
root@opnsense-fw:~ # bectl destroy 22.7.2
root@opnsense-fw:~ # bectl list
BE     Active Mountpoint Space Created
22.7.4 -      -          1.13G 2022-09-02 09:28
22.7.5 NR     /          3.80G 2022-10-05 08:58
</code></pre>]]></content:encoded>
    </item>
    
  </channel>
</rss>
