diff options
Diffstat (limited to 'docs/how-to/migration-scripts/31-extract-purgatory-expiry.sh')
| -rwxr-xr-x | docs/how-to/migration-scripts/31-extract-purgatory-expiry.sh | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/docs/how-to/migration-scripts/31-extract-purgatory-expiry.sh b/docs/how-to/migration-scripts/31-extract-purgatory-expiry.sh index 8cadad9..a20780e 100755 --- a/docs/how-to/migration-scripts/31-extract-purgatory-expiry.sh +++ b/docs/how-to/migration-scripts/31-extract-purgatory-expiry.sh | |||
| @@ -76,6 +76,14 @@ | |||
| 76 | 76 | ||
| 77 | set -euo pipefail | 77 | set -euo pipefail |
| 78 | 78 | ||
| 79 | # Get script directory for sourcing helpers | ||
| 80 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| 81 | |||
| 82 | # Source the service validation helper | ||
| 83 | if [[ -f "$SCRIPT_DIR/validate-service.sh" ]]; then | ||
| 84 | source "$SCRIPT_DIR/validate-service.sh" | ||
| 85 | fi | ||
| 86 | |||
| 79 | # Colors for output (disabled if not a terminal) | 87 | # Colors for output (disabled if not a terminal) |
| 80 | if [[ -t 1 ]]; then | 88 | if [[ -t 1 ]]; then |
| 81 | RED='\033[0;31m' | 89 | RED='\033[0;31m' |
| @@ -195,11 +203,35 @@ main() { | |||
| 195 | esac | 203 | esac |
| 196 | done | 204 | done |
| 197 | 205 | ||
| 198 | # Validate service name | 206 | # Validate service name format |
| 199 | if [[ ! "$service" =~ \.service$ ]]; then | 207 | if [[ ! "$service" =~ \.service$ ]]; then |
| 200 | service="${service}.service" | 208 | service="${service}.service" |
| 201 | fi | 209 | fi |
| 202 | 210 | ||
| 211 | # Validate service is appropriate for structured logging | ||
| 212 | # This prevents the common mistake of using ngit-relay instead of ngit-grasp | ||
| 213 | if type validate_service_for_structured_logging &>/dev/null; then | ||
| 214 | # Use non-interactive mode if not a terminal, skip log check (we'll do our own) | ||
| 215 | local interactive="true" | ||
| 216 | [[ ! -t 0 ]] && interactive="false" | ||
| 217 | |||
| 218 | if ! validate_service_for_structured_logging "$service" "false" "$interactive"; then | ||
| 219 | log_error "Service validation failed. Use an ngit-grasp service for structured logging." | ||
| 220 | exit 1 | ||
| 221 | fi | ||
| 222 | else | ||
| 223 | # Fallback validation if helper not available | ||
| 224 | if [[ "$service" == *"ngit-relay"* ]]; then | ||
| 225 | log_error "Service name appears to be ngit-relay: $service" | ||
| 226 | log_error "Structured logging ([PURGATORY_EXPIRED]) only exists in ngit-grasp services." | ||
| 227 | log_error "Please use the ngit-grasp archive service instead." | ||
| 228 | log_error "" | ||
| 229 | log_error "To find the correct service:" | ||
| 230 | log_error " systemctl list-units 'ngit-grasp*' --all" | ||
| 231 | exit 1 | ||
| 232 | fi | ||
| 233 | fi | ||
| 234 | |||
| 203 | log_info "Extracting purgatory expiry events from systemd logs" | 235 | log_info "Extracting purgatory expiry events from systemd logs" |
| 204 | log_info "Service: $service" | 236 | log_info "Service: $service" |
| 205 | log_info "Output: $output_dir" | 237 | log_info "Output: $output_dir" |