From d4180b34e665e8f2072ba90130bafbea42659c82 Mon Sep 17 00:00:00 2001 From: ahuston-0 Date: Tue, 18 Mar 2025 18:17:59 -0400 Subject: [PATCH] remove unneeded utils Signed-off-by: ahuston-0 --- utils/attic-token.bash | 36 --------------- utils/attic-utils.bash | 13 ------ utils/fetch-docker.sh | 23 ---------- utils/new.yaml | 14 ------ utils/old.yaml | 10 ----- utils/requirements.txt | 1 - utils/sops-add-machine.py | 20 --------- utils/sops-mergetool-new.sh | 67 ---------------------------- utils/sops-mergetool.sh | 88 ------------------------------------- 9 files changed, 272 deletions(-) delete mode 100755 utils/attic-token.bash delete mode 100644 utils/attic-utils.bash delete mode 100755 utils/fetch-docker.sh delete mode 100644 utils/new.yaml delete mode 100644 utils/old.yaml delete mode 100644 utils/requirements.txt delete mode 100755 utils/sops-add-machine.py delete mode 100755 utils/sops-mergetool-new.sh delete mode 100755 utils/sops-mergetool.sh diff --git a/utils/attic-token.bash b/utils/attic-token.bash deleted file mode 100755 index f069375..0000000 --- a/utils/attic-token.bash +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash - -if (($# != 3)); then - echo "usage: $0 " - exit 1 -fi - -cache="$1" -cache_pattern="$2" -token_type="$3" - -case $token_type in -"cache-creator") - atticd-atticadm make-token --sub "$cache-cache-creator" --validity "1y" \ - --pull "$cache_pattern" --push "$cache_pattern" --delete "$cache_pattern" \ - --create-cache "$cache_pattern" --configure-cache "$cache_pattern" \ - --configure-cache-retention "$cache_pattern" --destroy-cache "$cache_pattern" - ;; -"admin") - atticd-atticadm make-token --sub "$cache-admin" --validity "1y" --pull "$cache_pattern" \ - --push "$cache_pattern" --configure-cache "$cache_pattern" \ - --configure-cache-retention "$cache_pattern" - ;; -"writer") - atticd-atticadm make-token --sub "$cache-writer" --validity "1y" --pull "$cache_pattern" \ - --push "$cache_pattern" - ;; -"reader") - atticd-atticadm make-token --sub "$cache-reader" --validity "1y" --pull "$cache_pattern" - ;; -*) - echo "invalid token type: $token_type" - echo "available options: cache-creator, admin, writer, reader" - exit 1 - ;; -esac diff --git a/utils/attic-utils.bash b/utils/attic-utils.bash deleted file mode 100644 index ebae713..0000000 --- a/utils/attic-utils.bash +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -cache_name="" -action="" - -case "$action" in - "login") - ;; - *) - echo "" - exit 1 - ;; -esac diff --git a/utils/fetch-docker.sh b/utils/fetch-docker.sh deleted file mode 100755 index 637b3c6..0000000 --- a/utils/fetch-docker.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env nix -#! nix shell nixpkgs#bash nixpkgs#nix-prefetch-docker --command bash - -# retrieves the latest image tags - -set -x -set -v -set -e - -script_path=$(dirname "$(readlink -f $0)") -parent_path=$(dirname "$script_path") - -# a list of images to pull -# relpath is the relative path to the parent_path where you want the file written -# format: ,,,, -images=( - "nextcloud,apache,amd64,linux,/systems/palatine-hill/docker/nextcloud-image/nextcloud-apache.nix" -) -IFS="," -while read -r name tag arch os relpath; do - nix-prefetch-docker --image-name "$name" --image-tag "$tag" --arch "$arch" --os "$os" --quiet >"$parent_path/$relpath" - git --no-pager diff "$parent_path/$relpath" -done <<<"${images[@]}" diff --git a/utils/new.yaml b/utils/new.yaml deleted file mode 100644 index 3ac2526..0000000 --- a/utils/new.yaml +++ /dev/null @@ -1,14 +0,0 @@ -network: - ethernets: - addresses: - - 155.128.134.198/23 - - 2002:18f0:b009:f84:5200:03ff:fdf7:d0c2/64 - - abc - dhcp4: false - ens3: null - gateway4: 155.128.134.198 - nameservers: - addresses: - - 108.61.10.10 - renderer: networkd - version: 2 diff --git a/utils/old.yaml b/utils/old.yaml deleted file mode 100644 index 788a11b..0000000 --- a/utils/old.yaml +++ /dev/null @@ -1,10 +0,0 @@ -network: - version: 2 - renderer: networkd - ethernets: - ens3: - dhcp4: no - addresses: [155.128.134.198/23,'2002:18f0:b009:f84:5200:03ff:fdf7:d0c2/64'] - gateway4: 155.128.134.198 - nameservers: - addresses: [108.61.10.10] diff --git a/utils/requirements.txt b/utils/requirements.txt deleted file mode 100644 index c3726e8..0000000 --- a/utils/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pyyaml diff --git a/utils/sops-add-machine.py b/utils/sops-add-machine.py deleted file mode 100755 index e34fa84..0000000 --- a/utils/sops-add-machine.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env nix -#! nix shell nixpkgs#python312 nixpkgs#python312Packages.pyyaml --command python - -import yaml -import pprint - -with open(".sops.yaml", "r") as in_yamlfile: - cur_yaml = yaml.safe_load(in_yamlfile) - -cur_yaml["keys"].append("&test testkey") - -pprint.pprint(cur_yaml) - -# with open('new.yaml','w') as out_yamlfile: -# yaml.safe_dump(cur_yaml, out_yamlfile) - -# with open('new.yaml','r') as inn_yamlfile: -# new_yaml = yaml.safe_load(inn_yamlfile) - -# assert(cur_yaml == new_yaml) diff --git a/utils/sops-mergetool-new.sh b/utils/sops-mergetool-new.sh deleted file mode 100755 index fc425c9..0000000 --- a/utils/sops-mergetool-new.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash - -# Rename CLI parameters to friendlier names -# https://git-scm.com/docs/gitattributes#_defining_a_custom_merge_driver -base="$1" -local_="$2" -remote="$3" -merged="$4" - -# Load the mergetool scripts -TOOL_MODE=merge -source "$(git --exec-path)/git-mergetool--lib" -mergetool=$(get_merge_tool) -setup_tool "${mergetool}" - -# Create file names for decrypted contents -# example_LOCAL_2823.yaml -> example_LOCAL_2823.decrypted.yaml -extension=".${base##*.}" -base_decrypted="${base/$extension/.decrypted$extension}" -local_decrypted="${local_/$extension/.decrypted$extension}" -remote_decrypted="${remote/$extension/.decrypted$extension}" -merged_decrypted="${base_decrypted/_BASE_/_MERGED_}" -backup_decrypted="${base_decrypted/_BASE_/_BACKUP_}" - -# If anything goes wrong, then delete our decrypted files -handle_trap_exit() { - rm $base_decrypted || true - rm $local_decrypted || true - rm $remote_decrypted || true - rm $merged_decrypted || true - rm $backup_decrypted || true -} -trap handle_trap_exit EXIT - -# Decrypt our file contents -sops --decrypt --show-master-keys "$base" >"$base_decrypted" -sops --decrypt --show-master-keys "$local_" >"$local_decrypted" -sops --decrypt --show-master-keys "$remote" >"$remote_decrypted" - -# Create a merge-diff to compare against -git merge-file -p "$local_decrypted" "$base_decrypted" "$remote_decrypted" >"$merged_decrypted" -cp "$merged_decrypted" "$backup_decrypted" - -# Set up variables for the mergetool -# https://github.com/git/git/blob/v2.8.2/mergetools/meld -# https://github.com/git/git/blob/v2.8.2/git-mergetool--lib.sh#L95-L111 -LOCAL="$local_decrypted" -BASE="$base_decrypted" -REMOTE="$remote_decrypted" -MERGED="$merged_decrypted" -BACKUP="$backup_decrypted" - -# Override `check_unchanged` with a custom script -check_unchanged() { - # If the contents haven't changed, then fail - if test "$MERGED" -nt "$BACKUP"; then - return 0 - else - exit 1 - fi -} - -# Run the mergetool -run_merge_tool "${mergetool}" true - -# Re-encrypt content -sops --encrypt "$merged_decrypted" >"$merged" diff --git a/utils/sops-mergetool.sh b/utils/sops-mergetool.sh deleted file mode 100755 index 591562e..0000000 --- a/utils/sops-mergetool.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env bash -# Exit on first error and verify variables have been set/passed via CLI -#set -eu -set -v -set -x - -# Rename our variables to friendlier equivalents -# https://git-scm.com/docs/gitattributes#_defining_a_custom_merge_driver -base="$1" -local_="$2" -remote="$3" -merged="$4" - -echo "$base" -echo "$local_" -echo "$remote" -echo "$merged" - -# Resolve our default mergetool -# https://github.com/git/git/blob/v2.8.2/git-mergetool--lib.sh#L3 -mergetool="$(git config --get merge.tool)" -GIT_DIR="$(git --exec-path)" -if test "$mergetool" = ""; then - echo 'No default `merge.tool` was set for `git`. Please set one via `git config --set merge.tool `' 1>&2 - exit 1 -fi - -# Create file names for our decrypted contents -# example_LOCAL_2823.yaml -> example_LOCAL_2823.decrypted.yaml -extension=".${base##*.}" -base_decrypted="${base/$extension/.decrypted$extension}" -local_decrypted="${local_/$extension/.decrypted$extension}" -remote_decrypted="${remote/$extension/.decrypted$extension}" -merged_decrypted="${base_decrypted/_BASE_/_MERGED_}" -backup_decrypted="${base_decrypted/_BASE_/_BACKUP_}" - -# If anything goes wrong, then delete our decrypted files -handle_trap_exit() { - rm $base_decrypted || true - rm $local_decrypted || true - rm $remote_decrypted || true - rm $merged_decrypted || true - rm $backup_decrypted || true -} -trap handle_trap_exit EXIT - -# Decrypt our file contents -sops --decrypt --show-master-keys "$base" >"$base_decrypted" -sops --decrypt --show-master-keys "$local_" >"$local_decrypted" -sops --decrypt --show-master-keys "$remote" >"$remote_decrypted" - -# Create a merge-diff to compare against -set +e -git merge-file -p "$local_decrypted" "$base_decrypted" "$remote_decrypted" >"$merged_decrypted" -set -e -cp "$merged_decrypted" "$backup_decrypted" - -# Set up variables for our mergetool -# https://github.com/git/git/blob/v2.8.2/mergetools/meld -# https://github.com/git/git/blob/v2.8.2/git-mergetool--lib.sh#L95-L111 -export LOCAL="$local_decrypted" -export BASE="$base_decrypted" -export REMOTE="$remote_decrypted" -export MERGED="$merged_decrypted" -export BACKUP="$backup_decrypted" - -# Load our mergetool scripts -source "$GIT_DIR/git-mergetool--lib" -source "$GIT_DIR/mergetools/$mergetool" - -# Override `check_unchanged` with a custom script -check_unchanged() { - # If the contents haven't changed, then fail - if test "$MERGED" -nt "$BACKUP"; then - return 0 - else - exit 1 - fi -} - -# Run our mergetool -set +eu -export merge_tool_path="$(get_merge_tool_path "$mergetool")" -merge_cmd -set -eu - -# Re-encrypt content -sops --encrypt "$merged_decrypted" >"$merged"