Skip to content

Instantly share code, notes, and snippets.


Troy Fontaine troyfontaine

View GitHub Profile
troyfontaine /
Created April 12, 2022 03:16
Rsync commands for TrueNAS

Rsync Commands for use with TrueNAS

Due to the way TrueNAS is built-duplicating files using Rsync requires some special flags to allow it to work

The below example command has been used and verified as working with TrueNAS Scale

rsync -avrh -A --no-perms <SOURCE> <DESTINATION>
troyfontaine /
Created April 3, 2022 05:06
Migrating Unifi Controller from Cloudkey Gen 1 to Docker Container

How to Migrate a Unifi Controller from Cloudkey Gen 1 to Docker Container

Background: In an effort to streamline my local network and reduce the number of dedicated devices, I began an effort to move off of my Unifi Cloudkey Gen 1 to a Docker Container. While the migration should be straight forward-it is definitely not!

Before we begin, ensure that your existing Cloudkey is still connected to the network and operational. This is crucial to migrate the existing settings and to leverage the Unifi migration tooling for a site to save on having to wipe your configuration and rebuild everything from scratch.

  1. Launch your container (it is up to you to follow the documentation for the specific maintainer's flavour to ensure you avoid data loss!) Once you can access the set up screen (on TCP:8443) for the containerized controller, you can proceed to Step 2
  2. On your existing controller, Navigate to Settings -> Backup and download a settings only backup. This is CRITICAL because trying to import
troyfontaine /
Last active March 24, 2022 13:59
Running Badblocks on External USB Drives attached to a TrueNAS Scale Machine

Badblocks on TrueNAS Scale

  1. Connect your USB drive to the machine
  2. Navigate to the TrueNAS Scale shell by opening the menu, going to System Settings and then clicking on Shell
  3. Locate the drive's device ID using the lsblk command
  4. Check the recommended block size using the command blockdev --getbsz /dev/<YOUR BLOCK DEVICE ID>
  5. Note the block size you got from the last command
  6. STOP! Have you ensured that the USB device does NOT have any important data on it? If it does, stop now, unplug it from the TrueNAS Scale machine and back it up elsewhere! Running the specific badblocks command we'll use will destroy data on the drive!
  7. Okay, you've confirmed there is no data on the drive you need? Good!
  8. Fire up a new tmux session tmux new -s badblocks_
troyfontaine /
Created March 19, 2022 14:45
Resize Ubuntu VM Disk on TrueNAS Scale

Resize an Ubuntu VM Disk on TrueNAS Scale

  1. Shutdown the target VM
  2. Locate the zvol where the storage is allocated in the Storage blade in the TrueNAS Scale Web UI
  3. Resize the zvol by editing it-this can ONLY be increased, not shrunk!
  4. Save your changes
  5. Start your target VM up again
  6. Log in to the VM
  7. Execute the growpart command, ie. sudo growpart /dev/vda 2
  8. Execute the resize2fs command, ie. sudo resize2fs /dev/vda2
troyfontaine /
Created February 10, 2022 03:59
Install Docker Compose V2 on 64-bit Raspberry Pi OS
#!/usr/bin/env bash
# Download the binary
sudo curl -SL \
-o /usr/local/lib/docker/cli-plugins/
# Set the binary to be executable
chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
troyfontaine /
Last active February 8, 2022 18:20
Install Hashicorp Vault on Raspberry Pi 4 with 64-bit Raspberry Pi OS
#!/usr/bin/env bash
# Install Dependencies
sudo apt-get update && sudo apt-get install software-properties-common wget -y
# Add the gpg key
wget -O- | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
# Add the repository and set where the key is to validate the packages
echo 'deb [arch=arm64 signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] $(lsb_release -cs) main' | sudo tee /etc/apt/sources.list.d/hashicorp.list
troyfontaine /
Last active December 21, 2022 11:24
Setting up Aliases for Python on Windows PowerShell

Getting Your Python (Development) On!

Python for Windows is really easy to install-but what if you had started in the world of MacOS/*nix OSes and miss that single command to call Python or Pip? What if you don't have access to modify your environment PATH?

Windows PowerShell has a feature called "Profiles" which allows you to configure your PowerShell in a similar fashion as you could with Bash, Zsh, etc.

Pretty cool huh?

Create a Profile

troyfontaine /
Created August 13, 2020 12:50
Fixed Close All RabbitMQ Connections

Fixed command to close connections to RabbitMQ

rabbitmqctl list_connections pid port state user vhost recv_cnt send_cnt send_pend name| grep -vP 'Listing|pid' | awk '{print "rabbitmqctl close_connection \"" $1 "\" \"manually closing idle connection\"" | "sh" }'
troyfontaine /
Last active May 11, 2020 17:22
Pipeline Script to install rbenv, rbenv gemset and ruby-build
# Bash script to check if rbenv is installed along with a few necessities and if they don't exist
# to install them
install_rbenv() {
echo "--- :construction: Installing Rbenv"
# Clone rbenv from Github
git clone "$HOME/.rbenv" > /dev/null 2>&1
troyfontaine / 1.
Last active November 29, 2022 05:49 — forked from igorkulman/CompareTools.plist
Visual Studio Code as a merge tool for Git Tower.
View 1.

Enable Visual Studio Code for Merge/Diff on Windows

From PowerShell or CMD:

cd C:\Program Files (x86)\fournova\Tower\CompareTools
code .

Edit VisualStudioCode.json and replace line 10 which is: