gitlab-upgrade-path-calculator v1.01: add -h flag, 19.x stops, colorized output
Amp-Thread-ID: https://ampcode.com/threads/T-019e662f-3078-74f7-af23-0aabb46d0d79 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
#### Author: Phil Connor ####
|
#### Author: Phil Connor ####
|
||||||
#### Contact: contact@mylinux.work ####
|
#### Contact: contact@mylinux.work ####
|
||||||
#### License: MIT ####
|
#### License: MIT ####
|
||||||
#### Version 1.00 ####
|
#### Version 1.01 ####
|
||||||
#### ####
|
#### ####
|
||||||
#### Usage: ####
|
#### Usage: ####
|
||||||
#### ./gitlab-upgrade-path-calculator.sh --from 16.3.0 --to 18.2.0 ####
|
#### ./gitlab-upgrade-path-calculator.sh --from 16.3.0 --to 18.2.0 ####
|
||||||
@@ -66,6 +66,10 @@ STOPS=(
|
|||||||
"18.5.0|0|Required stop (18.x predictable schedule)"
|
"18.5.0|0|Required stop (18.x predictable schedule)"
|
||||||
"18.8.0|0|Required stop (18.x predictable schedule)"
|
"18.8.0|0|Required stop (18.x predictable schedule)"
|
||||||
"18.11.0|0|Required stop (18.x predictable schedule)"
|
"18.11.0|0|Required stop (18.x predictable schedule)"
|
||||||
|
"19.2.0|0|Required stop (19.x predictable schedule)"
|
||||||
|
"19.5.0|0|Required stop (19.x predictable schedule)"
|
||||||
|
"19.8.0|0|Required stop (19.x predictable schedule)"
|
||||||
|
"19.11.0|0|Required stop (19.x predictable schedule)"
|
||||||
)
|
)
|
||||||
|
|
||||||
# ── PostgreSQL Requirements ───────────────────────────────────────────────────
|
# ── PostgreSQL Requirements ───────────────────────────────────────────────────
|
||||||
@@ -78,9 +82,10 @@ PG_REQS=(
|
|||||||
"16|13|15"
|
"16|13|15"
|
||||||
"17|14|16"
|
"17|14|16"
|
||||||
"18|16|17"
|
"18|16|17"
|
||||||
|
"19|16|17"
|
||||||
)
|
)
|
||||||
|
|
||||||
LATEST_VERSION="18.11.0"
|
LATEST_VERSION="19.11.0"
|
||||||
|
|
||||||
# ── Colors ────────────────────────────────────────────────────────────────────
|
# ── Colors ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -169,7 +174,7 @@ parse_args() {
|
|||||||
--format) FORMAT="$2"; shift 2 ;;
|
--format) FORMAT="$2"; shift 2 ;;
|
||||||
--no-color) COLOR="never"; shift ;;
|
--no-color) COLOR="never"; shift ;;
|
||||||
--verbose) VERBOSE="true"; shift ;;
|
--verbose) VERBOSE="true"; shift ;;
|
||||||
--help) show_help; exit 0 ;;
|
-h|--help) show_help; exit 0 ;;
|
||||||
*) die "Unknown option: $1" ;;
|
*) die "Unknown option: $1" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -375,7 +380,7 @@ format_path_text() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "\n ── Upgrade Path ──────────────────────────────────────────\n\n"
|
printf "\n ${CYAN}── Upgrade Path ──────────────────────────────────────────${RESET}\n\n"
|
||||||
printf " ${DIM}Step Version Notes PG Required${RESET}\n"
|
printf " ${DIM}Step Version Notes PG Required${RESET}\n"
|
||||||
printf " ${DIM}──── ──────────── ─────────────────────────────────────── ──────────${RESET}\n"
|
printf " ${DIM}──── ──────────── ─────────────────────────────────────── ──────────${RESET}\n"
|
||||||
|
|
||||||
@@ -400,16 +405,20 @@ format_path_text() {
|
|||||||
cond_marker=" ⓘ"
|
cond_marker=" ⓘ"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local ver_color="$RESET"
|
local ver_color="$CYAN"
|
||||||
|
local note_color="$RESET"
|
||||||
if [[ "$notes" == "Target version" ]]; then
|
if [[ "$notes" == "Target version" ]]; then
|
||||||
ver_color="$GREEN"
|
ver_color="$GREEN"
|
||||||
|
note_color="$GREEN"
|
||||||
|
elif [[ "$conditional" == "1" ]]; then
|
||||||
|
note_color="$YELLOW"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf " %3d ${ver_color}%-12s${RESET} %-39s %s\n" "$step" "$ver" "${notes}${cond_marker}" "$pg_range"
|
printf " %3d ${ver_color}%-12s${RESET} ${note_color}%-39s${RESET} ${DIM}%s${RESET}\n" "$step" "$ver" "${notes}${cond_marker}" "$pg_range"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ ${#PG_WARNINGS[@]} -gt 0 ]]; then
|
if [[ ${#PG_WARNINGS[@]} -gt 0 ]]; then
|
||||||
printf "\n ── PostgreSQL Upgrade Required ───────────────────────────\n\n"
|
printf "\n ${CYAN}── PostgreSQL Upgrade Required ───────────────────────────${RESET}\n\n"
|
||||||
local warning
|
local warning
|
||||||
for warning in "${PG_WARNINGS[@]}"; do
|
for warning in "${PG_WARNINGS[@]}"; do
|
||||||
IFS='|' read -r msg action gl_major pg_min pg_max <<< "$warning"
|
IFS='|' read -r msg action gl_major pg_min pg_max <<< "$warning"
|
||||||
@@ -419,19 +428,19 @@ format_path_text() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
estimate_downtime
|
estimate_downtime
|
||||||
printf " ── Estimated Downtime ────────────────────────────────────\n\n"
|
printf " ${CYAN}── Estimated Downtime ────────────────────────────────────${RESET}\n\n"
|
||||||
printf " Software: %d stops × 5-15 min = %d-%d min\n" "${#UPGRADE_PATH[@]}" "$DT_SW_LOW" "$DT_SW_HIGH"
|
printf " ${BOLD}Software:${RESET} %d stops × 5-15 min = %d-%d min\n" "${#UPGRADE_PATH[@]}" "$DT_SW_LOW" "$DT_SW_HIGH"
|
||||||
printf " ${DIM}(package install + gitlab-ctl reconfigure)${RESET}\n"
|
printf " ${DIM}(package install + gitlab-ctl reconfigure)${RESET}\n"
|
||||||
if [[ -n "$DB_SIZE" ]]; then
|
if [[ -n "$DB_SIZE" ]]; then
|
||||||
printf " Migrations: %d stops × %s db = %d-%d min\n" "${#UPGRADE_PATH[@]}" "$DB_SIZE" "$DT_MIG_LOW" "$DT_MIG_HIGH"
|
printf " ${BOLD}Migrations:${RESET} %d stops × %s db = %d-%d min\n" "${#UPGRADE_PATH[@]}" "$DB_SIZE" "$DT_MIG_LOW" "$DT_MIG_HIGH"
|
||||||
printf " ${DIM}(background migrations must complete per stop)${RESET}\n"
|
printf " ${DIM}(background migrations must complete per stop)${RESET}\n"
|
||||||
else
|
else
|
||||||
printf " Migrations: ${DIM}use --db-size (small/medium/large/xlarge) for estimates${RESET}\n"
|
printf " ${BOLD}Migrations:${RESET} ${DIM}use --db-size (small/medium/large/xlarge) for estimates${RESET}\n"
|
||||||
fi
|
fi
|
||||||
if [[ ${#PG_WARNINGS[@]} -gt 0 ]]; then
|
if [[ ${#PG_WARNINGS[@]} -gt 0 ]]; then
|
||||||
printf " PG upgrades: %d × 15-60 min = %d-%d min\n" "${#PG_WARNINGS[@]}" "$DT_PG_LOW" "$DT_PG_HIGH"
|
printf " ${BOLD}PG upgrades:${RESET} %d × 15-60 min = %d-%d min\n" "${#PG_WARNINGS[@]}" "$DT_PG_LOW" "$DT_PG_HIGH"
|
||||||
fi
|
fi
|
||||||
printf "\n ${BOLD}Total estimate: %d-%d min${RESET}" "$DT_TOTAL_LOW" "$DT_TOTAL_HIGH"
|
printf "\n ${BOLD}${GREEN}Total estimate: %d-%d min${RESET}" "$DT_TOTAL_LOW" "$DT_TOTAL_HIGH"
|
||||||
if (( DT_TOTAL_HIGH >= 120 )); then
|
if (( DT_TOTAL_HIGH >= 120 )); then
|
||||||
local hours_low=$(( DT_TOTAL_LOW / 60 ))
|
local hours_low=$(( DT_TOTAL_LOW / 60 ))
|
||||||
local hours_high=$(( DT_TOTAL_HIGH / 60 ))
|
local hours_high=$(( DT_TOTAL_HIGH / 60 ))
|
||||||
|
|||||||
Reference in New Issue
Block a user