#3 Re-create test secret

This commit is contained in:
Joey Hafner 2024-08-16 12:45:31 -07:00
parent 8c3f370086
commit 02972c0d6b
No known key found for this signature in database
7 changed files with 263 additions and 3 deletions

View File

@ -3,3 +3,4 @@
1. Install [sops](https://github.com/getsops/sops/releases).
2. Install [age](https://github.com/FiloSottile/age).
3. Run the [setup script](.age-setup.sh).

View File

@ -0,0 +1,9 @@
MYSECRET=ENC[AES256_GCM,data:VExl6Kt5ESLaitlsmDTJfQljSaAgPpFDCAiiuB0LccrzL0fL0KJG9QJVwvQFhFmp,iv:+eESJZtIB/QVzHR7TqdcEdUmrruGiaAGDbsYlWPhHbU=,tag:I4WbGR8JyvV4C23qdCM8FQ==,type:str]
sops_age__list_0__map_enc=-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBtOEhlSWlpZHZCNlJxMi9E\nSGIxeUFGR2R3Qm9IaTQ0SzB4cSszWmtkNGxzCkgzMUpnQ084RkowQU9MczNxRlpx\nMDFOcDVCRkFsWDlSWkd6bFlFQ09qencKLS0tIHFEemVNYlFzbzB2ZDNFWGpUMDY1\nY3RJTzB2YjNzSjFkTk00UmtnOW1lU1UKJWiYjkPCKddDWYiJ9/WzunhzlsFNvPu2\nZdFfireA2muLz0e3QvHUTJkOVm53d5g2e1nf4UOWmRfHmKo4TrYt6Q==\n-----END AGE ENCRYPTED FILE-----\n
sops_age__list_0__map_recipient=age1zswcq6t5wl8spr3g2wpxhxukjklngcav0vw8py0jnfkqd2jm2ypq53ga00
sops_age__list_1__map_enc=-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBqanZDS2plaUNkV2dWd09T\nTjZOSFBJZEkxcmI2Nk1zRUh4N0pDWCt1SEFrCkw1Vk1vL0VwY1FDSGlPZTdBZzdy\nUkl2Z0NpT1k1aHdoY1Q0WS9JTjNSencKLS0tIDhicVhYMnJRSUtQVTFmZXFtVUFh\neksxUi9LYy81YTZMempXTUJtRm9Gc3MKAPmYIA/SM+D2jf9YPfTUARxT9UGXXc1e\n20/21hT6Q61Oww5NLsXHUUOSFRmgsT4PuD3Ak//DroWLKdoxuW9F8Q==\n-----END AGE ENCRYPTED FILE-----\n
sops_age__list_1__map_recipient=age13prhyye2jy3ysa6ltnjgkrqtxrxgs0035d86jyn4ltgk3wxtqgrqgav855
sops_lastmodified=2024-08-16T19:45:31Z
sops_mac=ENC[AES256_GCM,data:7oR+d2k+NEJTtJcoVm7sEU4UN4AVTKq+7AikggtCXyFa+IaFR2tv74SJkrZQCAglmfgQ7hMQquSkHx8Vb1zbzTZV/ugYeDFwlSMlClVcLcvbCS+EwF6UF+d91YcpXeUspplqOT2bogt4x+6PUtHknI6QENlMZsjx2UXkiDm0X/g=,iv:z7tiqDHb0mwUnA8KlKnWJfrzeQvzy7w0hpcoSpo7UuU=,tag:Yd/xthPaMIQx4Rf6g2d4KA==,type:str]
sops_unencrypted_suffix=_unencrypted
sops_version=3.9.0

View File

@ -30,9 +30,6 @@ fi
# Move to the working directory for working with files.
cd /usr/local/apache2/htdocs
echo " === Checking directory permissions for /usr/local/apache2/htdocs"
ls -ld /usr/local/apache2/htdocs
DL_LINK=${DL_LINK:-https://github.com/5etools-mirror-2/5etools-mirror-2.github.io.git}
IMG_LINK=${IMG_LINK:-https://github.com/5etools-mirror-2/5etools-img}

View File

@ -0,0 +1,137 @@
#!/bin/bash
{
# Step 1. Check and print variable values:
echo " # Check and print variables:"
echo " # PUID:PGID: $PUID:$PGID"
echo " # OFFLINE_MODE: $OFFLINE_MODE"
echo " # GET_IMAGES: $GET_IMAGES"
echo " # HOMEBREW_URLS: $HOMEBREW_URLS"
# $HOMEBREW_PATH; host path containing homebrew json files to load
# $CONTENT_BLOCKLIST_FILE; file automatically imported to block content
}
{
# Step 2. Assert ownership of site files.
echo " # Setting ownership of site directory"
chown -R $PUID:$PGID /usr/local/apache2/htdocs
}
{
# Step 3. Check for offline mode.
# - If OFFLINE_MODE is set to TRUE, we check if the site files directory
# has a valid 5eTools version file.
# - If there is a valid version file, we start the server.
# - If there is no valid version, we exit with error.
# - Else we continue to step 4.
echo -n " # Checking OFFLINE_MODE: "
if [ "$OFFLINE_MODE" = "TRUE" ]; then
echo "enabled"
echo " # Will try to launch from local files."
echo -n " # Checking local version: "
if [ -f /usr/local/apache2/htdocs/package.json ]; then
VERSION=$(jq -r .version package.json) # Get version from package.json
echo "$VERSION"
echo " # Starting!"
httpd-foreground
else
echo "None found."
echo " # No local version detected. Exiting."
exit 1
fi
fi
}
{
# Step 4. Check for site update.
# - First we gather facts: local version, remote version, GET_IMAGES bool.
# - Check local and remote version tags of main site
cd /usr/local/apache2/htdocs
echo " # Checking version info"
echo -n " # Local version: "
if ! [[ -f package.json ]]; then
echo "None"
else
CURRENT_RELEASE_VERSION="v$(jq -r .version package.json)"
echo "$CURRENT_RELEASE_VERSION"
fi
echo -n " # Remote version: "
LATEST_RELEASE_VERSION=$(curl -s https://api.github.com/repos/5etools-mirror-2/5etools-mirror-2.github.io/releases/latest | grep tag_name | cut -d':' -f2 | tr -d \" | tr -d \,| head -n 1 | xargs)
echo "$LATEST_RELEASE_VERSION"
}
{
# Step 5. Handle image files.
# - Check if images are wanted, present:
# - Not wanted, not present: Skip.
# - Not wanted, present: Delete.
# - Wanted, not present: Get.
# - Wanted, present: Update.
echo " # Checking for image files"
if [[ "$GET_IMAGES" == "FALSE" ]]; then
if ! [[ -f /usr/local/apache2/htdocs/img/.version ]];
echo " # Image files not wanted, not present. Skipping."
else
echo " # Image files not wanted, but found locally. Deleting."
rm -rf /usr/local/apache2/htdocs/img
fi
else
if ! [[ -f /usr/local/apache2/htdocs/img/.version ]];
echo " # Image files wanted, not present. Downloading."
# TODO: Download image files. Create `.version` file for images.
IMG_LATEST_RELEASE_VERSION=$(curl -s https://api.github.com/repos/5etools-mirror-2/5etools-img/releases/latest | grep tag_name | cut -d':' -f2 | tr -d \" | tr -d \,| head -n 1 | xargs)
echo " # Getting list of img release files"
IMG_URLS=$(curl -s https://api.github.com/repos/5etools-mirror-2/5etools-img/releases/latest | grep browser_download_url | cut -d':' -f2,3 | tr -d \" | xargs)
echo " # Downloading img release files"
for file in $(echo $IMG_URLS); do echo "Downloading file: $file"; wget --directory-prefix=/tmp/ "$file"; done
echo " # Extracting img release archives"
unzip -d /usr/local/apache2/htdocs/img/ -n /tmp/img-*.zip
echo "$IMAGE_LATEST_RELEASE_VERSION" > /usr/local/apache2/htdocs/img/.version
echo " # Cleaning up archives"
rm /tmp/img-*
else
echo " # Image files wanted, and found locally. Checking for update."
# TODO: Diff local tag to remote latest. If different, download update.
# $1 = Repo path like 5etools-mirror-2/5etools-img
# $2 = Current tag like v1.209.0
# $3 = Compare tag like v1.209.3
# Returns bool; 1 if tags are identical
IMG_REPO=5etools-mirror-2/5etools-img
IMG_CURRENT_RELEASE_VERSION=$(cat /usr/local/apache2/htdocs/img/.version)
IMG_LATEST_RELEASE_VERSION=$(curl -s https://api.github.com/repos/5etools-mirror-2/5etools-img/releases/latest | grep tag_name | cut -d':' -f2 | tr -d \" | tr -d \,| head -n 1 | xargs)
TESTURL=${"https://github.com/$IMG_REPO/compare/$IMG_CURRENT_RELEASE_VERSION..$IMG_LATEST_RELEASE_VERSION"}
curl -s $TESTURL | grep "There isnt anything to compare"
DIFFERENT=$?
if [[ "$DIFFERENT" == "1" ]]; then
echo "new images, re-downloading image repo."
else
echo "no new images, skipping update."
fi
fi
fi
if [[ "$CURRENT_RELEASE_VERSION" == "$LATEST_RELEASE_VERSION" ]]; then
echo " # Downloading latest release"
fi
}
{
# Step 6. Update main site.
wget -O /tmp/5etools.zip $LATEST_RELEASE_URL
find /usr/local/apache2/htdocs/ -path ./homebrew -prune -o -type f -exec rm "{}" \;
unzip -d /usr/local/apache2/htdocs/ -n /tmp/5etools.zip
rm /tmp/5etools.zip
}
if [[ -f /usr/local/apache2/htdocs/img/.version ]]
# check for local image files in the img/ directory
# get image files
if [[ "$GET_IMAGES"=="TRUE" ]]; then
fi

View File

@ -0,0 +1,51 @@
+++
title = '5eTools Docker: Admin-friendly 5eTools Docker image'
description = " "
date = 2024-07-21T11:55:06-07:00
aliases = []
author = "Joey Hafner"
ogimage = '/img/Jafner.dev.logo.png'
slug = "5etools"
draft = true
+++
## The What and Why
I initially created `5etools-docker` when I wanted to host my own instance and there was no publicly-available Docker image available to facilitate that. That was back before there was a Git repo for it, so we had to check a site. For liability reasons, I couldn't build the image with the site files inside it, so instead I went with an installer/updater script approach.
The image and script were pretty much it. Just a little 3rd-party Dockerization of a site I wanted to self-host.
And then the Git repo was published and a two-line Dockerfile obsoleted my work. A perfect opportunity to look for ways to provide differentiating features: automatically import homebrew and blocklist files.
5eTools self-hosted instances offer the ability to customize your instance by automatically loading a list of homebrew content. For me, that means I can spin up an instance pre-loaded with my custom homebrew and my players can access that content seamlessly. And that same feature supports blocklists, so I can just disable all the content I don't own, or don't want my players to use. Cool stuff!
So how can we get a 5eTools instance that provides the features I want as a DM?
- Auto-updating from the upstream repository.
- Auto-loading my homebrew.
- Auto-loading my blocklist of content I don't own.
Let's dig into it.
## The How
I built this image in three parts, each working at a different in the deployment process:
- `Dockerfile`
- `docker-compose.yaml`
- `init.sh`
Our `Dockerfile` provides the core packages and utilities we need to run the web server and handle automatic updating. It's based on `httpd`, just like the upstream. But it also provides some features useful to admins integrating 5eTools into a bigger Docker environment: PUID and PGID settings with directory ownership assertion, the `curl`, `git`, and `jq` packages, and of course the `init.sh` script.
The `docker-compose.yaml` file is a declarative configuration version of a `docker run` command. In addition to the standard benefits of declarative configuration, we can also include some basic usage documentation inside the file for things like envrionment variables and volume mounts.
And finally, `init.sh` runs every time you launch the container. It handles any runtime logic and features we've implemented: offline mode, auto-updating, include or skip image files, and homebrew/blocklist patching.
### Dead Simple Dockerfile
The core of our image, it pulls the fewest possible packages necessary to run our script.
### Init Script
### Docker Compose
### Usage
## Closing Thoughts and Future Work

View File

@ -0,0 +1,20 @@
+++
title = 'K3s'
description = " "
date = 2024-08-06T13:08:14-07:00
aliases = []
author = "Joey Hafner"
ogimage = '/img/Jafner.dev.logo.png'
slug = "draft"
draft = true
+++
- Bard, Cleric, and Ranger are Dell Wyse 5070s onto which I installed Debian 12.
- They have the IPs `192.168.1.{31..33}`
- On the first one, I ran `curl -sfL https://get.k3s.io | K3S_TOKEN=<my-token> sh -s - server --cluster-init`, and then on each of the other two I ran `curl -sfL https://get.k3s.io | K3S_TOKEN=<my-token> sh -s - server --server https://192.168.1.31:6443`
1. `kubectl apply -f dashboard.deployment.yml`
2. `kubectl create -f dashboard.admin-user.yml -f dashboard.admin-user-role.yml`
3. `kubectl -n kubernetes-dashboard create token admin-user`
4. `kubectl proxy`

View File

@ -0,0 +1,45 @@
+++
title = 'Subaru Self Tuning - Stage Zero'
description = " "
date = 2024-07-22T14:08:33-07:00
aliases = []
author = "Joey Hafner"
ogimage = '/img/Jafner.dev.logo.png'
slug = "subi-stg0"
draft = true
+++
## Tools of the Trade
- Tactrix OpenPort 2.0
- RomRaider
- EcuFlash
### Install the j2534 Driver
We need our laptop to be able to talk to our Tactrix cable, so we need to install the `j2534` driver created by Dale Schultz.
https://github.com/dschultzca/j2534
- Install `make` `gcc` `git`
- `git clone https://github.com/dschultzca/j2534`
- `cd j2534/j2534 && make install`
- `echo SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTR{idProduct}=="cc4d", GROUP="dialout", MODE="0666" | sudo tee /etc/udev/rules.d/tactrix`
### Install RomRaider (Option 1: Traditional)
- `git clone https://github.com/RomRaider/RomRaider.git && cd RomRaider`
- `chmod +x run.sh jdk-11.0.14.1+1-jre/bin/java`
- `./run.sh`
### Install RomRaider (Option 2: Docker)
- `git clone https://github.com/RomRaider/RomRaider.git && cd RomRaider`
- `docker build -t RomRaider .`
### Get Definitions Files
- Download the latest ECU definitions zip from the first post in [this thread](https://www.romraider.com/forum/topic360.html).
- Download the latest logger definitions zip from the first post in [this thread](https://www.romraider.com/forum/viewtopic.php?t=1642&start=1)
- Download the latest dyno definitions from the first post in [this thread](https://www.romraider.com/forum/viewtopic.php?t=5792)
### Reading the ECU