-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·71 lines (61 loc) · 1.43 KB
/
run.sh
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
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Source common libraries
source "${SCRIPT_DIR}/lib/logging.sh"
# Command definitions
COMMANDS=(
"switchover:Perform database switchover between primary and replica"
"test-setup:Set up new environment"
"help:Show this help message"
)
usage() {
echo "Database Upgrade"
echo
echo "Usage: $0 <command> [options]"
echo
echo "Available commands:"
for cmd in "${COMMANDS[@]}"; do
IFS=':' read -r command description <<< "$cmd"
printf " %-15s %s\n" "$command" "$description"
done
echo
echo "For command-specific help, run:"
echo " $0 <command> --help"
}
run_switchover() {
log_info "Running switchover..."
"${SCRIPT_DIR}/scripts/switchover.sh" "$@"
}
run_test-setup() {
log_info "Running database setup..."
"${SCRIPT_DIR}/scripts/test-setup.sh" "$@"
}
# Main execution
main() {
# Check if no command provided
if [ $# -eq 0 ]; then
usage
exit 1
fi
# Get the command
CMD=$1
shift # Remove the command from arguments
# Process the command
case $CMD in
switchover)
run_switchover "$@"
;;
test-setup)
run_test-setup "$@"
;;
help)
usage
;;
*)
log_error "Unknown command: $CMD"
usage
exit 1
;;
esac
}
main "$@"