<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Matt Ray&apos;s ramblings</title>
    <description>You&apos;ve somehow ended up reading Matt Ray&apos;s ramblings.</description>
    <link>https://mattray.github.io/</link>
    <atom:link href="https://mattray.github.io/feed.xml" rel="self" type="application/rss+xml" />
    <pubDate>Thu, 24 Oct 2024 00:46:51 +0000</pubDate>
    <lastBuildDate>Thu, 24 Oct 2024 00:46:51 +0000</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
    
      <item>
        <title>Preseed Installing Debian 11 on a Headless MacBook Pro</title>
        <description>&lt;p&gt;&lt;a href=&quot;https://www.ifixit.com/Device/MacBook_Pro_13%22_Function_Keys_Late_2016&quot;&gt;&lt;img src=&quot;/assets/macbookpro13.jpg&quot; alt=&quot;Late 2016 Function Keys MacBook Pro 13&quot; width=&quot;312&quot; height=&quot;234&quot; align=&quot;right&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My previous employer had a generous refurbished hardware program where we could purchase used laptops at a greatly discounted rate. I took advantage of this and bought a total of 5 2015 MacBook Airs and the IT folks generously threw in a 13” MacBook Pro with a broken screen, knowing my penchant for resuscitating broken hardware.&lt;/p&gt;

&lt;p&gt;The laptop screen would power up, but never displayed anything. While there was a potentially relevant Apple recall for displays, the repair was rejected because of apparent water damage to the machine. I attached a USB C HDMI adapter and that worked with macOS and I could have used the machine as a desktop with an external monitor, but I already had plenty of working laptops and didn’t really need it for that. I decided I would add it to my piecemeal cluster of Linux servers running Kubernetes, I just needed to get a clean installation of Debian on it.&lt;/p&gt;

&lt;p&gt;Unfortunately USB C HDMI is not well-supported by the Debian installer. In fact, nothing worked beyond the initial &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;grub&lt;/code&gt; installation screen. I initially went down the path of trying to use my &lt;a href=&quot;/2022/02/27/enabling-usb-serial-console&quot;&gt;USB serial console cable&lt;/a&gt;, but gave up after running into the harsh reality that USB serial consoles are very lightly documented (a few references in some grub documentation) and blocked by the USB Braille support in standard Debian installers (I did a build taking this out, still no luck).&lt;/p&gt;

&lt;h2 id=&quot;debian-preseeds&quot;&gt;Debian Preseeds&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://www.debian.org/releases/stable/amd64/apb.en.html&quot;&gt;Debian preseeds&lt;/a&gt; are a technique for automated installations where a preseed file is provided that answers the installer questions. This can be baked into the installation medium or provided through DHCP or a network location. Given that I could get the first screen of the installer, I figured it would be easiest if I used the network location to rapidly iterate over getting the right configuration in place.&lt;/p&gt;

&lt;p&gt;I was using the &lt;a href=&quot;https://www.debian.org/distrib/netinst#netboot&quot;&gt;Debian 11 Netboot installer&lt;/a&gt; flashed onto a USB thumbdrive with &lt;a href=&quot;https://www.balena.io/etcher/&quot;&gt;Balena Etcher&lt;/a&gt;. On a MacBook Air or MacBook Pro, if you want to boot a USB drive you hold down the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Option&lt;/code&gt; key while booting and you will eventually see an option titled &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EFI Boot&lt;/code&gt;, which is the Debian installer. This boots into the initial Debian installer menu which is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;grub&lt;/code&gt; providing various installation techniques.&lt;/p&gt;

&lt;h3 id=&quot;automated-installation&quot;&gt;Automated Installation&lt;/h3&gt;

&lt;p&gt;The Debian Installation Guide’s &lt;a href=&quot;https://www.debian.org/releases/stable/amd64/apbs04.en.html&quot;&gt;Contents of the preconfiguration file&lt;/a&gt; provides the basics that covered almost everything needed for the installation.&lt;/p&gt;

&lt;p&gt;To run the preseed, select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Advanced options ...&lt;/code&gt; and then select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;... Automated install&lt;/code&gt;. Press the “E” key to “Edit Selection”. You will be presented with a screen similar to&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;setparams &apos;... Automated install&apos;

    set background_color=black
    linux   /install.amd/vmlinux auto=true priority=critical vga=788 --- quiet
    initrd  /install.amd/initrd.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You need to provide the URL of the preseed file, which was served up by the simple webserver &lt;a href=&quot;https://www.lighttpd.net/&quot;&gt;lighttpd&lt;/a&gt; on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://10.0.0.2/preseed.cfg&lt;/code&gt;. In order to set the hostname and domain of the machine, I had to enter these as well because the &lt;a href=&quot;https://unix.stackexchange.com/questions/106614/preseed-cfg-ignoring-hostname-setting&quot;&gt;preseed did not set them for some reason&lt;/a&gt;. The 3rd line is updated to look similar to this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    linux   /install.amd/vmlinux auto=true priority=critical vga=788 --- quiet url=http://10.0.0.2/preseed.cfg netcfg/get_hostname=farnsworth netcfg/get_domain=bottlebru.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After making these changes, hit F10 to run the installation with your settings. I ran through this a few times with a working MacBook Air so I could verify the preseed settings were correct and iterate until I got everything right. Once it worked, I updated the preseed for the MacBook Pro and ran the installation. About 5 minutes later, I heard the distinctive Apple reboot sound and I was able to SSH into my new Linux server.&lt;/p&gt;

&lt;h2 id=&quot;2016-macbook-pro-preseed&quot;&gt;2016 MacBook Pro Preseed&lt;/h2&gt;

&lt;p&gt;Here are the contents of my &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;preseed.cfg&lt;/code&gt;, I added comments inline. Some of these may be extraneous, but it worked. A few things to note:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;localised for Australia&lt;/li&gt;
  &lt;li&gt;added &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mattray&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root&lt;/code&gt; users with hashed passwords&lt;/li&gt;
  &lt;li&gt;formatted the entire drive as a single partition&lt;/li&gt;
  &lt;li&gt;the MacBook Pro used &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/nvme0n1&lt;/code&gt; as the disk instead of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/sda&lt;/code&gt; on the older MacBook Airs&lt;/li&gt;
  &lt;li&gt;there is an &lt;a href=&quot;&quot;&gt;apt-cacher-ng&lt;/a&gt; proxy cache running at http://10.0.0.4:3142&lt;/li&gt;
  &lt;li&gt;the additional packages &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl emacs-nox htop openssh-server rsync sudo usbutils zsh&lt;/code&gt; are installed&lt;/li&gt;
  &lt;li&gt;Remote root SSH is enabled so I can login to the machine once it installs&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#_preseed_V1

### Network/Hostname
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string farnsworth
d-i netcfg/get_domain string bottlebru.sh
d-i netcfg/hostname string farnsworth.bottlebru.sh
# the above settings never seemed to work, but adding
# netcfg/get_hostname=farnsworth netcfg/get_domain=bottlebru.sh
# to the grub CLI worked

### Localization
# some of this is probably overkill
d-i debian-installer/country string AU
d-i debian-installer/language string en_AU:en
d-i debian-installer/locale select en_AU.UTF-8
d-i keyboard-configuration/xkb-keymap select us
d-i keymap select us
d-i time/zone string Australia/Sydney
tzdata tzdata/Areas select Australia
tzdata tzdata/Zones/Australia select Sydney
tzsetup-udeb time/zone select Australia/Sydney

### Clock/NTP
d-i clock-setup/utc boolean true
d-i clock-setup/ntp boolean true

### Users
d-i passwd/user-fullname string Matt Ray
d-i passwd/username string mattray
# encrypted using a crypt(3) hash from whois package `mkpasswd -m sha-512`
d-i passwd/root-password-crypted password $6$w.JmcUilXD1bk/$39EE73ghigxMpHaip03dNKq0ZuzDYYD/gq2F2GAEQJxbGRlL0zidd3u5RrTBsokQ8Kid9x89bOLdzjcMfbck3/
d-i passwd/user-password-crypted password $6$Z3rruwk5Et$zwi8MxWYY5E4/l3JCBEG60VJHNKHTUhcbTAFPZHNQS7VR.HAJFlmMLxXx.Ld0SpM8HoXzY.T9XlC5R6nbmyAY1

### Partitioning
d-i partman-auto/choose_recipe select atomic
d-i partman-auto/confirm boolean true
d-i partman-auto/disk string /dev/nvme0n1
d-i partman-auto/method string regular
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

### Package Sources
choose-mirror-bin mirror/http/countries select AU
choose-mirror-bin mirror/http/proxy string http://10.0.0.4:3142
d-i mirror/https/directory string /debian/
d-i mirror/https/hostname string deb.debian.org
d-i mirror/https/mirror select deb.debian.org

### System installation
d-i base-installer/install-recommends boolean false
d-i base-installer/kernel/override-image string linux-server
d-i debian-installer/splash boolean false
d-i pkgsel/include string curl emacs-nox htop openssh-server rsync sudo usbutils zsh
d-i pkgsel/install-language-support boolean false
d-i pkgsel/update-policy select none
d-i pkgsel/upgrade select full-upgrade
popularity-contest popularity-contest/participate boolean false
tasksel tasksel/first multiselect ssh-server
# the openssh settings never seemed to take
d-i preseed/late_command string \
 in-target sh -c &apos;sed -i &quot;s/^#PermitRootLogin.*\$/PermitRootLogin yes/g&quot; /etc/ssh/sshd_config&apos;;

### Finish and reboot
d-i grub-installer/only_debian boolean true
d-i grub-installer/bootdev  string /dev/nvme0n1
d-i finish-install/keep-consoles boolean false
d-i finish-install/reboot_in_progress note
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;usb-c-ethernet-adapters&quot;&gt;USB C Ethernet Adapters&lt;/h3&gt;

&lt;p&gt;I have a USB C gigabit ethernet adapter that utilizes the Realtek RTL8153 chipset, but that isn’t supported in the Linux 5.10 kernel shipped with Debian Bullseye/Stable. For my installation, I used a known-working 100 megabit ethernet adapter with a USB A-C adapter. After the installation, I had to use the &lt;a href=&quot;https://backports.debian.org/Instructions/&quot;&gt;Debian Backports&lt;/a&gt; &lt;a href=&quot;https://packages.debian.org/bullseye-backports/linux-image-amd64&quot;&gt;linux-image-amd64&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;apt install linux-image-amd64/bullseye-backports
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;farnsworth&quot;&gt;Farnsworth&lt;/h2&gt;

&lt;p&gt;With Debian Stable installed and the Backport kernel, I now have a new fastest machine in my cluster: (&lt;a href=&quot;https://futurama.fandom.com/wiki/Hubert_J._Farnsworth&quot;&gt;“farnsworth”&lt;/a&gt;).&lt;/p&gt;
</description>
        <pubDate>Fri, 06 May 2022 00:00:00 +0000</pubDate>
        <link>https://mattray.github.io/2022/05/06/preseed-installing-debian-on-a-headless-mac.html</link>
        <guid isPermaLink="true">https://mattray.github.io/2022/05/06/preseed-installing-debian-on-a-headless-mac.html</guid>
        
        
      </item>
    
      <item>
        <title>Using Thunderbolt Networking under Linux on a Macbook Air</title>
        <description>&lt;p&gt;&lt;a href=&quot;https://www.apple.com/au/shop/product/MD463ZM/A/thunderbolt-to-gigabit-ethernet-adapter&quot;&gt;&lt;img src=&quot;/assets/thunderbolt.jpg&quot; alt=&quot;Apple Thunderbolt to Gigabit Ethernet Adapter&quot; width=&quot;85&quot; height=&quot;400&quot; align=&quot;right&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have several 2015 13” MacBook Airs in various states of disrepair that I run Debian on as part of my home testing cluster. Given they don’t have ethernet ports, I’ve usually used USB network adapters because they are generally well-supported. One of my machines however, has a broken USB interface and I was unable to use this. I’d put it on a shelf to use for parts, but I found an Apple Thunderbolt to Gigabit Ethernet Adapter and figured I’d give that a whirl. Not surprisingly, Linux worked pretty seamlessly on 7+ year old technology.&lt;/p&gt;

&lt;p&gt;After plugging it in, nothing happened. A bit of quick googling found that I needed the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;thunderbolt&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tg3&lt;/code&gt; kernel modules, so I added them with:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;modprobe tg3 thunderbolt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The device now showed up under &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dmesg&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lspci --nnk&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;0a:00.0 Ethernet controller [0200]: Broadcom Inc. and subsidiaries NetXtreme BCM57762 Gigabit Ethernet PCIe [14e4:1682]
	Subsystem: Apple Inc. Thunderbolt to Gigabit Ethernet Adapter [106b:00f6]
	Kernel driver in use: tg3
	Kernel modules: tg3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;But the network interface was not enabled according to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ip address&lt;/code&gt;. I added the following to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/network/interfaces&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# Thunderbolt
allow-hotplug ens9
iface ens9 inet dhcp
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;restarted my network and I was now connected via DHCP.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;2: ens9: &amp;lt;BROADCAST,MULTICAST,UP,LOWER_UP&amp;gt; mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 68:5b:35:9d:a5:25 brd ff:ff:ff:ff:ff:ff
    altname enp10s0
    inet 10.0.0.22/24 brd 10.0.0.255 scope global dynamic ens9
       valid_lft 84917sec preferred_lft 84917sec
    inet6 fe80::6a5b:35ff:fe9d:a525/64 scope link
       valid_lft forever preferred_lft forever
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It works after rebooting and I now have another machine for my cluster (&lt;a href=&quot;https://futurama.fandom.com/wiki/Yancy_Fry&quot;&gt;“yancy”&lt;/a&gt;).&lt;/p&gt;
</description>
        <pubDate>Fri, 11 Mar 2022 00:00:00 +0000</pubDate>
        <link>https://mattray.github.io/2022/03/11/thunderbolt_networking_on_mac_linux.html</link>
        <guid isPermaLink="true">https://mattray.github.io/2022/03/11/thunderbolt_networking_on_mac_linux.html</guid>
        
        
      </item>
    
      <item>
        <title>Enabling a USB Serial Console on Linux</title>
        <description>&lt;p&gt;&lt;a href=&quot;https://www.alibaba.com/product-detail/USB-to-USB-crossover-serial-adapter_60623058382.html&quot;&gt;&lt;img src=&quot;/assets/usb-crossover.jpg_300x300.jpg&quot; alt=&quot;USB Serial Crossover Cable&quot; width=&quot;300&quot; height=&quot;300&quot; align=&quot;right&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Serial consoles have been used to communicate with headless networking and datacenter gear for decades. It works without requiring a screen, keyboard or networking which makes it helpful for debugging embedded devices and clusters of broken laptops and headless Arm boxes (which is my home lab). Most devices stopped shipping with serial ports years ago and USB to RS-232 serial adapters became common, but I picked up a USB to USB crossover serial adapter eliminating the need for separate cables. I purchased mine from &lt;a href=&quot;https://www.alibaba.com/product-detail/USB-to-USB-crossover-serial-adapter_60623058382.html&quot;&gt;Alibaba.com&lt;/a&gt;, which was cheaper than the name-brand alternatives (about $25 with shipping to Australia).&lt;/p&gt;

&lt;h2 id=&quot;configuring-ttyusb0&quot;&gt;Configuring ttyUSB0&lt;/h2&gt;

&lt;p&gt;On Linux the serial console is usually available as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ttyS0&lt;/code&gt;, and if it’s enabled you can connect to it with tools like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;screen&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;minicom&lt;/code&gt;. Physical and virtual consoles are connected to serial ports and the terminal with the application &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getty&lt;/code&gt; (“get tty”), presenting the user with a login prompt. A USB serial console would be available as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ttyUSB0&lt;/code&gt;, so you need to connect the Linux service &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getty&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ttyUSB0&lt;/code&gt;. For most recent Linux versions, this is managed by &lt;a href=&quot;https://systemd.io/&quot;&gt;systemd&lt;/a&gt; so enabling and starting the service is as simple as:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;systemctl enable getty@ttyUSB0.service
systemctl start getty@ttyUSB0.service
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This creates a symlink from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/systemd/system/getty.target.wants/getty@ttyUSB0.service&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/lib/systemd/system/getty@.service&lt;/code&gt; and starts listening on the USB serial console. I ran this on Raspbian 10, Armbian 11, and Debian 11 x86 and Arm systems and it worked across the board. I added it to my &lt;a href=&quot;https://github.com/mattray/mattray-cookbook/blob/main/recipes/default.rb#L88&quot;&gt;Chef recipe&lt;/a&gt; to ensure it stayed enabled across my current and any future machines.&lt;/p&gt;

&lt;h2 id=&quot;accessing-the-usb-serial-console-with-coolterm&quot;&gt;Accessing the USB Serial Console with CoolTerm&lt;/h2&gt;

&lt;p&gt;I’m currently using macOS, so I initially tried out &lt;a href=&quot;https://www.decisivetactics.com/products/serial/&quot;&gt;Serial&lt;/a&gt; which was very impressive but seemed like overkill for my limited needs. Roger Meier’s &lt;a href=&quot;https://freeware.the-meiers.org/&quot;&gt;CoolTerm&lt;/a&gt; serial port terminal application was simple and worked like a charm.&lt;/p&gt;

&lt;p&gt;To connect with CoolTerm follow these steps:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Start the CoolTerm application&lt;/li&gt;
  &lt;li&gt;Connect the USB serial crossover cable. I’m using a USB-C to USB-A adapter with my M1 Macbook Air, it works just fine.&lt;/li&gt;
  &lt;li&gt;Go to &lt;strong&gt;Options&lt;/strong&gt; and select the &lt;strong&gt;Port&lt;/strong&gt; similar to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;usbserial-AU03XLD7&lt;/code&gt;. If it is not listed, unplug the USB cable, replug it and click &lt;strong&gt;Re-Scan Serial Ports&lt;/strong&gt; without the cable plugged into the remote machine yet.&lt;/li&gt;
  &lt;li&gt;The &lt;strong&gt;Baudrate&lt;/strong&gt; should probably be &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;9600&lt;/code&gt;, this appears to be the default.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Data Bits&lt;/strong&gt; should be &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;8&lt;/code&gt;, &lt;strong&gt;Parity&lt;/strong&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;None&lt;/code&gt; and &lt;strong&gt;Stop Bits&lt;/strong&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1&lt;/code&gt;, these are all defaults.&lt;/li&gt;
  &lt;li&gt;Under &lt;strong&gt;Terminal&lt;/strong&gt; you may want to set &lt;strong&gt;Filter ASCII Escape Sequences&lt;/strong&gt; if you use any special characters in your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PS1&lt;/code&gt; or see odd characters in your terminal.&lt;/li&gt;
  &lt;li&gt;I didn’t change any of the other defaults, it worked without having to mess with these.&lt;/li&gt;
  &lt;li&gt;Exit the &lt;strong&gt;Options&lt;/strong&gt; and select &lt;strong&gt;Connect&lt;/strong&gt;. At this point you should see a blank terminal and a timer with the number of bytes transmitted.&lt;/li&gt;
  &lt;li&gt;Plug the other end of the USB cable into your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ttyUSB0&lt;/code&gt; enabled device and a terminal should come right up. It works exactly like a virtual console or SSH session.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Unplugging it and plugging it into another machine behaves exactly like detaching a monitor. A USB console left open will stay open and switching to other machines will bring up their prompt accordingly. Have fun!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/coolterm.png&quot; alt=&quot;CoolTerm USB TTY Output&quot; width=&quot;812&quot; height=&quot;672&quot; align=&quot;center&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Sun, 27 Feb 2022 00:00:00 +0000</pubDate>
        <link>https://mattray.github.io/2022/02/27/enabling-usb-serial-console.html</link>
        <guid isPermaLink="true">https://mattray.github.io/2022/02/27/enabling-usb-serial-console.html</guid>
        
        
      </item>
    
      <item>
        <title>Installing Armbian 11 on a Pine64 ROCKPro64</title>
        <description>&lt;h2 id=&quot;getting-started&quot;&gt;Getting Started&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://pine64.com/product/rockpro64-4gb-single-board-computer/&quot;&gt;&lt;img src=&quot;/assets/ROCKPro64-SBC-3.jpg&quot; alt=&quot;Pine64 ROCKPro64&quot; width=&quot;300&quot; height=&quot;300&quot; align=&quot;right&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Pine64 ROCKPro64 is a fairly powerful 64-bit single board computer with a Rockchip RK3399 Hexa-Core (dual ARM Cortex A72 and quad ARM Cortex A53) processor and 4GB of RAM. I added it to my Arm devices homelab because it’s a more powerful CPU than the &lt;a href=&quot;https://core-electronics.com.au/raspberry-pi-4-model-b-2gb.html&quot;&gt;Raspberry Pi 4&lt;/a&gt; but still priced at only $80 USD. I run &lt;a href=&quot;https://www.armbian.com/rockpro64/&quot;&gt;Armbian&lt;/a&gt; on it because I had some trouble getting the &lt;a href=&quot;https://wiki.pine64.org/wiki/ROCKPro64_Software_Release#Debian&quot;&gt;official Debian 11&lt;/a&gt; working, but they’re really similar in the end.&lt;/p&gt;

&lt;h2 id=&quot;installing-the-base-image&quot;&gt;Installing the Base Image&lt;/h2&gt;

&lt;p&gt;I downloaded &lt;a href=&quot;https://www.armbian.com/rockpro64/&quot;&gt;Armbian’s ROCKPro64&lt;/a&gt; image and flashed it onto a 32 gig microSD card with &lt;a href=&quot;https://www.etcher.io/&quot;&gt;Balena Etcher for macOS&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With my microSD card ready I plugged in an HDMI cable to my monitor and a USB keyboard and booted into Armbian. From the console, I updated the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root&lt;/code&gt; password with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;passwd&lt;/code&gt;, created a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mattray&lt;/code&gt; user and set my timezone. I’m not using wifi with this box, so the network worked out of the box.&lt;/p&gt;

&lt;h2 id=&quot;managing-with-cinc&quot;&gt;Managing with Cinc&lt;/h2&gt;

&lt;p&gt;I installed the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aarch64&lt;/code&gt; build , which is a supported platform from Cinc. I got the packages from http://downloads.cinc.sh/files/stable/cinc/17.9.52/debian/11/ and installed them&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;apt install ./cinc_17.9.52-1_arm64.deb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I bootstrapped the boxes with my a &lt;a href=&quot;https://github.com/mattray/mattray-cookbook&quot;&gt;home boxes cookbook&lt;/a&gt; and policyfile from my &lt;a href=&quot;https://github.com/mattray/home-repo/&quot;&gt;home-repo&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;knife bootstrap mom -N mom --policy-group home --policy-name base
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This standardizes the machine with the same packages, users, and other settings. I tagged the machine with&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;knife tag create mom cluster
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To ensure that it picked up the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cluster&lt;/code&gt; recipe which ensures all the members of the Kubernetes cluster have the right &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/hosts&lt;/code&gt; entries and keep updated with the same version of Cinc.&lt;/p&gt;

&lt;h2 id=&quot;post-install&quot;&gt;Post Install&lt;/h2&gt;

&lt;p&gt;The ROCKPro64 is typically the &lt;a href=&quot;https://k3s.io&quot;&gt;K3s Server node&lt;/a&gt; when I’ve been testing out Kubernetes deployments. It’s the fastest of my Arm machines and just as easy to manage as any of the Raspberry Pi devices.&lt;/p&gt;
</description>
        <pubDate>Sun, 09 Jan 2022 00:00:00 +0000</pubDate>
        <link>https://mattray.github.io/2022/01/09/installing-armbian-11-on-a-rock64pro.html</link>
        <guid isPermaLink="true">https://mattray.github.io/2022/01/09/installing-armbian-11-on-a-rock64pro.html</guid>
        
        
      </item>
    
      <item>
        <title>Installing Debian 11 on a Raspberry Pi Zero/3/4</title>
        <description>&lt;h2 id=&quot;getting-started&quot;&gt;Getting Started&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://shop.pimoroni.com/products/raspberry-pi-zero-w&quot;&gt;&lt;img src=&quot;/assets/Pibow_Zero_ver_1.3_1_of_3_1024x1024.JPG&quot; alt=&quot;Raspberry Pi Zero W&quot; width=&quot;235&quot; height=&quot;235&quot; align=&quot;right&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In my home lab I have a several &lt;a href=&quot;https://core-electronics.com.au/raspberry-pi-4-model-b-2gb.html&quot;&gt;Raspberry Pi 4&lt;/a&gt;, &lt;a href=&quot;https://core-electronics.com.au/raspberry-pi-3-model-b-plus.html&quot;&gt;Raspberry Pi 3 B+&lt;/a&gt;, and &lt;a href=&quot;https://shop.pimoroni.com/products/raspberry-pi-zero-w&quot;&gt;Raspberry Pi Zero W&lt;/a&gt; devices. I primarily ran &lt;a href=&quot;https://www.raspberrypi.org/software/operating-systems/&quot;&gt;Rasberry Pi OS Lite&lt;/a&gt;, but with the release of Debian 11 there are &lt;a href=&quot;https://raspi.debian.net&quot;&gt;official Raspberry Pi images&lt;/a&gt; available with for a minimal installation. Setting up and configuring these is pretty straightforward, but I thought I’d add my notes for easier reference. The instructions are fairly similar for each, so I’m going to focus on the Raspberry Pi 4.&lt;/p&gt;

&lt;h2 id=&quot;installing-the-base-image&quot;&gt;Installing the Base Image&lt;/h2&gt;

&lt;p&gt;I started with the &lt;a href=&quot;https://raspi.debian.net/tested-images/&quot;&gt;Tested Images&lt;/a&gt; and downloaded the proper xz-compressed image for each machine type.&lt;/p&gt;

&lt;p&gt;I flashed the image onto a 32 gig microSD card with &lt;a href=&quot;https://www.etcher.io/&quot;&gt;Balena Etcher for OSX&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With my microSD card ready I plugged in my micro-HDMI adapter and HDMI cable and a USB keyboard and booted into Debian.&lt;/p&gt;

&lt;h2 id=&quot;configuring-debian&quot;&gt;Configuring Debian&lt;/h2&gt;

&lt;p&gt;There are no non-root users, so you login as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root&lt;/code&gt; with no password, which you’ll want to immediately change with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;passwd&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So I could work on the machine from my laptop, I enabled remote root SSH access (disable this later).&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;echo &quot;PermitRootLogin yes&quot; &amp;gt;&amp;gt; /etc/ssh/sshd_config
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To set the hostname I ran:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hostnamectl set-hostname larry.bottlebru.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The images come with wireless support, so it was simply a matter of adding the following to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/network/interfaces.d/wlan0&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;allow-hotplug wlan0
iface wlan0 inet dhcp
    wpa-ssid MYNETWORK
    wpa-psk MYPASSWORD
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Unlike with Raspberry Pi OS, the images don’t come with swap enabled, so no need to disable it. The partitions are also resized automatically, so there are no manual steps related to that either.&lt;/p&gt;

&lt;p&gt;A quick reboot and I was able to SSH in as root remotely and administer the machine remotely.&lt;/p&gt;

&lt;h3 id=&quot;managing-with-cinc&quot;&gt;Managing with Cinc&lt;/h3&gt;

&lt;p&gt;The Raspberry Pi 3 &amp;amp; 4 are running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aarch64&lt;/code&gt;, which is a supported platform from Cinc. I got the packages from http://downloads.cinc.sh/files/stable/cinc/17.4.38/debian/10/ and installed them&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;apt install ./cinc-17.4.48-rpi-armv6l_armel.deb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I bootstrapped the boxes with my a &lt;a href=&quot;https://github.com/mattray/mattray-cookbook&quot;&gt;home boxes cookbook&lt;/a&gt; and policyfile from my &lt;a href=&quot;https://github.com/mattray/home-repo/&quot;&gt;home-repo&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;knife bootstrap larry -N larry --policy-group home --policy-name base
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now it was ready to use.&lt;/p&gt;

&lt;p&gt;The Raspberry Pi Zero identified as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;armel&lt;/code&gt; instead of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;armhf&lt;/code&gt; that was used for the &lt;a href=&quot;/arm/&quot;&gt;Raspberry Pi OS builds&lt;/a&gt; I’d built previously, so I had to do a fresh build for the machines. Because I still have Raspberry Pi OS 10 applications running, I haven’t upgraded these nodes yet.&lt;/p&gt;
</description>
        <pubDate>Mon, 30 Aug 2021 00:00:00 +0000</pubDate>
        <link>https://mattray.github.io/2021/08/30/installing-debian-11-0-on-a-raspberry-pi.html</link>
        <guid isPermaLink="true">https://mattray.github.io/2021/08/30/installing-debian-11-0-on-a-raspberry-pi.html</guid>
        
        
      </item>
    
      <item>
        <title>Switching To Zsh</title>
        <description>&lt;h1 id=&quot;switching-to-zsh-updated-for-emacs-m-x-shell&quot;&gt;Switching to zsh (updated for Emacs M-x shell)&lt;/h1&gt;

&lt;p&gt;I may be late to the party, but I’ve finally switched from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bash&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zsh&lt;/code&gt;. It wasn’t due to any failings of bash, it’s because I’ve been using it inside of &lt;a href=&quot;/2019/11/03/emacsconf&quot;&gt;Emacs M-x shell&lt;/a&gt; and never felt the need the fancy features of &lt;a href=&quot;https://ohmyz.sh/&quot;&gt;Oh My Zsh&lt;/a&gt; or any of the other new and improved shells. The &lt;a href=&quot;https://starship.rs/&quot;&gt;Starship&lt;/a&gt; shell prompt is a vast improvement on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PS1&lt;/code&gt; settings and scripts available in bash as well. What prompted the change was macOS and Arch Linux both defaulting to it on installation.&lt;/p&gt;

&lt;h2 id=&quot;making-the-switch&quot;&gt;Making the Switch&lt;/h2&gt;

&lt;p&gt;There were a pair of useful articles I read beforehand:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Switching to ZSH](http://zpalexander.com/switching-to-zsh/)
[Moving to zsh](https://scriptingosx.com/2019/06/moving-to-zsh/)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After reading through those, I figured I’d just make the switch and suffer the fallout.&lt;/p&gt;

&lt;h2 id=&quot;zshenv&quot;&gt;.zshenv&lt;/h2&gt;

&lt;p&gt;The &lt;a href=&quot;https://github.com/mattray/home-directory/blob/main/.zshenv&quot;&gt;.zshenv&lt;/a&gt; file is used for setting user’s environment variables. I didn’t really have too many to set, but it is convenient to keep them in 1 place.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;HISTSIZE=200000

GOPATH=$HOME/go
PATH=$PATH:$HOME/bin:$GOPATH/bin

EDITOR=emacsclient
GIT_EDITOR=$EDITOR
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HISTSIZE&lt;/code&gt; is used for maintaining the maximum size of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.zsh_history&lt;/code&gt; file. The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$PATH&lt;/code&gt; settings are adding my home and local Go &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bin&lt;/code&gt; directories. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EDITOR&lt;/code&gt; is set for anything that needs to access my preferred editor of Emacs and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GIT_EDITOR&lt;/code&gt; is specific to Git.&lt;/p&gt;

&lt;h2 id=&quot;zshrc&quot;&gt;.zshrc&lt;/h2&gt;

&lt;p&gt;The &lt;a href=&quot;https://github.com/mattray/home-directory/blob/main/.zshrc&quot;&gt;.zshrc&lt;/a&gt; is used for setting user’s interactive shell configuration and executing commands, and is read when starting an interactive shell. The advice was to forgo using an additional &lt;strong&gt;.zsh_profile&lt;/strong&gt; and just use a &lt;strong&gt;.zshrc&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;There are several &lt;strong&gt;setopt&lt;/strong&gt; commands for setting &lt;strong&gt;.zsh_history&lt;/strong&gt; settings (documented in the file) and the various aliases I prefer. The block&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# emacs M-x shell&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;dumb&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$TERM&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]]&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then
  &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;l&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;cat&apos;&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;less&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;cat&apos;&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;cat&apos;&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;more&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;cat&apos;&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PAGER&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat
  export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;TERM&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;xterm-256color
&lt;span class=&quot;k&quot;&gt;else
  &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;l&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;less&apos;&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;more&apos;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;explicitly sets behavior so &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;M-x shell&lt;/code&gt; and iTerm behaved as expected. The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GIT_EDITOR&lt;/code&gt; was not picked up when commiting files from the CLI within &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;M-x shell&lt;/code&gt;, so I had to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;export GIT_EDITOR=$EDITOR&lt;/code&gt; to get the desired behavior of not opening another Emacs window when commiting. The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;export TERM=xterm-256color&lt;/code&gt; is to get around &lt;a href=&quot;https://github.com/starship/starship/issues/1588&quot;&gt;this Starship bug&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;My &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PS1&lt;/code&gt; is managed by my &lt;a href=&quot;https://github.com/mattray/home-directory/blob/main/.config/starship.toml&quot;&gt;Starship config file&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;emacs&quot;&gt;Emacs&lt;/h2&gt;

&lt;p&gt;To ensure that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;M-x shell&lt;/code&gt; used zsh instead of bash I set the custom variables&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &apos;(explicit-shell-file-name &quot;/bin/zsh&quot;)
 &apos;(explicit-zsh-args &apos;(&quot;--interactive&quot; &quot;--login&quot;))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;and to off echoed commands from zsh added&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &apos;(comint-process-echoes 0)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;to my &lt;a href=&quot;https://github.com/mattray/home-directory/blob/main/.emacs.d/init.el&quot;&gt;.emacs.d/init.el&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I did not use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AUTO_CD&lt;/code&gt; settings because Emacs tended to lose track of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CWD&lt;/code&gt; and I don’t care enough to figure out how to use &lt;a href=&quot;https://www.emacswiki.org/emacs/ShellDirtrackByPrompt&quot;&gt;Dirtrack&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I added the following to my &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.zshrc&lt;/code&gt; to &lt;a href=&quot;https://www.emacswiki.org/emacs/TrampMode#h5o-9&quot;&gt;prevent Tramp from hanging&lt;/a&gt; on remote ssh zsh connections.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[[ $TERM == &quot;dumb&quot; ]] &amp;amp;&amp;amp; unsetopt zle &amp;amp;&amp;amp; PS1=&apos;$ &apos;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Wed, 26 May 2021 00:00:00 +0000</pubDate>
        <link>https://mattray.github.io/2021/05/26/switching-to-zsh.html</link>
        <guid isPermaLink="true">https://mattray.github.io/2021/05/26/switching-to-zsh.html</guid>
        
        
      </item>
    
      <item>
        <title>Building An External Monitor From An Ipad</title>
        <description>&lt;h1 id=&quot;building-an-external-97-monitor-from-an-ipad&quot;&gt;Building an External 9.7” Monitor from an iPad&lt;/h1&gt;

&lt;p&gt;I’ve always had a soft spot for &lt;a href=&quot;/2020/06/15/upgrading-macbook-pro-ssds-updated&quot;&gt;repurposing old hardware&lt;/a&gt; so when I stumbled across the video &lt;a href=&quot;https://www.youtube.com/watch?v=CfirQC99xPc&quot;&gt;Build a DIY screen out of recycled parts for cheap&lt;/a&gt; I knew I had to see what I could build. Sure there is lots of software for the iPad that will allow you to use it as an external monitor, but mine was an original 2010 iPad model that could no longer connect to the Apple store to install new packages.&lt;/p&gt;

&lt;h2 id=&quot;lenovo-thinkpad-yoga-12&quot;&gt;Lenovo Thinkpad Yoga 12&lt;/h2&gt;

&lt;p&gt;After watching the &lt;a href=&quot;https://www.youtube.com/watch?v=CfirQC99xPc&quot;&gt;linked video&lt;/a&gt; I originally disassembled a broken &lt;a href=&quot;https://www.insidemylaptop.com/lenovo-thinkpad-yoga-12-disassembly/&quot;&gt;Lenovo ThinkPad Yoga 12&lt;/a&gt; and scavenged the reusable parts out of it: Samsung SSD, Intel AC 7265 wireless card, the USB camera, and the screen. The Samsung SSD went into my kids’ gaming machine as an extra 192GB drive. The Intel wireless card could be used in my AMD workstation, I just haven’t hooked it up because I already have an ethernet connection. I found the model of the Lenovo screen from the &lt;a href=&quot;https://download.lenovo.com/pccbbs/mobiles_pdf/yoga_12_hmm_en_sp40a27258.pdf&quot;&gt;Hardware Maintenance Manual&lt;/a&gt; and ordered the proper &lt;a href=&quot;https://www.aliexpress.com/item/4001364202221.html?spm=a2g0s.9042311.0.0.28774c4dH1GIM9&quot;&gt;HDMI LCD controller board&lt;/a&gt; for $13.50 USD with shipping from AliExpress. It showed up, I plugged it in, and it worked at 1920x1080 resolution! Unfortunately I broke the screen trying to remove it from the laptop lid, so I had to start over.&lt;/p&gt;

&lt;h2 id=&quot;2010-ipad&quot;&gt;2010 iPad&lt;/h2&gt;

&lt;p&gt;After nearly succeeding with my first attempt at building an external monitor, I knew I wanted to try again. My other “broken” laptops are still in use as Linux servers, but I had an original iPad that I had barely used since it stopped receiving iOS updates several years ago. I followed &lt;a href=&quot;https://www.ifixit.com/Guide/iPad+Wi-Fi+Display+Frame+Replacement/2209&quot;&gt;iFixit’s iPad Wi-Fi Display Frame Replacement&lt;/a&gt; to disassemble it, but stopped short of removing it from the glass front (lesson learned). I then went back to AliExpress and found what looked like the right model &lt;a href=&quot;https://www.aliexpress.com/item/1005001719139974.html?spm=a2g0s.9042311.0.0.28774c4dH1GIM9&quot;&gt;HDMI VGA LCD controller&lt;/a&gt; for about $19 with shipping.&lt;/p&gt;

&lt;p&gt;A few weeks later it finally showed up and didn’t work. Did I have a bad unit, had I broken my iPad screen, or had I done something wrong?&lt;/p&gt;

&lt;h2 id=&quot;try-try-again&quot;&gt;Try, Try Again&lt;/h2&gt;

&lt;p&gt;Undeterred, I decided to try AliExpress again. You’d think with a name like &lt;a href=&quot;https://www.aliexpress.com/store/910350379?spm=a2g0s.9042311.0.0.28774c4dH1GIM9&quot;&gt;Yqwsyxl LCD parts Store&lt;/a&gt; you’d get quality, but I decided since I was already down $19 I’d go with &lt;a href=&quot;https://www.aliexpress.com/store/5793675?spm=a2g0s.9042311.0.0.28774c4dH1GIM9&quot;&gt;CZHAO Accessories Store&lt;/a&gt; and pay the $21 premium (with international shipping). AliExpress prices and shipping times seem to vary wildly in response to US, Australian, and Chinese currency fluctuations and this took nearly 6 weeks to show up.&lt;/p&gt;

&lt;h2 id=&quot;success&quot;&gt;Success!&lt;/h2&gt;

&lt;p&gt;Once it finally arrived, I &lt;a href=&quot;/assets/lcd-back.JPG&quot;&gt;connected the HDMI LCD controller&lt;/a&gt; to the display. I connected an HDMI cable, a 12v power adapter and turned it on. It powered up, the OSD display came on and reported “Looking for Source”. I plugged it into my laptop and it appeared as a 1024x768 VGA monitor. &lt;a href=&quot;/assets/first-boot.JPG&quot;&gt;&lt;img src=&quot;/assets/first-boot.JPG&quot; alt=&quot;monitors&quot; width=&quot;365&quot; height=&quot;282&quot; align=&quot;right&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;usage&quot;&gt;Usage&lt;/h2&gt;

&lt;p&gt;Once I had it working, I ordered a &lt;a href=&quot;https://amzn.to/3rdcO7t&quot;&gt;gooseneck tablet stand&lt;/a&gt; and set it up next to my main 32” monitor, above my laptop. I was using it primarily for terminals, my calendar, or Slack but my son convinced me “you have too many monitors and I only have my laptop”, so now he uses it for Discord. For about $35, you should be able to convert an old laptop or tablet to a working external monitor with a stand.
&lt;a href=&quot;/assets/monitors.JPG&quot;&gt;&lt;img src=&quot;/assets/monitors.JPG&quot; alt=&quot;monitors&quot; width=&quot;438&quot; height=&quot;294&quot; align=&quot;center&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Tue, 02 Mar 2021 00:00:00 +0000</pubDate>
        <link>https://mattray.github.io/2021/03/02/building-an-external-monitor-from-an-ipad.html</link>
        <guid isPermaLink="true">https://mattray.github.io/2021/03/02/building-an-external-monitor-from-an-ipad.html</guid>
        
        
      </item>
    
      <item>
        <title>Chef Infra and Cinc Client Linux Builds for 32-bit ARM EL Platforms</title>
        <description>&lt;p&gt;&lt;a href=&quot;https://github.com/chef/chef&quot;&gt;&lt;img src=&quot;/assets/chef-logo.png&quot; alt=&quot;Chef&quot; width=&quot;100&quot; height=&quot;100&quot; align=&quot;left&quot; /&gt;&lt;/a&gt;
&lt;a href=&quot;https://gitlab.com/cinc-project/client&quot;&gt;&lt;img src=&quot;/assets/cinc-logo.png&quot; alt=&quot;Cinc&quot; width=&quot;100&quot; height=&quot;100&quot; align=&quot;right&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://grahamweldon.com/&quot;&gt;Graham Weldon&lt;/a&gt; has taken the &lt;a href=&quot;/arm/&quot;&gt;existing instructions&lt;/a&gt; and created new &lt;strong&gt;armel&lt;/strong&gt; builds for running on &lt;a href=&quot;https://www.edge-core.com/productsInfo.php?cls=1&amp;amp;cls2=9&amp;amp;cls3=46&amp;amp;id=21&quot;&gt;switches&lt;/a&gt; and other similar hardware. The build scripts do not require additional patches, but Graham has &lt;a href=&quot;https://grahamweldon.com/post/2021/01/building-chef-infra-on-cumulus-linux-armel/&quot;&gt;documented how to create the builds&lt;/a&gt;. He has graciously allowed me to host his builds, so I’ll be including them on the &lt;a href=&quot;/arm/&quot;&gt;32-bit Arm Chef Infra and Cinc Client Builds for Linux page&lt;/a&gt; going forward.&lt;/p&gt;
</description>
        <pubDate>Tue, 09 Feb 2021 00:00:00 +0000</pubDate>
        <link>https://mattray.github.io/2021/02/09/chef-cinc-on-armel.html</link>
        <guid isPermaLink="true">https://mattray.github.io/2021/02/09/chef-cinc-on-armel.html</guid>
        
        
      </item>
    
      <item>
        <title>Chef Infra and Cinc Client Linux Builds for 32-bit ARM</title>
        <description>&lt;p&gt;&lt;a href=&quot;https://github.com/chef/chef&quot;&gt;&lt;img src=&quot;/assets/chef-logo.png&quot; alt=&quot;Chef&quot; width=&quot;100&quot; height=&quot;100&quot; align=&quot;left&quot; /&gt;&lt;/a&gt;
&lt;a href=&quot;https://gitlab.com/cinc-project/client&quot;&gt;&lt;img src=&quot;/assets/cinc-logo.png&quot; alt=&quot;Cinc&quot; width=&quot;100&quot; height=&quot;100&quot; align=&quot;right&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Rather than continue to add new blog posts for each and every Chef Infra and Cinc client build, I’ve added a new &lt;a href=&quot;/arm/&quot;&gt;32-bit Arm Chef Infra and Cinc Client Builds for Linux&lt;/a&gt; page. I’ll continue publish builds and publicizing them, but only updating the landing page.&lt;/p&gt;
</description>
        <pubDate>Mon, 29 Jun 2020 00:00:00 +0000</pubDate>
        <link>https://mattray.github.io/2020/06/29/chef-cinc-on-arm.html</link>
        <guid isPermaLink="true">https://mattray.github.io/2020/06/29/chef-cinc-on-arm.html</guid>
        
        
      </item>
    
      <item>
        <title>Uploading Data Bags to Chef Infra Server with knife, knife raw, and curl</title>
        <description>&lt;p&gt;&lt;a href=&quot;https://github.com/chef/chef&quot;&gt;&lt;img src=&quot;/assets/chef-logo.png&quot; alt=&quot;Chef&quot; width=&quot;100&quot; height=&quot;100&quot; align=&quot;right&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;https://docs.chef.io/api_chef_server/&quot;&gt;Chef Infra Server API&lt;/a&gt; is fairly well-documented and includes many examples. &lt;a href=&quot;https://docs.chef.io/data_bags/&quot;&gt;Data bags&lt;/a&gt; are a way to store JSON on the Chef Infra Server. The customer I’m working with needed an example of uploading data bags via the API because they wanted to upload JSON into them without using the CLI &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;knife&lt;/code&gt; tool from ServiceNow. While there are supported &lt;a href=&quot;https://github.com/chef/chef-api&quot;&gt;Ruby&lt;/a&gt; and &lt;a href=&quot;https://github.com/chef/go-chef&quot;&gt;Go&lt;/a&gt; Chef Server APIs available, they wanted a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl&lt;/code&gt; example. This post covers locking down a set of credential and progressing from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;knife&lt;/code&gt; CLI to using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl&lt;/code&gt;.&lt;/p&gt;

&lt;h1 id=&quot;limited-privilege-client-preparation&quot;&gt;Limited Privilege Client Preparation&lt;/h1&gt;

&lt;p&gt;In order to interact with the API, we will need a client key with permissions limited to working with data bags. These commands must be run on the Chef Server. First, we’ll create the organization for testing:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;chef-server-ctl org-create test1 &apos;Test Organization 1&apos; -f test1-validator.pem
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Because I’m using a self-signed certificate and not every &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;knife&lt;/code&gt; subcommand takes &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--node-ssl-verify-mode&lt;/code&gt;, I have this additional &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;no_ssl.rb&lt;/code&gt; configuration file. You may not need this step if you have a proper certificate.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssl_verify_mode :verify_none
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;create-the-data-bag-manager-client&quot;&gt;Create the data bag manager client&lt;/h2&gt;

&lt;p&gt;Next we need to create a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dbm&lt;/code&gt; data bag manager client that manage data bags.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;knife client create dbm -f dbm.pem -k /etc/opscode/pivotal.pem -u pivotal -s &quot;https://localhost/organizations/test1&quot; -c no_ssl.rb --disable-editing
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;grant-data-bag-permissions&quot;&gt;Grant data bag permissions&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;knife acl add client dbm containers data create,read,update,delete -k /etc/opscode/pivotal.pem -u pivotal -s &quot;https://localhost/organizations/test1&quot; -c no_ssl.rb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We’re now done with this organization on the Chef Infra Server. Copy the the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dbm.pem&lt;/code&gt; off the Chef Infra Server to the destination.&lt;/p&gt;

&lt;h2 id=&quot;reusing-the-dbm-client-across-multiple-organizations&quot;&gt;Reusing the dbm client across multiple organizations&lt;/h2&gt;

&lt;p&gt;Having a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dbm&lt;/code&gt; client for managing data bags within a particular organization is useful, but if you had a large number of organizations you’d probably prefer to reuse that client across them. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;knife client create&lt;/code&gt; will allow you to provide your own public key, so the following can be used to create the public key from the generated private key, then reuse it for additional organizations (in our case &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test2&lt;/code&gt;).&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;chef-server-ctl list-client-keys test1 dbm -v | tail -10 &amp;gt; dbm.pub
knife client create dbm --public-key dbm.pub -k /etc/opscode/pivotal.pem -u pivotal -s &quot;https://localhost/organizations/test2&quot; -c no_ssl.rb --disable-editing
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;From here out, the rest of the commands with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dbm&lt;/code&gt; client would be the same, replacing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test1&lt;/code&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test2&lt;/code&gt; or similar for your other organizations.&lt;/p&gt;

&lt;h1 id=&quot;using-knife&quot;&gt;Using knife&lt;/h1&gt;

&lt;p&gt;If we have access to a CLI, the easiest way to manage data bags would be to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;knife data bag&lt;/code&gt;. We could create the data bag &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;srs&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;knife data bag create srs -k dbm.pem -u dbm -s &quot;https://ndnd/organizations/test1&quot; -c no_ssl.rb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Upload an item (defined in a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data_bags/srs/h.json&lt;/code&gt;) file.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ cat data_bags/srs/h.json
{
    &quot;id&quot;: &quot;hyperchicken&quot;,
    &quot;payload&quot;: {
        &quot;one&quot;: &quot;1&quot;
    }
}
$ knife data bag from file srs h.json -k dbm.pem -u dbm -s &quot;https://ndnd/organizations/test1&quot; -c no_ssl.rb
Updated data_bag_item[srs::hyperchicken]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can also list, show and delete the items.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ knife data bag list -k dbm.pem -u dbm -s &quot;https://ndnd/organizations/test1&quot; -c no_ssl.rb
srs
$ knife data bag show srs hyperchicken -k dbm.pem -u dbm -s &quot;https://ndnd/organizations/test1&quot; -c no_ssl.rb
id:      hyperchicken
payload:
  one:   1
$ knife data bag delete srs -k dbm.pem -u dbm -s &quot;https://ndnd/organizations/test1&quot; -c no_ssl.rb -y
Deleted data_bag[srs]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;knife-raw&quot;&gt;knife raw&lt;/h1&gt;

&lt;p&gt;The &lt;a href=&quot;https://docs.chef.io/workstation/knife_raw/&quot;&gt;knife raw&lt;/a&gt; command allows us to pass straight JSON to API endpoints with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;knife&lt;/code&gt; CLI handling authentication. Here are examples of how to create the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;srs&lt;/code&gt; data bag&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ echo &apos;{ &quot;name&quot;:&quot;srs&quot; }&apos; &amp;gt; srs.json
$ knife raw -m POST /data -i srs.json -k dbm.pem -u dbm -s &quot;https://ndnd/organizations/test1&quot; -c no_ssl.rb
{
  &quot;uri&quot;: &quot;https://ndnd/organizations/test1/data/srs&quot;
}
$ knife raw -m GET /data -k dbm.pem -u dbm -s &quot;https://ndnd/organizations/test1&quot; -c no_ssl.rb
{
  &quot;srs&quot;: &quot;https://ndnd/organizations/test1/data/srs&quot;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Create and view the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hyperchicken&lt;/code&gt; item&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ knife raw -m POST /data/srs -i data_bags/srs/h.json -k dbm.pem -u dbm -s &quot;https://ndnd/organizations/test1&quot; -c no_ssl.rb
{
  &quot;id&quot;: &quot;hyperchicken&quot;,
  &quot;payload&quot;: {
    &quot;one&quot;: &quot;1&quot;
  },
  &quot;chef_type&quot;: &quot;data_bag_item&quot;,
  &quot;data_bag&quot;: &quot;srs&quot;
}
$ knife raw -m GET /data/srs/hyperchicken -k dbm.pem -u dbm -s &quot;https://ndnd/organizations/test1&quot; -c no_ssl.rb
{
  &quot;id&quot;: &quot;hyperchicken&quot;,
  &quot;payload&quot;: {
    &quot;one&quot;: &quot;1&quot;
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;and we can delete the data bag item and entire data bag&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ knife raw -m DELETE /data/srs/hyperchicken -k dbm.pem -u dbm -s &quot;https://ndnd/organizations/test1&quot; -c no_ssl.rb
{
  &quot;name&quot;: &quot;data_bag_item_srs_hyperchicken&quot;,
  &quot;json_class&quot;: &quot;Chef::DataBagItem&quot;,
  &quot;chef_type&quot;: &quot;data_bag_item&quot;,
  &quot;data_bag&quot;: &quot;srs&quot;,
  &quot;raw_data&quot;: {
    &quot;id&quot;: &quot;hyperchicken&quot;,
    &quot;payload&quot;: {
      &quot;one&quot;: &quot;1&quot;
    }
  }
}
$ knife raw -m GET /data/srs -k dbm.pem -u dbm -s &quot;https://ndnd/organizations/test1&quot; -c no_ssl.rb
{

}
$ knife raw -m DELETE /data/srs -k dbm.pem -u dbm -s &quot;https://ndnd/organizations/test1&quot; -c no_ssl.rb
{
  &quot;name&quot;: &quot;srs&quot;,
  &quot;json_class&quot;: &quot;Chef::DataBag&quot;,
  &quot;chef_type&quot;: &quot;data_bag&quot;
}
$ knife data bag list -k dbm.pem -u dbm -s &quot;https://ndnd/organizations/test1&quot; -c no_ssl.rb

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;curl&quot;&gt;curl&lt;/h1&gt;

&lt;p&gt;Interacting with the Chef Infra Server API requires authenticating with the client’s private key and encoding the messages via openssl. While &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;knife&lt;/code&gt; handles this under the covers, there is a detailed &lt;a href=&quot;https://docs.chef.io/auth/#other-options&quot;&gt;curl example&lt;/a&gt; in the documentation. I’ve pared it down a bit for brevity, this currently only handles GETs:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#!/usr/bin/env bash

_chomp () {
  # helper function to remove newlines
  awk &apos;{printf &quot;%s&quot;, $0}&apos;
}

chef_api_request() {
  # This is the meat-and-potatoes, or rice-and-vegetables, your preference really.

  local method path body timestamp chef_server_url client_name hashed_body hashed_path
  local canonical_request headers auth_headers

  chef_server_url=&quot;https://ndnd/organizations/test1&quot;
  if echo $chef_server_url | grep -q &quot;/organizations/&quot; ; then
    endpoint=/organizations/${chef_server_url#*/organizations/}${2%%\?*}
  else
    endpoint=${2%%\?*}
  fi
  path=${chef_server_url}$2
  client_name=&quot;dbm&quot;
  method=$1
  body=$3

  hashed_path=$(echo -n &quot;$endpoint&quot; | openssl dgst -sha1 -binary | openssl enc -base64)
  hashed_body=$(echo -n &quot;$body&quot; | openssl dgst -sha1 -binary | openssl enc -base64)
  timestamp=$(date -u &quot;+%Y-%m-%dT%H:%M:%SZ&quot;)

  canonical_request=&quot;Method:$method\nHashed Path:$hashed_path\nX-Ops-Content-Hash:$hashed_body\nX-Ops-Timestamp:$timestamp\nX-Ops-UserId:$client_name&quot;
  headers=&quot;-H X-Ops-Timestamp:$timestamp \
    -H X-Ops-Userid:$client_name \
    -H X-Chef-Version:0.10.4 \
    -H Accept:application/json \
    -H X-Ops-Content-Hash:$hashed_body \
    -H X-Ops-Sign:version=1.0&quot;

  auth_headers=$(printf &quot;$canonical_request&quot; | openssl rsautl -sign -inkey &quot;dbm.pem&quot; | openssl enc -base64 | _chomp |  awk &apos;{ll=int(length/60);i=0; \
    while (i&amp;lt;=ll) {printf &quot; -H X-Ops-Authorization-%s:%s&quot;, i+1, substr($0,i*60+1,60);i=i+1}}&apos;)

  case $method in
    GET)
      curl_command=&quot;curl -k $headers $auth_headers $path&quot;
      echo $curl_command
      $curl_command
      ;;
    *)
      echo &quot;Unknown Method. I only know: GET&quot; &amp;gt;&amp;amp;2
      return 1
      ;;
    esac
  }

 chef_api_request &quot;$@&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Note that the values of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chef_server_url&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dbm&lt;/code&gt; user and key are hard-coded rather than take them from a config file. Output will be similar to&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ bash chef_curl.sh GET /data/srs/hyperchicken
curl -k -H X-Ops-Timestamp:2020-06-26T06:20:34Z -H X-Ops-Userid:dbm -H X-Chef-Version:0.10.4 -H Accept:application/json -H X-Ops-Content-Hash:2jmj7l5rSw0yVb/vlWAYkK/YBwk= -H X-Ops-Sign:version=1.0 -H X-Ops-Authorization-1:gVUUo9JoIXdZhFxYLgsvEOwKsmMFJLC6M+bMFu1fX6PRVtfyTfgMx2UzBcd5 -H X-Ops-Authorization-2:K0wFnDO8+fIHjMTyu3nQf2LBVCTn/S4SjKMSTMxKF0uN9BW7DU1CBYUmuOXO -H X-Ops-Authorization-3:C3ADAvmvC5N7lIJnSSffrTojSBuhWUeD16wCBqHtfh/AC4WVzPhe5t+gPpoE -H X-Ops-Authorization-4:moYCh2dyx6dnZ+NsfvU9UsfmiJJdNST7ur5kHnCh3bBgARvch8oilzBLlnQk -H X-Ops-Authorization-5:w+a5rVk3NwIDG/WNH95cYNxMtLt+WLyJVIlbMLWXlf/iZylqkcdEbckGtJjJ -H X-Ops-Authorization-6:9GMEhijpP9I+skDAjvw3pLLAHIfXH5jZSAAawxSCdw== https://ndnd/organizations/test1/data/srs/hyperchicken
{&quot;id&quot;:&quot;hyperchicken&quot;,&quot;payload&quot;:{&quot;one&quot;:&quot;1&quot;}}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can download it directly &lt;a href=&quot;/assets/chef_curl.sh&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
</description>
        <pubDate>Fri, 26 Jun 2020 00:00:00 +0000</pubDate>
        <link>https://mattray.github.io/2020/06/26/chef-infra-server-curl.html</link>
        <guid isPermaLink="true">https://mattray.github.io/2020/06/26/chef-infra-server-curl.html</guid>
        
        
      </item>
    
  </channel>
</rss>
