-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_grid_coordinates.sh
More file actions
executable file
·120 lines (105 loc) · 2.88 KB
/
fix_grid_coordinates.sh
File metadata and controls
executable file
·120 lines (105 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
# Wrapper script to fix Maidenhead grid coordinates in ClickHouse tables
# Sources credentials from /etc/wsprdaemon/clickhouse.conf
set -e
# Source ClickHouse credentials
if [[ -f /etc/wsprdaemon/clickhouse.conf ]]; then
source /etc/wsprdaemon/clickhouse.conf
else
echo "ERROR: /etc/wsprdaemon/clickhouse.conf not found" >&2
exit 1
fi
# Determine Python path
if [[ -f /opt/wsprdaemon-server/venv/bin/python3 ]]; then
PYTHON="/opt/wsprdaemon-server/venv/bin/python3"
elif command -v python3 &> /dev/null; then
PYTHON="python3"
else
echo "ERROR: python3 not found" >&2
exit 1
fi
# Script location
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPT="${SCRIPT_DIR}/fix_grid_coordinates.py"
if [[ ! -f "$SCRIPT" ]]; then
echo "ERROR: fix_grid_coordinates.py not found at $SCRIPT" >&2
exit 1
fi
# Default options
DRY_RUN=""
VERBOSE=""
BATCH_SIZE="10000"
LIMIT=""
SKIP_WSPRNET=""
SKIP_WSPRDAEMON=""
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--dry-run)
DRY_RUN="--dry-run"
shift
;;
--verbose)
VERBOSE="--verbose"
shift
;;
--batch-size)
BATCH_SIZE="$2"
shift 2
;;
--limit)
LIMIT="--limit $2"
shift 2
;;
--skip-wsprnet)
SKIP_WSPRNET="--skip-wsprnet"
shift
;;
--skip-wsprdaemon)
SKIP_WSPRDAEMON="--skip-wsprdaemon"
shift
;;
-h|--help)
cat << EOF
Fix Maidenhead Grid Coordinates in ClickHouse Tables
Usage: $0 [OPTIONS]
Options:
--dry-run Show what would be updated without making changes
--verbose Enable verbose logging
--batch-size N Rows per batch (default: 10000)
--limit N Limit total rows to process (for testing)
--skip-wsprnet Skip wsprnet.spots table
--skip-wsprdaemon Skip wsprdaemon.spots_extended table
-h, --help Show this help
Examples:
# Dry run to see what would be changed
$0 --dry-run
# Test with limited rows
$0 --dry-run --limit 1000
# Actually fix the coordinates
$0
# Fix only wsprdaemon table
$0 --skip-wsprnet
Credentials are loaded from /etc/wsprdaemon/clickhouse.conf
EOF
exit 0
;;
*)
echo "Unknown option: $1" >&2
echo "Use --help for usage information" >&2
exit 1
;;
esac
done
# Run the Python script
exec "$PYTHON" "$SCRIPT" \
--clickhouse-host "${CLICKHOUSE_HOST}" \
--clickhouse-port "${CLICKHOUSE_PORT}" \
--clickhouse-user "${CLICKHOUSE_ROOT_ADMIN_USER}" \
--clickhouse-password "${CLICKHOUSE_ROOT_ADMIN_PASSWORD}" \
--batch-size "${BATCH_SIZE}" \
${DRY_RUN} \
${VERBOSE} \
${LIMIT} \
${SKIP_WSPRNET} \
${SKIP_WSPRDAEMON}