Skip to content

Instantly share code, notes, and snippets.

@thejimnicholson
thejimnicholson / gist:8f4e57cd9948eaf98f972cc93a38de50
Created May 18, 2024 05:42
Get rid of all old docker container instances
for a in $(docker ps -a | tail +2 | cut -d' ' -f1); { docker rm $a; }
docker image prune -a
@thejimnicholson
thejimnicholson / helm2flux.md
Last active April 28, 2024 22:01
Create flux HelmRepository for each helm repo in local environment

helm2flux.sh

This script will convert all the helm repositories in your local helm environemnt into HelmRepository sources for fluxcd.

Dependencies:

from ansible.plugins.inventory import BaseInventoryPlugin
import yaml
class CustomInventoryPlugin(BaseInventoryPlugin):
NAME = 'custom_inventory'
def parse(self, inventory, loader, path, cache=True):
super(CustomInventoryPlugin, self).parse(inventory, loader, path)
import yaml
def process_yaml_file(input_file):
with open(input_file, 'r') as file:
data = yaml.safe_load(file)
group_entries = {}
for entry_name, entry_data in data.items():
hostgroups = entry_data.get('hostgroups', [])
@thejimnicholson
thejimnicholson / tabby-update.sh
Created December 30, 2022 23:13
bash script to pull the latest rpm for tabby
#!/usr/bin/env bash
PROJECT='eugeny/tabby'
API_LATEST=https://api.github.com/repos/$PROJECT/releases/latest
TARGET=$(curl -s $API_LATEST | jq ' .assets[].browser_download_url' | grep 'linux-x64.rpm' | tr -d '"')
PACKAGE=$(basename $TARGET)
echo $TARGET
echo $PACKAGE
curl -s -o $PACKAGE --max-redirs 5 -L $TARGET
@thejimnicholson
thejimnicholson / github-release-download.sh
Last active November 25, 2023 20:27
Download latest released .deb from github releases
#!/usr/bin/env bash
PROJECT='eugeny/tabby'
API_LATEST=https://api.github.com/repos/$PROJECT/releases/latest
TARGET=$(curl -s $API_LATEST | jq ' .assets[].browser_download_url' | grep \.linux-x64\.deb | tr -d '"')
PACKAGE=$(basename $TARGET)
curl -s -o $PACKAGE --max-redirs 5 -L $TARGET
@thejimnicholson
thejimnicholson / letsencrypt-dns.sh
Last active November 2, 2021 09:26
Use acme.sh with letsencrypt and AWS Route 53 on a Zentyal server
#!/bin/bash
#
# Run this on your Zentyal server from an ssh session as root.
#
# Inject your AWS credentials here
export AWS_ACCESS_KEY_ID=""
export AWS_SECRET_ACCESS_KEY=""
export HOST_FQDN="my.domain.com"
export ACCOUNT_EMAIL="your@email.co"
@thejimnicholson
thejimnicholson / jenkins.sh
Last active October 5, 2020 21:08
Start a docker container for jenkins
#!/usr/bin/env bash
docker volume create jenkins
docker run -d \
-v jenkins:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(which docker):$(which docker) \
-p 8080:8080 -p 50000:50000 \
--name jenkins \
--restart unless-stopped \
jenkins/jenkins:lts
@thejimnicholson
thejimnicholson / gist:cda0aeed57a761fea3b1ec933d2c9c42
Created May 22, 2020 07:50
Set up docker multiarch container for buildx
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx rm builder
docker buildx create --name builder --driver docker-container --use
docker buildx inspect --bootstrap
@thejimnicholson
thejimnicholson / json_example.sh
Created October 4, 2019 21:31
Create JSON in bash using heredocs
#!/usr/bin/env bash
var1='value of var1'
var2='value of var2'
read -r -d '' block <<-END
{
"var1": "${var1}",
"var2": "${var2}"