refactor: move helper scripts into .bin folder and update tasks.json

This commit is contained in:
yeti
2025-05-16 10:02:00 +01:00
parent a565ed4c33
commit 54baa71622
6 changed files with 3 additions and 8 deletions

12
.bin/clean_dangling_images.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
# Get list of image IDs with <none> tag (dangling images)
dangling_images=$(podman images -f "dangling=true" -q)
if [ -z "$dangling_images" ]; then
echo "✅ No dangling images to remove."
else
echo "⚠️ Removing dangling images..."
echo "$dangling_images" | xargs podman rmi -f
echo "🧹 Done!"
fi

9
.bin/create-home-tarball.sh Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail
if [ "$(basename "$(pwd -P)")" != "workspaces" ]; then
echo "Error: this script must be run from a directory named 'workspaces', not '$(basename "$(pwd -P)")'" >&2
exit 1
fi
tar -czf home.tar.gz --owner root --group secproc --xform "s,$PWD,/home/devuser," .config .local .ssh start.sh

39
.bin/generate-user-config.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash
set -euo pipefail
YAML_FILE="access.yml"
TEMPLATE_FILE="gitconfig.template"
USER="$1"
# Extract user fields from YAML
GIT_NAME=$(yq ".\"$USER\".name" "$YAML_FILE")
GIT_EMAIL=$(yq ".\"$USER\".email" "$YAML_FILE")
# Ensure fields are not empty
if [[ -z "$GIT_NAME" || -z "$GIT_EMAIL" ]]; then
echo "❌ Error: User '$USER' not found or missing name/email in $YAML_FILE"
exit 1
fi
# Create output directory
USER_DIR="files/$USER"
mkdir -p "$USER_DIR"
# Generate .gitconfig
env GIT_NAME="$GIT_NAME" GIT_EMAIL="$GIT_EMAIL" \
envsubst <"$TEMPLATE_FILE" >"$USER_DIR/gitconfig"
echo "✅ .gitconfig created at $USER_DIR/gitconfig"
# Generate SSH keypair if it doesn't exist
KEYFILE="$USER_DIR/id_ed25519"
if [[ -f "$KEYFILE" ]]; then
echo "🔑 SSH key already exists for $USER at $KEYFILE"
else
ssh-keygen -t ed25519 -N "" -C "$GIT_EMAIL" -f "$KEYFILE"
echo "✅ SSH keypair generated at:"
echo " 🔐 Private: $KEYFILE"
echo " 🔓 Public : $KEYFILE.pub"
fi

8
.bin/nvim-workspace.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
XDG_CONFIG_HOME="$PWD/.config" \
XDG_DATA_HOME="$PWD/.local/share" \
XDG_STATE_HOME="$PWD/.state" \
XDG_CACHE_HOME="$PWD/.cache" \
TMUX="" \
tmux new-session -s dev -n editor 'nvim'