<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[spot #nix]]></title><description><![CDATA[the feeble attempt to understand.]]></description><link>https://mesa.monu.net/spotnix/</link><generator>Ghost 0.7</generator><lastBuildDate>Fri, 08 May 2026 21:37:45 GMT</lastBuildDate><atom:link href="https://mesa.monu.net/spotnix/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Tasmota config for Sonoff Mini]]></title><description><![CDATA[<p>Set inverted follow switch mode:  </p>

<pre><code>SwitchMode 2  
</code></pre>

<p>If this is a switch where you are controlling devices through MQTT and you don't want direct relay control, like say if you have smart-plugs on the switched outlet or you just want it to control smart-bulbs in various places, you need this:</p>]]></description><link>https://mesa.monu.net/spotnix/tasmota-config-for-sonoff-mini/</link><guid isPermaLink="false">ca6900b3-06ff-4d68-8951-6caa3ef0f5ca</guid><dc:creator><![CDATA[trick tricklyson]]></dc:creator><pubDate>Sat, 05 Jun 2021 03:20:41 GMT</pubDate><content:encoded><![CDATA[<p>Set inverted follow switch mode:  </p>

<pre><code>SwitchMode 2  
</code></pre>

<p>If this is a switch where you are controlling devices through MQTT and you don't want direct relay control, like say if you have smart-plugs on the switched outlet or you just want it to control smart-bulbs in various places, you need this:</p>

<pre><code>Backlog Rule1 on switch1#state=1 do publish mini4/stat/SWITCH1 {"STATE":"ON"} endon  
Backlog Rule1 + on switch1#state=0 do publish mini4/stat/SWITCH1 {"STATE":"OFF"} endon  
Rule1 on  
</code></pre>

<p>Then you can set up the appropriate automation in HA based on the Mini's switch.</p>

<p>(The previous version of the code I have for this was before the days of MQTT HomeAssistant auto-discovery in Tasmota, via <code>SetOption19 1</code>. Which has now been superceded by <code>SetOption19 0</code> Tasmota integration auto-discovery in HomeAssistant. Try to keep up.)</p>

<p>Oh. Neat. Apparently Switch&lt;->Relay detachment is superceded with an option, if you have it... I do not, on v8.1.0. If you do:</p>

<pre><code>SetOption114 1  
</code></pre>]]></content:encoded></item><item><title><![CDATA[Lossless audio trim with FFMPEG]]></title><description><![CDATA[<p>When dealing with lossy audio, you really don't want to re-encode it to isolate sections. Enter FFMPEG:</p>

<p><code>ffmpeg -y -i youtube-audio-file.webm -ss 00:31:26.0 -t 00:00:27.0 -c:a copy useable-file.opus</code></p>

<p>ss is the starting time. t is the duration of the section you</p>]]></description><link>https://mesa.monu.net/spotnix/lossless-audio-trim-with-ffmpeg/</link><guid isPermaLink="false">fe4b221c-f36a-44e3-af54-86c8c1e9dedf</guid><dc:creator><![CDATA[trick tricklyson]]></dc:creator><pubDate>Tue, 05 May 2020 17:48:09 GMT</pubDate><content:encoded><![CDATA[<p>When dealing with lossy audio, you really don't want to re-encode it to isolate sections. Enter FFMPEG:</p>

<p><code>ffmpeg -y -i youtube-audio-file.webm -ss 00:31:26.0 -t 00:00:27.0 -c:a copy useable-file.opus</code></p>

<p>ss is the starting time. t is the duration of the section you are capturing.</p>]]></content:encoded></item><item><title><![CDATA[Working with QR]]></title><description><![CDATA[<p>It is pretty easy and obvious to find <code>qrencode</code> for creating QR codes out of text files. Helpful in a world where wifi networks and wireguard configs can be transferred by QR.</p>

<p>Suppose you want to actually see the encoded text, if, for example, you want to manually make a</p>]]></description><link>https://mesa.monu.net/spotnix/working-with-qr/</link><guid isPermaLink="false">f4a562a3-7313-46d2-aea3-2aa071b17d28</guid><dc:creator><![CDATA[trick tricklyson]]></dc:creator><pubDate>Mon, 28 Oct 2019 20:30:48 GMT</pubDate><content:encoded><![CDATA[<p>It is pretty easy and obvious to find <code>qrencode</code> for creating QR codes out of text files. Helpful in a world where wifi networks and wireguard configs can be transferred by QR.</p>

<p>Suppose you want to actually see the encoded text, if, for example, you want to manually make a wifi QR file but don't know the text format some online converter gave you for a different net.</p>

<p>Turns out <code>zbarimg</code> from the gentoo zbar package (w/ use +imagemagick) gets you that capability.</p>

<pre><code>qrencode -r ~/wifi-info -o ~/wifi.png -t png  
# verify
zbarimg ~/wifi.png  
</code></pre>

<p>I also had to use this to figure out what wireguard wanted because the iOS app is insanely inflexible in what it considers to be a config file.</p>

<p>Also, just for fun, here's the wifi QR code format:</p>

<pre><code>Vars: ssid_name, wifi_password  
QR-Code:WIFI:S:ssid_name;T:WPA;P:wifi_password;;  
</code></pre>]]></content:encoded></item><item><title><![CDATA[sqlite3 maintenance]]></title><description><![CDATA[<p>Dump database to SQL <br>
<code>echo ".dump" | sqlite3 /path/to/database_file.db &gt; /path/to/output.sql</code></p>

<p>Detect malformation (Output <code>ok</code> means database is valid) <br>
<code>sqlite3&gt; PRAGMA integrity_check;</code></p>

<p>New database from SQL contents <br>
<code>echo ".read /path/to/output.sql" | sqlite3 /path/to/new_database_file.db</code></p>

<p>Making your</p>]]></description><link>https://mesa.monu.net/spotnix/sqlite3-maintenance/</link><guid isPermaLink="false">2c7dd421-ba6f-4aeb-9ac2-8afae583ffbb</guid><dc:creator><![CDATA[trick tricklyson]]></dc:creator><pubDate>Thu, 25 Jul 2019 03:42:28 GMT</pubDate><content:encoded><![CDATA[<p>Dump database to SQL <br>
<code>echo ".dump" | sqlite3 /path/to/database_file.db &gt; /path/to/output.sql</code></p>

<p>Detect malformation (Output <code>ok</code> means database is valid) <br>
<code>sqlite3&gt; PRAGMA integrity_check;</code></p>

<p>New database from SQL contents <br>
<code>echo ".read /path/to/output.sql" | sqlite3 /path/to/new_database_file.db</code></p>

<p>Making your dump compatible with other SQL servers (MariaDB/MySQL)</p>

<ul>
<li>Remove double quotes around column names, search <code>CREATE TABLE</code>, <code>CREATE INDEX</code></li>
<li>Remove <code>PRAGMA foreign_keys=OFF;</code></li>
<li>Remove <code>BEGIN TRANSACTION;</code> and <code>COMMIT;</code> if you don't feel the need to create and populate a full DB in one transaction...</li>
</ul>]]></content:encoded></item><item><title><![CDATA[base64 encoded hash bytes]]></title><description><![CDATA[<p>There are a number of places where you want a base64 encoded version of some kind of hash. Sometimes people wind up base64 encoding the hex string instead of the bytes, which is gross.  </p>

<pre><code>echo -n 'passphrase' |\  
sha512sum |\  
awk '{print $1}' |\  
xxd -r -p |\  
base64 -w 0  
</code></pre>

<p>Replace</p>]]></description><link>https://mesa.monu.net/spotnix/base64-encoded-hashes/</link><guid isPermaLink="false">f5a9caed-e977-4e67-b0de-19d3ae639ca7</guid><dc:creator><![CDATA[trick tricklyson]]></dc:creator><pubDate>Tue, 18 Dec 2018 21:26:02 GMT</pubDate><content:encoded><![CDATA[<p>There are a number of places where you want a base64 encoded version of some kind of hash. Sometimes people wind up base64 encoding the hex string instead of the bytes, which is gross.  </p>

<pre><code>echo -n 'passphrase' |\  
sha512sum |\  
awk '{print $1}' |\  
xxd -r -p |\  
base64 -w 0  
</code></pre>

<p>Replace <code>sha512sum</code> with the CLI hasher of your choosing, and adjust (or remove) awk as needed.</p>]]></content:encoded></item><item><title><![CDATA[Fixing Let's Encrypt tls-sni-01 destruction]]></title><description><![CDATA[<p>Let's Encrypt disabled <code>tls-sni-01</code> certificate request verification in January 2018. This broke LE for anyone w/o port 80 or programmable DNS. The only option now seems to be <code>tls-alpn-01</code>, which is only supported reasonably via the dehydrated.io LE client (from git, not released (11/2018)).</p>

<p>You still have</p>]]></description><link>https://mesa.monu.net/spotnix/fixing-lets-encrypt-tls-sni-01-destruction/</link><guid isPermaLink="false">3a4dd66f-52e9-4b95-985a-811e41af6414</guid><dc:creator><![CDATA[trick tricklyson]]></dc:creator><pubDate>Tue, 20 Nov 2018 10:46:57 GMT</pubDate><content:encoded><![CDATA[<p>Let's Encrypt disabled <code>tls-sni-01</code> certificate request verification in January 2018. This broke LE for anyone w/o port 80 or programmable DNS. The only option now seems to be <code>tls-alpn-01</code>, which is only supported reasonably via the dehydrated.io LE client (from git, not released (11/2018)).</p>

<p>You still have to code out your own <code>alpn-responder.py</code>, but there's a workable sample on the net.</p>

<p>You have to provide some kind of self-signed cert for it in lieu of ubuntu/debian? snakeoil key/cert pairs that seem to exist.</p>

<p>With dehydrated configured and my alpn-responder wrapped in an openrc init script, I was able to rewrite the ansible playbook without much trouble. The hard part was adapting it to distribute the cert to hass.io locally on rpi.</p>]]></content:encoded></item><item><title><![CDATA[Containerizing old Ghost sites]]></title><description><![CDATA[<p>I recently had to upgrade a machine running some older software. Node applications are extremely finicky about versions ... of node ... of JS libs ... of native libs, etc. I had to get some old Ghost web applications that were unexported running in order to export/upgrade them. It's a pretty hacky</p>]]></description><link>https://mesa.monu.net/spotnix/containerizing-old-ghost-sites/</link><guid isPermaLink="false">df28f5df-c303-4cf9-bd5a-9c7073016430</guid><dc:creator><![CDATA[trick tricklyson]]></dc:creator><pubDate>Tue, 20 Nov 2018 10:33:14 GMT</pubDate><content:encoded><![CDATA[<p>I recently had to upgrade a machine running some older software. Node applications are extremely finicky about versions ... of node ... of JS libs ... of native libs, etc. I had to get some old Ghost web applications that were unexported running in order to export/upgrade them. It's a pretty hacky container process, but it worked.</p>

<p>The plan: <code>mhart/alpine-node</code> supports versions back to 0.10 series, perfect. I need sqlite, so I lifted the trivial Docker recipe to add from <code>jansanchez/sqlite-alpine</code>:</p>

<pre><code>RUN apk update \  
  &amp;&amp; apk add sqlite \
  &amp;&amp; apk add socat
</code></pre>

<p>Buuuut... prebuilt sqlite3 JS lib has builtin symbol ref for memcpy on glibc. Alpine uses musl. Supposedly some kind of newer version has a patch that is necessary over <code>node_modules/sqlite3/src/gcc-preinclude.h</code>. Of course, it's not in what gets pulled down, so patching is required.</p>

<p>See discussion at <a href="https://github.com/mapbox/node-sqlite3/issues/459">https://github.com/mapbox/node-sqlite3/issues/459</a></p>

<pre><code>--- a/sqlite3/src/gcc-preinclude.h    2015-05-08 07:48:21.000000000 -0700
+++ b/sqlite3/src/gcc-preinclude.h    2018-11-18 12:10:23.528699071 -0800
@@ -1,6 +1,6 @@

 // https://rjpower9000.wordpress.com/2012/04/09/fun-with-shared-libraries-version-glibc_2-14-not-found/

-#if defined(__linux__) &amp;&amp; defined(__x86_64__)
+#if defined(__GLIBC__) &amp;&amp; defined(__linux__) &amp;&amp; defined(__x86_64__)
 __asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
 #endif
</code></pre>

<p>
Application within npm/docker process is a little tricky but doable. I included the patched file in my image build repo to avoid dealing w/ patch in alpine (maybe it would have been fine).  </p>

<pre><code>RUN apk add --no-cache make gcc g++ libc-dev python

RUN npm install -g node-pre-gyp  
RUN npm install --prod

RUN mv gcc-preinclude.h node_modules/sqlite3/src/gcc-preinclude.h  
WORKDIR node_modules/sqlite3  
RUN node-pre-gyp configure  
RUN node-pre-gyp build verbose  
</code></pre>

<p>Ready to build &amp; run on the coreOS host:  </p>

<pre><code>docker build -t n/ghost:1.0 /data/docker_import/ghost  
docker run -d --name ghost1 --restart unless-stopped --mount type=bind,src=/data/ghost1,dst=/app/content --dns x.x.x.x -p x.x.x.x:2369:2369 -e NODE_ENV=production n/ghost:1.0  
</code></pre>]]></content:encoded></item><item><title><![CDATA[systemd mount units]]></title><description><![CDATA[<p>I needed to add a lot of storage to /var/lib/docker on a coreOS qemu VM using a version of their <code>coreos_production_qemu.sh</code> script.</p>

<pre><code># add to ignition yaml:
systemd:  
  units:
    - name: var-lib-docker.mount
      enable: true
      contents: |
        [Unit]
        Before=local-fs.target
        [Mount]
        What=/dev/disk/by-label/docker_</code></pre>]]></description><link>https://mesa.monu.net/spotnix/systemd-mount-units/</link><guid isPermaLink="false">226ac984-337e-4c49-89ee-2f99d60fb284</guid><dc:creator><![CDATA[trick tricklyson]]></dc:creator><pubDate>Tue, 20 Nov 2018 10:32:55 GMT</pubDate><content:encoded><![CDATA[<p>I needed to add a lot of storage to /var/lib/docker on a coreOS qemu VM using a version of their <code>coreos_production_qemu.sh</code> script.</p>

<pre><code># add to ignition yaml:
systemd:  
  units:
    - name: var-lib-docker.mount
      enable: true
      contents: |
        [Unit]
        Before=local-fs.target
        [Mount]
        What=/dev/disk/by-label/docker_data
        Where=/var/lib/docker
        Type=ext4
        Options=rw,relatime,seclabel,data=ordered
        [Install]
        WantedBy=local-fs.target

# regenerate ignition json:
ct -in-file tansu-config.yml -out-file tansu-config.ignition 

# create disk image
qemu-img create -f raw /data/coreos/tansu_docker.img 500G

# add line to wrapper script around coreos_production_qemu.sh:
-drive if=virtio,format=raw,file=/data/coreos/tansu_docker.img,discard=unmap \

# restart coreOS, format ext4, mount new disk,
rsync -xavSH /var/lib/docker/ /mnt/  
# create /etc/systemd/system/var-lib-docker.mount
systemctl enable var-lib-docker.mount  
# stop docker containers
systemctl stop docker  
rsync -xavSH /var/lib/docker/ /mnt/  
# reboot
</code></pre>

<p><strong>Important bit about systemd mounts:</strong> unit file must be named according to Where path. <code>docker.mount</code> would fail with a delightfully useless error message, <code>var-lib-docker.mount</code> is what the unit must be called.</p>]]></content:encoded></item><item><title><![CDATA[CLI Manual Restoring from Time Machine]]></title><description><![CDATA[<p>Restoring, for example, your SSH Host keys after a fresh Mac OS install.</p>

<pre><code># skip some of the ExAttr stuff during copy
cp -pX /Volumes/time-machine/Backups.db/host/Latest/etc/ssh_host* /etc/ssh_host*

# list ACLs
ls -le /etc/ssh_host*

# remove ACLs
chown -N /etc/ssh_host*

# fix</code></pre>]]></description><link>https://mesa.monu.net/spotnix/restoring-from-time-machine-cli/</link><guid isPermaLink="false">1c94db8e-b88c-4891-90c2-3d26b1363149</guid><dc:creator><![CDATA[trick tricklyson]]></dc:creator><pubDate>Tue, 17 Nov 2015 03:49:34 GMT</pubDate><content:encoded><![CDATA[<p>Restoring, for example, your SSH Host keys after a fresh Mac OS install.</p>

<pre><code># skip some of the ExAttr stuff during copy
cp -pX /Volumes/time-machine/Backups.db/host/Latest/etc/ssh_host* /etc/ssh_host*

# list ACLs
ls -le /etc/ssh_host*

# remove ACLs
chown -N /etc/ssh_host*

# fix ownership if necessary
chown root:wheel /etc/ssh/ssh_host*  
</code></pre>]]></content:encoded></item><item><title><![CDATA[ssh + watch]]></title><description><![CDATA[<p>using <code>ssh</code> with <code>watch</code> for some basic monitoring? maybe a different ncurses or terminal-requiring binary you want to run often, but not from a directly interactive terminal session? </p>

<p>because <code>ssh x@y watch -n 60 bin</code> doesn't just work (<code>Error opening terminal: unknown.</code>), there's a temptation to use <code>watch -n</code></p>]]></description><link>https://mesa.monu.net/spotnix/ssh-watch/</link><guid isPermaLink="false">8a1a3c27-57c1-4b2d-826f-b2ea53b7d53e</guid><dc:creator><![CDATA[trick tricklyson]]></dc:creator><pubDate>Tue, 20 Oct 2015 06:57:38 GMT</pubDate><content:encoded><![CDATA[<p>using <code>ssh</code> with <code>watch</code> for some basic monitoring? maybe a different ncurses or terminal-requiring binary you want to run often, but not from a directly interactive terminal session? </p>

<p>because <code>ssh x@y watch -n 60 bin</code> doesn't just work (<code>Error opening terminal: unknown.</code>), there's a temptation to use <code>watch -n 60 ssh x@y bin</code>, which does just work. younger me did this in the ultra primitive raid monitoring i set up back in 2006 on the mac pro (i didn't want a daemonized <code>mdadm</code>, just not a fan). the shabby version of watch i installed for mac w/ fink back then has finally ceased functioning, so it was time to figure out:</p>

<p><code>ssh</code><strong><code>-t</code></strong><code>x@y watch -n 60 bin</code></p>

<p>to force pseudo tty allocation and make watch happy.</p>

<p>it has the added benefit of reducing the auth.log pollution from ssh'ing into raid hosts every 60 seconds to <code>cat /proc/mdstat</code>, as now <code>watch</code> runs on the local host in a long-running ssh session. always the preferred outcome, just not instantaneously worky. i recall wanting to know if fink would work for installing <code>watch</code>, as it was lacking on the mac platform.</p>

<p>i also set up graylog for a modernish alert delivery mechanism, but fixing the old thing is nice too. it has, technically, worked quite well to date, but now that email is everywhere there's a win to be had there.</p>]]></content:encoded></item><item><title><![CDATA[mac os flat packages]]></title><description><![CDATA[<p>so you’ve decided you want at some files in an installer package, but it’s not the kind you can just “Show Package Contents” on; it’s a “flat” package.</p>

<pre><code>pkgutil --expand ~/Downloads/ExampleApp.pkg /tmp/ExampleApp.unpkg

# look at a file list, not needed for just extraction
lsbom</code></pre>]]></description><link>https://mesa.monu.net/spotnix/mac-os-flat-packages/</link><guid isPermaLink="false">225ab10c-281d-4f73-a5c4-0f91ee3f718a</guid><category><![CDATA[ultra basic]]></category><category><![CDATA[command usages]]></category><category><![CDATA[mac]]></category><dc:creator><![CDATA[trick tricklyson]]></dc:creator><pubDate>Wed, 22 Apr 2015 18:03:00 GMT</pubDate><content:encoded><![CDATA[<p>so you’ve decided you want at some files in an installer package, but it’s not the kind you can just “Show Package Contents” on; it’s a “flat” package.</p>

<pre><code>pkgutil --expand ~/Downloads/ExampleApp.pkg /tmp/ExampleApp.unpkg

# look at a file list, not needed for just extraction
lsbom comexample.pkg/Bom

# unpack the payload
cat Payload | gzip -d | cpio -id  
</code></pre>]]></content:encoded></item><item><title><![CDATA[mac os gentoo prefix for modern unix]]></title><description><![CDATA[<p>I like to have a modern, upgradeable unix layer on my macs. The kind of thing people use homebrew, macports, et al (back to fink) for.</p>

<p>I use gentoo prefix. Usually root-owned in users/shared … I also like to replace the openssh daemon mac os uses.</p>

<p>The process grows in</p>]]></description><link>https://mesa.monu.net/spotnix/mac-os-gentoo-prefix-for-modern-unix/</link><guid isPermaLink="false">2ee17e61-7383-448c-bc50-526c9da51457</guid><category><![CDATA[procedures]]></category><category><![CDATA[less basic]]></category><category><![CDATA[mac]]></category><dc:creator><![CDATA[trick tricklyson]]></dc:creator><pubDate>Fri, 17 Apr 2015 03:55:00 GMT</pubDate><content:encoded><![CDATA[<p>I like to have a modern, upgradeable unix layer on my macs. The kind of thing people use homebrew, macports, et al (back to fink) for.</p>

<p>I use gentoo prefix. Usually root-owned in users/shared … I also like to replace the openssh daemon mac os uses.</p>

<p>The process grows in diceyness perhaps. Here goes.</p>

<p>Only ever set it up once (per major os version), then rsync deploy.</p>

<p>I tried bootstrapping normally. Boy. That was a thing. Not recommended.</p>

<p>It was actually easier for me to take my existing 10.7 prefix and upgrade the CHOST on it/rebuild/upgrade. Not, you know, like a lot, but easier (it worked).</p>

<p><a href="https://wiki.gentoo.org/wiki/Changing_the_CHOST_variable">Changing the CHOST</a> - Gentoo Wiki was sort of semi-applicable, had some useful info.</p>

<p><a href="https://www.mail-archive.com/gentoo-alt@lists.gentoo.org/msg07087.html">clang on Mac OS X</a> was the most critical information nexus.</p>

<pre><code>#!/bin/bash

# this script upgrades a macos 10.7 portage 2.2.10 prefix installation
# into a macos 10.9 portage 2.2.14 prefix installation w/ clang/llvm3.5
# prefix purpose is universal ed25519 ssh (vim, coreutils, etc)

EPREFIX="/Users/Shared/gentoo/"

# user1 is original owner (username) of the prefix, user2 is new
USER1="XXX"  
USER2="XXXNew"

if [[ ${SHELL#${EPREFIX}} == ${SHELL} ]] ; then  
    # Fix weird segfaults due to missing LANG in environment
    perl -p -i -e 's/env -i HOME=\$HOME/env -i LANG=\$LANG HOME=\$HOME/' ${EPREFIX}startprefix
    echo "Fixed startprefix script"
    echo "run ${EPREFIX}startprefix now and rerun fix_gentoo.sh"
    exit 0;
fi

perl -p -i -e 's/XXX/XXXNew/g' ${EPREFIX}usr/lib/portage/pym/portage/const_autotool.py  
perl -p -i -e 's/XXX/XXXNew/g' ${EPREFIX}usr/share/portage/config/make.globals  
echo "Fixed portage user"

# CHOST Changeover
echo "CHOST=\"x86_64-apple-darwin13\"" &gt;&gt; ${EPREFIX}etc/portage/make.conf

# rebuild binutils-apple
emerge -v binutils-apple  
ln -s ${EPREFIX}usr/x86_64-apple-darwin13/binutils-bin ${EPREFIX}usr/x86_64-apple-darwin11/binutils-bin  
mkdir -p ${EPREFIX}usr/x86_64-apple-darwin11/x86_64-apple-darwin13/lib  
ln -s ${EPREFIX}usr/lib/gcc/x86_64-apple-darwin11/4.2.1 ${EPREFIX}usr/x86_64-apple-darwin11/x86_64-apple-darwin13/lib/gcc  
#ln -s ${EPREFIX}usr/x86_64-apple-darwin11/gcc-bin ${EPREFIX}usr/x86_64-apple-darwin13/gcc-bin
emerge -v binutils-config  
binutils-config 1  
env-update  
. ${EPREFIX}etc/profile

# rebuild gcc-apple
GCC_BUILDS=0  
while true; do  
    emerge -v gcc-apple
    STATUS=$?
    if [[ $STATUS == 0 ]]; then
        # gcc successfully built
        # this was taking about 5 attempts for me
         # really dunno what to say about that
        break;
    else
        GCC_BUILDS=$[$GCC_BUILDS + 1];
        if [ $GCC_BUILDS -gt 10 ]; then
            echo
            echo "GCC WOULD NOT BUILD AFTER 10 ATTEMPTS."
            echo
            exit 1;
        fi
    fi
done;  
rm ${EPREFIX}etc/env.d/04gcc-x86_64-apple-darwin11  
rm ${EPREFIX}etc/env.d/gcc/config-x86_64-apple-darwin11  
env-update  
. ${EPREFIX}etc/profile

# clean up, rebuild 4-5 packs, worked
emerge -v @preserved-rebuild  
rm -r ${EPREFIX}usr/x86_64-apple-darwin11  
rm -r ${EPREFIX}usr/bin/x86_64-apple-darwin11-*

# full changeover in profile, remove explicit CHOST
eselect profile set 5  
perl -p -i -e 's/CHOST="x86_64-apple-darwin13"//' ${EPREFIX}etc/portage/make.conf  
env-update  
. ${EPREFIX}etc/profile

# rebuild binutils w/ rebuilt gcc
emerge -v binutils-config binutils-apple  
. ${EPREFIX}etc/profile

# rebuild gcc w/ rebuilt gcc &lt;== this actually never worked
emerge -v gcc-config  
#GCC_BUILDS=0
#while true; do
#    emerge -v gcc-apple
#    STATUS=$?
#    if [[ $STATUS == 0 ]]; then
#        # gcc successfully built
#        break;
#    else
#        GCC_BUILDS=$[$GCC_BUILDS + 1];
#        if [ $GCC_BUILDS -gt 10 ]; then
#            echo
#            echo "GCC WOULD NOT REBUILD AFTER 10 ATTEMPTS."
#            echo
#            exit 1;
#        fi
#    fi
#done;

# UPDATE PORTAGE TREE
# 1ST PATH IS PATH TO AN UPDATED PORTAGE TREE, IN MY CASE FROM FAILED BOOTSTRAP
rsync -avSH --delete-after --exclude distfiles/ --exclude metadata/ ~XXX/gentoo/usr/portage/ ${EPREFIX}usr/portage/  
rsync -avSH /Users/XXX/gentoo/usr/portage/distfiles/ ${EPREFIX}usr/portage/distfiles/  
emerge -v dev-libs/libiconv gcc-config binutils-apple  
# libffi upgrade needed, can't rebuild gcc now w/o portage upgrade
. ${EPREFIX}etc/profile
emerge -v gmp autoconf-wrapper automake-wrapper  
emerge -v mpfr dev-libs/libffi pidof-bsd file less coreutils  
hash -r  
emerge -v patch  
# two-step upgrade to portage 2.2.14(+?)
emerge -v =sys-apps/portage-2.2.10.1-r1  
emerge -v portage  
emerge -v gcc-apple  
. ${EPREFIX}etc/profile
emerge -v ncurses  
echo "sys-devel/llvm  clang" &gt;&gt; ${EPREFIX}etc/portage/package.use  
emerge -v llvm:0/3.4

# get libcxx-apple ebuild
wget https://github.com/fishman/timebomb-gentoo-osx-overlay/archive/master.zip  
unzip master.zip  
mv timebomb-gentoo-osx-overlay-master/sys-libs/libcxx-apple ${EPREFIX}usr/local/portage/sys-libs/  
rm -r timebomb-gentoo-osx-overlay-master  
ebuild ${EPREFIX}usr/local/portage/sys-libs/libcxx-apple manifest  
emerge -v libcxx-apple  
# pulled in a bunch of subversion dep bullshit but fine.

# set up portage environment to use clang(11)
mkdir ${EPREFIX}etc/portage/env  
echo "CC=clang  
CXX=clang++  
CFLAGS=\"${CFLAGS} -stdlib=libstdc++\"  
CXXFLAGS=\"${CXXFLAGS} -stdlib=libstdc++\"" &gt; ${EPREFIX}etc/portage/env/clang  
echo "CC=clang  
CXX=clang++  
CFLAGS=\"${CFLAGS}\"  
CXXFLAGS=\"${CXXFLAGS} -std=c++11 -stdlib=libstdc++\"  
LDFLAGS=\"${LDFLAGS} -stdlib=libc++\"" &gt; ${EPREFIX}etc/portage/env/clang11

# use clang11 for llvm-3.5+ &amp; binutils-apple
echo "&gt;=sys-devel/llvm-3.5                    clang11" &gt;&gt; ${EPREFIX}etc/portage/package.env  
echo "sys-devel/binutils-apple:6[libcxx]      clang11" &gt;&gt; ${EPREFIX}etc/portage/package.env

emerge -v llvm:0/3.5

echo "&gt;=sys-devel/llvm-3.6.0" &gt;&gt; ${EPREFIX}etc/portage/package.mask

# building binutils-apple[libcxx] didn't happen

# strategically rebuild the system
emerge -v binutils-config  
emerge -v perl-cleaner perl  
perl-cleaner --all -- -v  
emerge -v gnuconfig gzip help2man which wget  
emerge -v ca-certificates eselect rsync glib:2 pkgconfig  
emerge -v python:2.7  
emerge -v libxslt gettext debianutils nano grep popt  
emerge -v gentoolkit baselayout-prefix  
emerge -vu csu libiconv perl-File-Spec automake libtool:2 expat \  
  perl-ExtUtils-Manifest ExtUtils-Manifest sed make gtk-doc-am
emerge -v dev-perl/libintl-perl  
emerge -v openssl

emerge --deselect -v pkgconfig glib:2 perl-cleaner ca-certificates portage python openssl groff \  
  eselect flex nano popt libxslt gettext libintl-perl Text-Unidecode gtk-doc-am debianutils expat \
  libtool:2 perl-ExtUtils-Manifest automake ExtUtils-Manifest help2man perl-File-Spec perl mpfr \
  gmp automake-wrapper autoconf-wrapper pax-utils libffi dev-libs/libiconv binutils-config \
  gcc-config mime-types zlib ncurses

# bzip won't build w/o FEATURE="allow_broken_install_names", i'm wary, just mask it
echo "&gt;=app-arch/bzip2-1.0.6-r7" &gt;&gt; ${EPREFIX}etc/portage/package.mask

emerge -v nano  
emerge -vtuDN --with-bdeps y world  
emerge -av --depclean  
eclean-dist


# do your upgrade of openssh now, an 1.8 ebuild w/ just --with-pam works w/ password auth on mac os 10.9
# patches would probably help the 4-5 second delay on login, but i'm not worrying about that for now
</code></pre>

<p>I installed llvm 3.4/clang &amp; used it to build llvm 3.5/clang, but didn’t actually use it for anything. just might sometime.</p>

<p>Additional SSH specific notes:</p>

<blockquote>
  <p>OpenSSH<em>6.8p1 prefix ebuild forces -pam, which, I guess makes sense in a prefix context, but I prefer to make the prefix sshd replace the system one, so just replace use</em>with pam to –with-pam to econf in the ebuild.
  DNS resolution is one of the more fail-forward things happening on mac os. To prevent a five second delay on logins, add UseDNS no to sshd<em>config. <br>
  Previous MacOS, like 10.7, had issues that required turning off AcceptEnv LANG LC</em>* in the sshd_config. With 10.9, the behavior is ‘upgraded’ to segfaulting on missing LANG in environment, so AcceptEnv LANG is very much required.</p>
</blockquote>

<p>END</p>

<p>follows the bootstrapping. first attempt.</p>

<p>TLDR: it doesn’t go very far, is very challenge, and requires much further research.</p>

<p>Download the newest bootstrap-prefix.sh script</p>

<p>''' <br>
export EPREFIX=/Users/X/gentoo <br>
./bootstrap-prefix.sh</p>

<p>hah yeah right! <br>
'''</p>

<p>set up in ~/gentoo … we’ll have to move/chown after bootstrap because it hates root (and wheel)</p>

<p>apparently the bootstrap process for mac os 10.9 is reaaaaaally terrible. probably 10.8 as well from what i’ve read. the main issues stem from apple removing vital gnu dev components. gcc, automake, autoconf, libtool, readline (replaced w/ an incompatible .h system-accessible). the next issue is determining the proper blend of –std=gnu89 during various stage emerging.</p>

<p>getting through stage1 &amp; 2 was quite difficult, involved path hacking, symlinking bash &amp; perl into future gentoo tree … coaxing things to build by temp moving system includes, adding proper include paths directly to cflags (gentoo/usr/include, gentoo/tmp/usr/include). i mean … grisly.</p>

<p>gcc-apple, for example, requires <code>CC="gcc -std=gnu89″</code>. coreutils, on the other hand, will only build in 99+ mode. try and let as much build in/with/available 99 mode as possible.</p>

<p><code>CC="gcc -std=gnu89 " emerge --oneshot --nodeps -av gcc-apple</code>
<code>emerge -av system</code> (deselect a bunch of stuff from world)
<code>emerge -av system</code> … goes ok, dies 37 pks in at gmp, –enable-cxx is on. fails super early, during configure, basically w/ no output.</p>

<p>interestingly, ncurses built fine w/ cxx enabled</p>

<p>in the bootstrapped environment, c++ stuff is not so build for some reason, perhaps substantial binary incompatibility due to gcc-apple 4.2. suspect llvm/clang would be ideal? gentoo llvm is at 3.6, apple is based on 3.5</p>

<p>install fsf gcc 4.7, use it (gcc-config, env-update, . gentoo/etc/profile) to build llvm/clang</p>

<p>llvm does not build.  </p>

<pre><code>Undefined symbols for architecture x86_64:  
  "llvm::TargetRegisterInfo::composeSubRegIndexLaneMaskImpl(unsigned int, unsigned int) const", referenced from:
      vtable for llvm::TargetRegisterInfo in libLLVMCodeGen.a(TargetRegisterInfo.o)
  "llvm::TargetRegisterInfo::composeSubRegIndicesImpl(unsigned int, unsigned int) const", referenced from:
      vtable for llvm::TargetRegisterInfo in libLLVMCodeGen.a(TargetRegisterInfo.o)
ld: symbol(s) not found for architecture x86_64  
collect2: error: ld returned 1 exit status  
/Users/table/gentoo/var/tmp/portage/sys-devel/llvm-3.6.0/work/llvm-3.6.0.src/Makefile.rules:1199: recipe for target '/Users/table/gentoo/var/tmp/portage/sys-devel/llvm-3.6.0/work/llvm-3.6.0.src-.amd64/Release/lib/libLLVM-3.6.dylib' failed
</code></pre>

<p>hmm. some things seem to work. it is odd. openssh is def old &amp; shitty on 10.9… still kinda want that real sshd…</p>]]></content:encoded></item><item><title><![CDATA[gentoo perl 5.20 upgrade madness]]></title><description><![CDATA[<p>perl upgrade from 5.18 to 5.20 was a bit painful. i could tell it was looking … odd, on my machines w/ almost no perl packs installed (git deps basically). on those systems, the simple <code>emerge -utav perl</code> managed to work with only a few complaints.</p>

<p>my spam scanning</p>]]></description><link>https://mesa.monu.net/spotnix/gentoo-perl-5-20-upgrade-madness/</link><guid isPermaLink="false">7ed94710-eb7f-4ab1-b97d-acba2f5f515c</guid><category><![CDATA[command usages]]></category><category><![CDATA[procedures]]></category><category><![CDATA[interesting]]></category><category><![CDATA[linux]]></category><dc:creator><![CDATA[trick tricklyson]]></dc:creator><pubDate>Tue, 03 Mar 2015 20:21:00 GMT</pubDate><content:encoded><![CDATA[<p>perl upgrade from 5.18 to 5.20 was a bit painful. i could tell it was looking … odd, on my machines w/ almost no perl packs installed (git deps basically). on those systems, the simple <code>emerge -utav perl</code> managed to work with only a few complaints.</p>

<p>my spam scanning system, however, was another thing. amavis &amp; spamassassin = such perl. it took several hours to figure this stuff out (due to minutes long ‘calculating dependencies’ on this ancient hardware).</p>

<p>TLDR:  </p>

<pre><code>emerge -utav $(qlist -IC 'virtual/perl-*')  
</code></pre>

<p>OK. so. I’ve seen other issues in the past, and they boiled down to ‘having the wrong things’ in world (/var/lib/portage/world).</p>

<p>OK, yeah, I’ve got perl-core/IO-Socket-IP in there … 7 virtuals … 6ish dev-perl packs. Maybe it’s that.</p>

<pre><code>emerge --deselect -av IO-Socket-IP  
emerge -utavD perl  
# different, not fixed.
emerge --deselect -av virtual/perl-ExtUtils-ParseXS perl-File-Temp perl-IO-Zlib perl-Locale-Maketext-Simple perl-Net-Ping perl-Package-Constants perl-libnet  
emerge -utavD perl  
# different, not fixed.
emerge -utavD perl ... added all dev-perl packages ... then some others ... no help.

# start using qlist, from a gentoo forum suggestion
emerge -utav perl Net-HTTP JSON Net-DNS Net-SSLeay libwww-perl DBI DBD-mysql IO-Socket-IP HTML-Parser perl-version net-server perl-Pod-Parser spamassassin Net-Ping MIME-tools $(qlist -IC 'virtual/perl-*') dev-perl/extutils-pkgconfig  
emerge -utav perl Net-HTTP JSON Net-DNS Net-SSLeay libwww-perl DBI DBD-mysql IO-Socket-IP HTML-Parser perl-version net-server MIME-tools $(qlist -IC 'dev-perl/*') $(qlist -IC 'virtual/perl-*') dev-perl/extutils-pkgconfig amavisd-new  
emerge -utav $(qlist -IC 'dev-perl/*') $(qlist -IC 'virtual/perl-*') $(qlist -IC 'perl-core/*')

# aaaaaaand, this worked:
emerge -utav  $(qlist -IC 'virtual/perl-*')  
</code></pre>

<p>If you are having a hard time upgrading perl on gentoo, apparently emerge -u with all installed virtual/perl-* atoms is the way to go.</p>

<p>If it doesn’t work, I would guess that deselecting perl-core/* and virtual/perl-* from world was actually important.</p>]]></content:encoded></item><item><title><![CDATA[custom runlevels on gentoo openrc]]></title><description><![CDATA[<p>with openrc, the magic term is ’stacked runlevels’</p>

<p>suppose you have a server with sophisticated storage capabilities that you don’t always want to come up on boot. if, for example, booting in a recovery mode to poke around.</p>

<p>you could easily enough just add all the services to the</p>]]></description><link>https://mesa.monu.net/spotnix/custom-runlevels-on-gentoo-openrc/</link><guid isPermaLink="false">0d19330d-fe11-44d7-aa33-9a9eba642731</guid><category><![CDATA[command usages]]></category><category><![CDATA[ultra basic]]></category><category><![CDATA[linux]]></category><dc:creator><![CDATA[trick tricklyson]]></dc:creator><pubDate>Tue, 11 Nov 2014 19:19:00 GMT</pubDate><content:encoded><![CDATA[<p>with openrc, the magic term is ’stacked runlevels’</p>

<p>suppose you have a server with sophisticated storage capabilities that you don’t always want to come up on boot. if, for example, booting in a recovery mode to poke around.</p>

<p>you could easily enough just add all the services to the default runlevel and set up a bunch of lines in /etc/rc.conf to make your services depend (use/need) on a central ’storage’ service.</p>

<p>so yeah, i’ve done that, but i also still don’t want my services to start automatically. in this particular case, i actually want to have to manually start things after confirming other things.</p>

<p>so…enter stacked runlevel, allowing me to easily start a set of services.</p>

<p>set up new runlevel:  </p>

<pre><code># 'create' a runlevel called 'storage'
mkdir /etc/runlevels/storage  
# add the 'default' runlevel to the new runlevel
rc-update -s add default storage  
on boot, post-verify:

rc storage  
</code></pre>

<p>seems like it would have issues scaling to a variety of runlevel needs, but that’s why people use systemd. ’stacking’ works well ‘up’, not so great laterally.</p>]]></content:encoded></item><item><title><![CDATA[Attempts to increase networking performance on Mac OS 10.6]]></title><description><![CDATA[<p>While attempting to boost network block transfer performance, I made some changes to nvram boot-args and /etc/sysctl.conf</p>

<pre><code>nvram boot-args  
boot-args    maxloreserve=425 ncl=131072 initmcl=131072 nbuf=131072

sysctl.conf  
# boot time only: DONT WORK
# kern.ipc.maxsockets=2048
# kern.ipc.nmbclusters=131072


# regular net options:

#net.inet.</code></pre>]]></description><link>https://mesa.monu.net/spotnix/attempts-to-increase-networking-performance-on-mac-os-10-6/</link><guid isPermaLink="false">7f55f031-e9b9-44fa-8b40-910b222c64c1</guid><category><![CDATA[command usages]]></category><category><![CDATA[configuration values]]></category><category><![CDATA[mac]]></category><dc:creator><![CDATA[trick tricklyson]]></dc:creator><pubDate>Tue, 11 Nov 2014 02:42:00 GMT</pubDate><content:encoded><![CDATA[<p>While attempting to boost network block transfer performance, I made some changes to nvram boot-args and /etc/sysctl.conf</p>

<pre><code>nvram boot-args  
boot-args    maxloreserve=425 ncl=131072 initmcl=131072 nbuf=131072

sysctl.conf  
# boot time only: DONT WORK
# kern.ipc.maxsockets=2048
# kern.ipc.nmbclusters=131072


# regular net options:

#net.inet.tcp.delayed_ack=0
kern.maxfiles=204800  
#kern.ipc.maxsockets=204800

# Max backlog size, def 128

kern.ipc.somaxconn=4096

#kern.ipc.maxsockbuf=16777216
#kern.ipc.maxsockbuf=1572864
# previous entry:
#kern.ipc.maxsockbuf=8388608

# current:
#kern.ipc.maxsockbuf=33554432

#net.inet.tcp.sendspace=786432
#net.inet.tcp.recvspace=786432

# current :
#net.inet.tcp.sendspace=262144
#net.inet.tcp.recvspace=262144
#net.inet.tcp.sockthreshold=0
#net.smb.fs.tcpsndbuf=262144
#net.smb.fs.tcprcvbuf=262144
kern.sysv.shmmax=16777216  
kern.sysv.shmmin=1  
kern.sysv.shmmni=32  
kern.sysv.shmseg=8  
kern.sysv.shmall=4096



kern.ipc.maxsockbuf=4194304  
#kern.ipc.somaxconn=2048
#kern.ipc.nmbclusters=2048
net.inet.tcp.rfc1323=1  
net.inet.tcp.win_scale_factor=4  
net.inet.tcp.sockthreshold=16  
net.inet.tcp.sendspace=1042560  
net.inet.tcp.recvspace=1042560  
net.inet.tcp.mssdflt=1448  
net.inet.tcp.msl=15000  
net.inet.tcp.always_keepalive=0  
net.inet.tcp.delayed_ack=3  
net.inet.tcp.slowstart_flightsize=20  
net.inet.tcp.blackhole=2  
net.inet.udp.blackhole=1  
net.inet.icmp.icmplim=50  
</code></pre>

<p>I doubt that it is all correct at this point. I’ve noticed network interface resets.</p>]]></content:encoded></item></channel></rss>