Skip to content

Commit 6947bd9

Browse files
authored
Enhance logging in sync-ssh-keys.sh for configuration loading and use… (#14)
* Enhance logging in sync-ssh-keys.sh for configuration loading and user counting; update users.conf examples for clarity * Bump script version to 0.1.1
1 parent aab4279 commit 6947bd9

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

sync-ssh-keys.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set -euo pipefail
77
# Repository: https://github.com/locus313/ssh-key-sync
88

99
# shellcheck disable=SC2034 # planned to be used in a future release
10-
readonly SCRIPT_VERSION="0.1.0"
10+
readonly SCRIPT_VERSION="0.1.1"
1111
SCRIPT_NAME="$(basename "$0")"
1212
readonly SCRIPT_NAME
1313

@@ -461,16 +461,25 @@ main() {
461461
fi
462462

463463
# Load and validate configuration
464+
log_info "Loading configuration..."
464465
load_configuration
466+
log_info "Configuration loaded successfully"
467+
468+
log_info "Validating configuration..."
465469
validate_configuration
470+
log_info "Configuration validated successfully"
466471

467472
# Validate USER_KEYS array has entries
468-
local user_count=0
473+
log_info "Counting users..."
474+
user_count=0
469475
if declare -p USER_KEYS &>/dev/null; then
470476
for username in "${!USER_KEYS[@]}"; do
471-
((user_count++))
477+
log_info "Found user: $username"
478+
user_count=$((user_count + 1))
479+
log_info "User count now: $user_count"
472480
done
473481
fi
482+
log_info "Total user count: $user_count"
474483

475484
if [[ $user_count -eq 0 ]]; then
476485
log_warning "No users defined in USER_KEYS array. Nothing to do."

users.conf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ CONF_GITHUB_TOKEN="your_github_token_here"
2020
# User key mapping
2121
# Add or modify entries below according to your needs
2222
declare -A USER_KEYS=(
23-
# Example: Fetch from public URL
24-
["ubuntu"]="raw:https://example.com/ssh-keys/ubuntu.authorized_keys"
23+
# Example: Fetch from public URL (replace with real URL)
24+
# ["ubuntu"]="raw:https://example.com/ssh-keys/ubuntu.authorized_keys"
2525

26-
# Example: Fetch from private GitHub repository
27-
["devuser"]="api:https://api.github.com/repos/yourorg/ssh-keys/contents/keys/devuser.authorized_keys?ref=main"
26+
# Example: Fetch from private GitHub repository (replace with real repo)
27+
# ["devuser"]="api:https://api.github.com/repos/yourorg/ssh-keys/contents/keys/devuser.authorized_keys?ref=main"
2828

29-
# Example: Fetch public keys from GitHub user
30-
["alice"]="ghuser:alice-github-username"
29+
# Example: Fetch public keys from GitHub user (replace with real username)
30+
# ["alice"]="ghuser:your-github-username"
3131
)
3232

3333
# Additional configuration options can be added here as needed

0 commit comments

Comments
 (0)