From 509fd5187937ceaed3256a284da3790f76eb2a49 Mon Sep 17 00:00:00 2001 From: "Aaron D. Lee" Date: Wed, 24 Dec 2025 19:26:21 -0500 Subject: [PATCH] Dotfiles update 2025-12-24 19:26 --- bin/dotfiles-update.sh | 6 ++-- bin/dotfiles-vault.sh | 74 ++++++++++++++++++++--------------------- bin/dotfiles-version.sh | 2 +- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/bin/dotfiles-update.sh b/bin/dotfiles-update.sh index fee778a..158e758 100755 --- a/bin/dotfiles-update.sh +++ b/bin/dotfiles-update.sh @@ -44,7 +44,7 @@ source "$DOTFILES_DIR/zsh/lib/colors.zsh" 2>/dev/null || { DF_GREEN=$'\033[0;32m' DF_YELLOW=$'\033[1;33m' DF_RED=$'\033[0;31m' DF_BLUE=$'\033[0;34m' DF_CYAN=$'\033[0;36m' DF_NC=$'\033[0m' DF_GREY=$'\033[38;5;242m' DF_LIGHT_BLUE=$'\033[38;5;39m' - DF_BOLD=$'\033[1m' DF_DIM=$'\033[2m' + DF_BOLD=$'\033[1m' DF_DIM=$'\033[2m' DF_LIGHT_GREEN=$'\033[38;5;82m' } # ============================================================================ @@ -60,10 +60,10 @@ print_header() { local datetime=$(date '+%a %b %d %H:%M') local width=66 local hline="" && for ((i=0; i/dev/null || { print_header() { if declare -f df_print_header &>/dev/null; then - df_print_header "dotfiles-vault" + df_print_header "dotfiles-vault " else local user="${USER:-root}" local hostname="${HOSTNAME:-$(hostname -s 2>/dev/null)}" local datetime=$(date '+%a %b %d %H:%M') local width=66 local hline="" && for ((i=0; i "$VAULT_FILE" print_success "Vault initialized" @@ -90,9 +90,9 @@ decrypt_vault() { echo "{}" return fi - + local cipher=$(get_cipher) - + case "$cipher" in age) age -d -i "$HOME/.age/keys.txt" "$VAULT_FILE" 2>/dev/null || echo "{}" @@ -106,7 +106,7 @@ decrypt_vault() { encrypt_vault() { local data="$1" local cipher=$(get_cipher) - + case "$cipher" in age) echo "$data" | age -R "$HOME/.age/keys.txt" > "$VAULT_FILE" @@ -124,39 +124,39 @@ encrypt_vault() { vault_set() { local key="$1" local value="${2:-}" - + if [[ -z "$key" ]]; then print_error "Usage: vault set [value]" exit 1 fi - + if [[ -z "$value" ]]; then read -s -p "Enter value for $key: " value echo "" fi - + local current=$(decrypt_vault) - + if command -v jq &> /dev/null; then local updated=$(echo "$current" | jq --arg k "$key" --arg v "$value" '.[$k] = $v') else local updated="{\"$key\": \"$value\"}" fi - + encrypt_vault "$updated" print_success "Secret stored: $key" } vault_get() { local key="$1" - + if [[ -z "$key" ]]; then print_error "Usage: vault get " exit 1 fi - + local vault=$(decrypt_vault) - + if command -v jq &> /dev/null; then echo "$vault" | jq -r ".\"$key\" // \"\"" | grep -v "^$" else @@ -166,9 +166,9 @@ vault_get() { vault_list() { print_section "Secrets" - + local vault=$(decrypt_vault) - + if command -v jq &> /dev/null; then echo "$vault" | jq -r 'keys[]' | while read key; do echo -e " ${DF_CYAN}•${DF_NC} $key" @@ -178,36 +178,36 @@ vault_list() { echo -e " ${DF_CYAN}•${DF_NC} $key" done fi - + echo "" } vault_delete() { local key="$1" - + if [[ -z "$key" ]]; then print_error "Usage: vault delete " exit 1 fi - + local vault=$(decrypt_vault) - + if command -v jq &> /dev/null; then local updated=$(echo "$vault" | jq "del(.\"$key\")") else print_error "jq required for delete operation" exit 1 fi - + encrypt_vault "$updated" print_success "Secret deleted: $key" } vault_shell() { print_section "Loading secrets into environment" - + local vault=$(decrypt_vault) - + if command -v jq &> /dev/null; then echo "$vault" | jq -r 'to_entries[] | "export \(.key)=\"\(.value)\""' else @@ -218,17 +218,17 @@ vault_shell() { vault_export() { local dest="${1:-.}" - + if [[ -z "$dest" ]]; then print_error "Usage: vault export " exit 1 fi - + if [[ -f "$dest" ]]; then print_error "File already exists: $dest" exit 1 fi - + cp "$VAULT_FILE" "$dest" chmod 600 "$dest" print_success "Vault exported to: $dest" @@ -236,17 +236,17 @@ vault_export() { vault_import() { local src="${1:-}" - + if [[ -z "$src" ]]; then print_error "Usage: vault import " exit 1 fi - + if [[ ! -f "$src" ]]; then print_error "File not found: $src" exit 1 fi - + cp "$src" "$VAULT_FILE" chmod 600 "$VAULT_FILE" print_success "Vault imported from: $src" @@ -254,26 +254,26 @@ vault_import() { vault_status() { print_section "Vault Status" - + if [[ ! -d "$VAULT_DIR" ]]; then echo -e " ${DF_YELLOW}⚠${DF_NC} Vault not initialized" return fi - + if [[ ! -f "$VAULT_FILE" ]]; then echo -e " ${DF_YELLOW}⚠${DF_NC} Vault file not found" return fi - + local size=$(du -h "$VAULT_FILE" | cut -f1) local modified=$(stat -c %y "$VAULT_FILE" 2>/dev/null | cut -d' ' -f1 || stat -f '%Sm' "$VAULT_FILE" 2>/dev/null) - + echo -e " ${DF_CYAN}Location:${DF_NC} $VAULT_FILE" echo -e " ${DF_CYAN}Size:${DF_NC} $size" echo -e " ${DF_CYAN}Modified:${DF_NC} $modified" echo -e " ${DF_CYAN}Encryption:${DF_NC} $(get_cipher)" echo -e " ${DF_CYAN}Permissions:${DF_NC} $(stat -c '%a' $VAULT_FILE 2>/dev/null || stat -f '%a' "$VAULT_FILE")" - + echo "" } @@ -283,11 +283,11 @@ vault_status() { main() { print_header - + if [[ ! -d "$VAULT_DIR" ]]; then init_vault fi - + case "${1:-list}" in init) init_vault diff --git a/bin/dotfiles-version.sh b/bin/dotfiles-version.sh index bdebc5a..7a84088 100755 --- a/bin/dotfiles-version.sh +++ b/bin/dotfiles-version.sh @@ -47,7 +47,7 @@ done print_header() { if declare -f df_print_header &>/dev/null; then - df_print_header "dotfiles-version" + df_print_header "dotfiles-version " else local user="${USER:-root}" local hostname="${HOSTNAME:-$(hostname -s 2>/dev/null)}"