Add bin/devhamctl
Add bin/docker-traverse.sh Add bin/exec-sanity.sh Add bin/lunardev.sh Add bin/record.sh Add bin/restart-builds-drone.sh Add bin/run-dosier.sh Add bin/sanity.sh Add bin/scan-for-bad-indexes.sh Add bin/ssh-agent.sh Add bin/terraform.sh Add bin/tmux.sh Add bin/update-vault.sh Add bin/zimfwupdate.sh
This commit is contained in:
parent
ef2da35882
commit
31d7ef27a8
24
bin/executable_devhamctl
Normal file
24
bin/executable_devhamctl
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
function cleanupTempDir() {
|
||||||
|
temp=$1
|
||||||
|
echo "cleaning up $temp"
|
||||||
|
|
||||||
|
rm -r $temp
|
||||||
|
|
||||||
|
echo "cleaned up tempdir"
|
||||||
|
}
|
||||||
|
|
||||||
|
tempdir=$(mktemp -d -t "devhamctl")
|
||||||
|
trap "cleanupTempDir $tempdir" EXIT
|
||||||
|
|
||||||
|
pushd $tempdir
|
||||||
|
echo "fetching release manager [hamctl]"
|
||||||
|
wget -q https://github.com/lunarway/release-manager/releases/download/$1/hamctl-darwin-amd64 -O binhamctl
|
||||||
|
shift
|
||||||
|
echo "calling release manager [hamctl] with args [$@]"
|
||||||
|
chmod +x binhamctl
|
||||||
|
HAMCTL_URL="http://some-url" ./binhamctl "$@"
|
||||||
|
popd
|
66
bin/executable_docker-traverse.sh
Normal file
66
bin/executable_docker-traverse.sh
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Parse command line arguments
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
key="$1"
|
||||||
|
case "$key" in
|
||||||
|
--image)
|
||||||
|
IMAGE_NAME="$2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Error: Unknown option: $key"
|
||||||
|
echo "Usage: $0 --image IMAGE_NAME"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Define the path to the temporary directory where the files will be extracted
|
||||||
|
DESTINATION="/tmp/docker_images/${IMAGE_NAME}"
|
||||||
|
MANIFEST="${DESTINATION}/manifest.json"
|
||||||
|
|
||||||
|
# Define a function to download and extract the Docker image layers
|
||||||
|
function extract_docker_image {
|
||||||
|
# Pull image to make sure we have it before we save it.
|
||||||
|
docker pull "$IMAGE_NAME"
|
||||||
|
|
||||||
|
# Save the Docker image as a tar file
|
||||||
|
echo "Saving Docker image as a tar file..." >&2
|
||||||
|
docker save "$1" -o "${DESTINATION}/${IMAGE_NAME}.tar"
|
||||||
|
|
||||||
|
# Extract the Docker image layers to the destination directory
|
||||||
|
echo "Extracting Docker image layers..." >&2
|
||||||
|
mkdir -p "${DESTINATION}/layers"
|
||||||
|
tar -xf "${DESTINATION}/${IMAGE_NAME}.tar" -C "${DESTINATION}/"
|
||||||
|
|
||||||
|
# Rename the layer directories to their respective layer IDs
|
||||||
|
LAYERS=$(jq -r '.[0].Layers[]' "${MANIFEST}")
|
||||||
|
|
||||||
|
# Extract each layer
|
||||||
|
for LAYER in ${LAYERS}; do
|
||||||
|
BLOB="${LAYER}"
|
||||||
|
# Extract the layer tar file to the destination directory
|
||||||
|
echo "Extracting layer ${LAYER}..." >&2
|
||||||
|
mkdir -p "${DESTINATION}/$(dirname ${BLOB})"
|
||||||
|
tar -xf "${DESTINATION}/${BLOB}" -C "${DESTINATION}/layers"
|
||||||
|
echo "Layer ${LAYER} extracted" >&2
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ensure that the user has provided the Docker image name using the --image flag
|
||||||
|
if [ -z "$IMAGE_NAME" ]; then
|
||||||
|
echo "Error: Docker image name not provided." >&2
|
||||||
|
echo "Usage: $0 --image IMAGE_NAME" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create the destination directory if it doesn't already exist
|
||||||
|
rm -rf "${DESTINATION}"
|
||||||
|
mkdir -p "${DESTINATION}"
|
||||||
|
|
||||||
|
# Call the function to download and extract the Docker image layers
|
||||||
|
extract_docker_image "$IMAGE_NAME"
|
||||||
|
|
7
bin/executable_exec-sanity.sh
Normal file
7
bin/executable_exec-sanity.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
podid=$(kubectl get pods | rg sanity | rg -v mesh | awk '{print $1}')
|
||||||
|
|
||||||
|
kubectl exec -it "$podid" -- sh
|
33
bin/executable_lunardev.sh
Normal file
33
bin/executable_lunardev.sh
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
function lunardev ()
|
||||||
|
{
|
||||||
|
nolunardev
|
||||||
|
|
||||||
|
tmux new-window -n lunardev
|
||||||
|
|
||||||
|
tmux send-keys -t lunardev "shuttle run local_up" C-m
|
||||||
|
|
||||||
|
# allow for user input
|
||||||
|
tmux split-window -h
|
||||||
|
|
||||||
|
shuttle run generate_dotenv
|
||||||
|
|
||||||
|
|
||||||
|
tmux send-keys -t lunardev 'export $(cat local.env | xargs)' C-m
|
||||||
|
tmux send-keys -t lunardev "air -c ~/.config/air/.air.toml" C-m
|
||||||
|
tmux split-window -v
|
||||||
|
|
||||||
|
export $(cat local.env | xargs)
|
||||||
|
tmux send-keys -t lunardev "PGPASSWORD=$DBPASSWORD psql -h $DBHOST -U $DBUSER -d $DBDATABASE" C-m
|
||||||
|
|
||||||
|
# set user input to first
|
||||||
|
tmux select-pane -t 0
|
||||||
|
|
||||||
|
|
||||||
|
tmux attach-session -t lunardev
|
||||||
|
}
|
||||||
|
|
||||||
|
function nolunardev() {
|
||||||
|
tmux kill-window -t lunardev || true
|
||||||
|
}
|
14
bin/executable_record.sh
Normal file
14
bin/executable_record.sh
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get the current timestamp
|
||||||
|
timestamp=$(date +%Y%m%d%H%M%S)
|
||||||
|
|
||||||
|
# Construct the filename
|
||||||
|
filename="recording_$timestamp.cast"
|
||||||
|
|
||||||
|
mkdir -p ~/Documents/arecordings
|
||||||
|
|
||||||
|
# Start the recording
|
||||||
|
asciinema rec ~/Documents/arecordings/${filename}
|
||||||
|
|
||||||
|
echo "Recording saved to ~/Documents/arecordings/${filename}"
|
19
bin/executable_restart-builds-drone.sh
Normal file
19
bin/executable_restart-builds-drone.sh
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
drone_url=https://ci.i.kjuulh.io/api/
|
||||||
|
auth="Authorization: Bearer z1gpPUNI0dAgxtCqvk1aFhyyRn6S1n05"
|
||||||
|
|
||||||
|
curl -s "${drone_url}user/repos" -H "$auth" | jq -r .[].slug |
|
||||||
|
while read -r repo; do
|
||||||
|
echo "processing $repo"
|
||||||
|
curl -s "${drone_url}repos/$repo/builds" -H "$auth" | jq -c '.[1:5] | .[] | select(.status | contains("failure")) | .number' | jq -r |
|
||||||
|
while read -r build_id; do
|
||||||
|
echo "building: $repo - $build_id"
|
||||||
|
curl -s -X POST "${drone_url}repos/$repo/builds/$build_id" -H "$auth"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
|
16
bin/executable_run-dosier.sh
Normal file
16
bin/executable_run-dosier.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
LOG="$HOME/morning.log"
|
||||||
|
|
||||||
|
exec > >(tee -i ${LOG})
|
||||||
|
exec 2>&1
|
||||||
|
|
||||||
|
echo "# Starting morning run: $(date)"
|
||||||
|
|
||||||
|
pushd ~/git/git.front.kjuulh.io/kjuulh/morning/ || return 1
|
||||||
|
|
||||||
|
cargo run oneshot
|
||||||
|
|
||||||
|
popd || return 1
|
||||||
|
|
||||||
|
echo "Finished monring run: $(date)"
|
13
bin/executable_sanity.sh
Normal file
13
bin/executable_sanity.sh
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
function sanity() {
|
||||||
|
env=${1:-dev}
|
||||||
|
|
||||||
|
k8s "$env"
|
||||||
|
|
||||||
|
pod=$(k get pods -n "$env" | rg sanity | rg -v mesh | awk '{print $1}')
|
||||||
|
|
||||||
|
echo "$pod"
|
||||||
|
|
||||||
|
k exec "$pod" -it -n "$env" -- sh
|
||||||
|
}
|
24
bin/executable_scan-for-bad-indexes.sh
Normal file
24
bin/executable_scan-for-bad-indexes.sh
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
psql -AtF',' -c 'SELECT datname FROM pg_database WHERE datistemplate = false;' | rg -v rdsadmin |
|
||||||
|
while read -r line
|
||||||
|
do
|
||||||
|
echo "running for $line"
|
||||||
|
|
||||||
|
psql -d "$line" -AtF',' -c '
|
||||||
|
SELECT pg_class.relname
|
||||||
|
FROM pg_class, pg_index
|
||||||
|
WHERE pg_index.indisvalid = false
|
||||||
|
AND pg_index.indexrelid = pg_class.oid;'
|
||||||
|
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
|
||||||
|
#psql <<EOF
|
||||||
|
#EOF
|
||||||
|
|
||||||
|
#SELECT pg_class.relname
|
||||||
|
#FROM pg_class, pg_index
|
||||||
|
#AND pg_index.indexrelid = pg_class.oid;
|
9
bin/executable_ssh-agent.sh
Normal file
9
bin/executable_ssh-agent.sh
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
function start-ssh-agent() {
|
||||||
|
eval "$(ssh-agent -s)"
|
||||||
|
|
||||||
|
ssh-add ~/.ssh/github
|
||||||
|
ssh-add ~/.ssh/id_ed25519
|
||||||
|
}
|
||||||
|
|
10
bin/executable_terraform.sh
Normal file
10
bin/executable_terraform.sh
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/zsh
|
||||||
|
|
||||||
|
ta ()
|
||||||
|
{
|
||||||
|
terraform apply
|
||||||
|
}
|
||||||
|
|
||||||
|
ti () {
|
||||||
|
terraform init
|
||||||
|
}
|
9
bin/executable_tmux.sh
Normal file
9
bin/executable_tmux.sh
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
function tcd() {
|
||||||
|
tmux new-window -n tcd
|
||||||
|
|
||||||
|
tmux send-keys -t tcd "," C-m
|
||||||
|
|
||||||
|
tmux select-pane -t 0
|
||||||
|
}
|
22
bin/executable_update-vault.sh
Normal file
22
bin/executable_update-vault.sh
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
LOG="$HOME/update-vault.log"
|
||||||
|
|
||||||
|
exec > >(tee -i ${LOG})
|
||||||
|
exec 2>&1
|
||||||
|
|
||||||
|
echo "# Starting update vault: $(date)"
|
||||||
|
|
||||||
|
pushd ~/Documents/vaults/kjuulh/ || return 1
|
||||||
|
|
||||||
|
git add .
|
||||||
|
|
||||||
|
git commit -m "auto commit"
|
||||||
|
|
||||||
|
git pull origin main --rebase
|
||||||
|
|
||||||
|
git push
|
||||||
|
|
||||||
|
popd || return 1
|
||||||
|
|
||||||
|
echo "Finished update vault: $(date)"
|
21
bin/executable_zimfwupdate.sh
Normal file
21
bin/executable_zimfwupdate.sh
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
function refresh_zimfw() {
|
||||||
|
echo "refreshing zimfw / zplug"
|
||||||
|
cd ~/git/github.com/lunarway/lw-zsh/
|
||||||
|
echo "pulling changes"
|
||||||
|
git pull origin master --rebase
|
||||||
|
git push -f
|
||||||
|
cd
|
||||||
|
cd .zim/modules
|
||||||
|
echo "refreshing zim"
|
||||||
|
rm -rf lw-zsh
|
||||||
|
echo "installing new updates"
|
||||||
|
zimfw install
|
||||||
|
cd
|
||||||
|
echo "done refreshing zimfw / zplug"
|
||||||
|
echo "refreshing zsh"
|
||||||
|
zsh
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user