feat: add flyaway repair to updater
This commit is contained in:
1 parent
ed5b9a6f7c
commit
474de0717b
1 file changed
+142
-7
+142
-7
@@ -174,7 +174,10 @@ load_language() {
|
|||||||
["Cron Scheduler"]="Cron Planner"
|
["Cron Scheduler"]="Cron Planner"
|
||||||
["View Git Stashes"]="Bekijk Git Stashes"
|
["View Git Stashes"]="Bekijk Git Stashes"
|
||||||
["Exit"]="Afsluiten"
|
["Exit"]="Afsluiten"
|
||||||
["Select [0-20]"]="Selecteer [0-20]"
|
["Flyaway Repair"]="Vliegende Reparatie"
|
||||||
|
["Rebuild Frontend"]="Frontend Herbouwen"
|
||||||
|
["Rebuild Emulator"]="Emulator Herbouwen"
|
||||||
|
["Select [0-20]"]="Selecteer [0-21]"
|
||||||
["Press Enter to continue..."]="Druk op Enter om door te gaan..."
|
["Press Enter to continue..."]="Druk op Enter om door te gaan..."
|
||||||
["Goodbye!"]="Tot ziens!"
|
["Goodbye!"]="Tot ziens!"
|
||||||
# ── HELP ──────────────────────────────────────────────
|
# ── HELP ──────────────────────────────────────────────
|
||||||
@@ -464,7 +467,10 @@ load_language() {
|
|||||||
["Cron Scheduler"]="Planificateur Cron"
|
["Cron Scheduler"]="Planificateur Cron"
|
||||||
["View Git Stashes"]="Voir les stashs Git"
|
["View Git Stashes"]="Voir les stashs Git"
|
||||||
["Exit"]="Quitter"
|
["Exit"]="Quitter"
|
||||||
["Select [0-20]"]="Sélectionner [0-20]"
|
["Flyaway Repair"]="Réparation Flyaway"
|
||||||
|
["Rebuild Frontend"]="Reconstruire le Frontend"
|
||||||
|
["Rebuild Emulator"]="Reconstruire l'Emulateur"
|
||||||
|
["Select [0-20]"]="Sélectionner [0-21]"
|
||||||
["Press Enter to continue..."]="Appuyez sur Entrée pour continuer..."
|
["Press Enter to continue..."]="Appuyez sur Entrée pour continuer..."
|
||||||
["Goodbye!"]="Au revoir !"
|
["Goodbye!"]="Au revoir !"
|
||||||
["Start update?"]="Lancer la mise à jour ?"
|
["Start update?"]="Lancer la mise à jour ?"
|
||||||
@@ -546,7 +552,10 @@ load_language() {
|
|||||||
["Cron Scheduler"]="Programador Cron"
|
["Cron Scheduler"]="Programador Cron"
|
||||||
["View Git Stashes"]="Ver Stashes Git"
|
["View Git Stashes"]="Ver Stashes Git"
|
||||||
["Exit"]="Salir"
|
["Exit"]="Salir"
|
||||||
["Select [0-20]"]="Seleccionar [0-20]"
|
["Flyaway Repair"]="Reparación Flyaway"
|
||||||
|
["Rebuild Frontend"]="Reconstruir Frontend"
|
||||||
|
["Rebuild Emulator"]="Reconstruir Emulador"
|
||||||
|
["Select [0-20]"]="Seleccionar [0-21]"
|
||||||
["Press Enter to continue..."]="Presione Enter para continuar..."
|
["Press Enter to continue..."]="Presione Enter para continuar..."
|
||||||
["Goodbye!"]="¡Hasta luego!"
|
["Goodbye!"]="¡Hasta luego!"
|
||||||
["Start update?"]="¿Iniciar actualización?"
|
["Start update?"]="¿Iniciar actualización?"
|
||||||
@@ -591,7 +600,10 @@ load_language() {
|
|||||||
["Cron Scheduler"]="Cron-Planer"
|
["Cron Scheduler"]="Cron-Planer"
|
||||||
["View Git Stashes"]="Git-Stashes anzeigen"
|
["View Git Stashes"]="Git-Stashes anzeigen"
|
||||||
["Exit"]="Beenden"
|
["Exit"]="Beenden"
|
||||||
["Select [0-20]"]="Auswählen [0-20]"
|
["Flyaway Repair"]="Flyaway-Reparatur"
|
||||||
|
["Rebuild Frontend"]="Frontend neu bauen"
|
||||||
|
["Rebuild Emulator"]="Emulator neu bauen"
|
||||||
|
["Select [0-20]"]="Auswählen [0-21]"
|
||||||
["Press Enter to continue..."]="Drücken Sie Enter zum Fortfahren..."
|
["Press Enter to continue..."]="Drücken Sie Enter zum Fortfahren..."
|
||||||
["Goodbye!"]="Auf Wiedersehen!"
|
["Goodbye!"]="Auf Wiedersehen!"
|
||||||
["Start update?"]="Update starten?"
|
["Start update?"]="Update starten?"
|
||||||
@@ -636,7 +648,10 @@ load_language() {
|
|||||||
["Cron Scheduler"]="Pianificatore Cron"
|
["Cron Scheduler"]="Pianificatore Cron"
|
||||||
["View Git Stashes"]="Vedi Stash Git"
|
["View Git Stashes"]="Vedi Stash Git"
|
||||||
["Exit"]="Esci"
|
["Exit"]="Esci"
|
||||||
["Select [0-20]"]="Seleziona [0-20]"
|
["Flyaway Repair"]="Riparazione Flyaway"
|
||||||
|
["Rebuild Frontend"]="Ricostruisci Frontend"
|
||||||
|
["Rebuild Emulator"]="Ricostruisci Emulatore"
|
||||||
|
["Select [0-20]"]="Seleziona [0-21]"
|
||||||
["Press Enter to continue..."]="Premi Invio per continuare..."
|
["Press Enter to continue..."]="Premi Invio per continuare..."
|
||||||
["Goodbye!"]="Arrivederci!"
|
["Goodbye!"]="Arrivederci!"
|
||||||
["Start update?"]="Avviare aggiornamento?"
|
["Start update?"]="Avviare aggiornamento?"
|
||||||
@@ -1546,6 +1561,121 @@ cmd_health() {
|
|||||||
box_bottom 50; echo ""
|
box_bottom 50; echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# FLYAWAY REPAIR
|
||||||
|
# =============================================================================
|
||||||
|
cmd_flyaway_repair() {
|
||||||
|
echo ""
|
||||||
|
acquire_lock
|
||||||
|
DRY_RUN=${DRY_RUN:-false}
|
||||||
|
info "Site: %s | Branch: %s | Mode: %s" "${NITRO_SITE_URL:-?}" "$NITRO_BRANCH" "flyaway-repair"
|
||||||
|
info "Log: %s" "$LOG_FILE"
|
||||||
|
if [ "$DRY_RUN" = true ]; then
|
||||||
|
info "Dry-run: would check repos, reinstall deps, fix permissions, sync configs, restart services"
|
||||||
|
show_summary
|
||||||
|
release_lock
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
step 1 6 "System Diagnostics"
|
||||||
|
preflight_check
|
||||||
|
|
||||||
|
step 2 6 "$(_t "Flyaway Repair")"
|
||||||
|
local repaired=0
|
||||||
|
|
||||||
|
for repo in "$EMULATOR_DIR/Emulator" "$NITRO_CLIENT" "$NITRO_RENDERER"; do
|
||||||
|
[ -d "$repo/.git" ] || continue
|
||||||
|
local name; name=$(basename "$repo")
|
||||||
|
info "Checking %s..." "$name"
|
||||||
|
|
||||||
|
# Reset any dirty/uncommitted changes that may cause issues
|
||||||
|
cd "$repo"
|
||||||
|
if ! git diff --quiet 2>/dev/null || ! git diff --cached --quiet 2>/dev/null; then
|
||||||
|
warn "Dirty working tree in %s — stashing changes" "$name"
|
||||||
|
git stash --include-untracked 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Reset to clean latest of the current branch
|
||||||
|
local branch; branch=$(git branch --show-current 2>/dev/null || echo "main")
|
||||||
|
if git checkout "$branch" 2>/dev/null; then
|
||||||
|
git checkout . 2>/dev/null || true
|
||||||
|
git clean -fd 2>/dev/null || true
|
||||||
|
ok "Cleaned %s working tree" "$name"
|
||||||
|
fi
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
|
|
||||||
|
# Reinstall dependencies if package.json exists
|
||||||
|
if [ -f "$repo/package.json" ]; then
|
||||||
|
spinner_start "Installing deps for %s..." "$name"
|
||||||
|
if yarn install --frozen-lockfile --prefer-offline 2>/dev/null; then
|
||||||
|
spinner_stop ok
|
||||||
|
ok "Deps reinstalled for %s" "$name"
|
||||||
|
else
|
||||||
|
spinner_stop fail
|
||||||
|
warn "yarn install failed for %s — cleaning node_modules and retrying" "$name"
|
||||||
|
rm -rf "$repo/node_modules" 2>/dev/null || true
|
||||||
|
yarn install --frozen-lockfile --prefer-offline 2>/dev/null || warn "yarn install still failed for %s" "$name"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
repaired=$((repaired + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
# Fix permissions
|
||||||
|
step 3 6 "$(_t "Set Permissions")"
|
||||||
|
for d in "$NITRO_CLIENT" "$NITRO_RENDERER" "$EMULATOR_DIR" "$GAMEDATA_CONF_DIR"; do
|
||||||
|
[ -d "$d" ] && sudo chown -R www-data:www-data "$d" 2>/dev/null || true
|
||||||
|
done
|
||||||
|
ok "Permissions fixed"
|
||||||
|
|
||||||
|
# Sync / validate configs
|
||||||
|
step 4 6 "$(_t "Sync Configurations")"
|
||||||
|
sync_configs
|
||||||
|
|
||||||
|
# Rebuild frontend if dist is missing or empty
|
||||||
|
if [ ! -d "$NITRO_CLIENT/dist" ] || [ -z "$(ls -A "$NITRO_CLIENT/dist" 2>/dev/null)" ]; then
|
||||||
|
step 5 6 "$(_t "Rebuild Frontend")"
|
||||||
|
spinner_start "$(_t "Building frontend...")"
|
||||||
|
cd "$NITRO_CLIENT"
|
||||||
|
if yarn build >> "$LOG_FILE" 2>&1; then
|
||||||
|
spinner_stop ok
|
||||||
|
ok "Frontend rebuilt"
|
||||||
|
else
|
||||||
|
spinner_stop fail
|
||||||
|
fail "Frontend rebuild failed"
|
||||||
|
fi
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
|
else
|
||||||
|
ok "Frontend dist intact — skip rebuild"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Rebuild emulator if jar is missing
|
||||||
|
if [ ! -d "$EMULATOR_DIR/Emulator/target" ] || ! ls "$EMULATOR_DIR/Emulator/target"/Polaris-*-jar-with-dependencies.jar &>/dev/null 2>&1; then
|
||||||
|
step 6 6 "$(_t "Rebuild Emulator")"
|
||||||
|
cd "$EMULATOR_DIR/Emulator"
|
||||||
|
backup_binaries
|
||||||
|
ROLLBACK_NEEDED=true
|
||||||
|
spinner_start "$(_t "Building emulator (parallel)...")"
|
||||||
|
command -v ccache >/dev/null 2>&1 && export CC="ccache gcc" CXX="ccache g++"
|
||||||
|
if mvn package -q -T 1C -Dmaven.test.skip=true >> "$LOG_FILE" 2>&1; then
|
||||||
|
spinner_stop ok
|
||||||
|
ok "Emulator rebuilt"
|
||||||
|
else
|
||||||
|
spinner_stop fail
|
||||||
|
fail "Emulator rebuild failed"
|
||||||
|
fi
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
|
else
|
||||||
|
ok "Emulator jar intact — skip rebuild"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Restart services
|
||||||
|
do_restart
|
||||||
|
|
||||||
|
show_summary
|
||||||
|
sudo chown -R www-data:www-data /var/www/Nitro-V3/
|
||||||
|
release_lock
|
||||||
|
}
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# SERVICES
|
# SERVICES
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
@@ -1843,10 +1973,11 @@ cmd_interactive() {
|
|||||||
echo -e " ${C_BLUE}${C_BOLD}17)${C_RESET} ${E_GLOBE} $(_t "Compare Branches")"
|
echo -e " ${C_BLUE}${C_BOLD}17)${C_RESET} ${E_GLOBE} $(_t "Compare Branches")"
|
||||||
echo -e " ${C_BLUE}${C_BOLD}18)${C_RESET} ${E_CLOCK} $(_t "Cron Scheduler")"
|
echo -e " ${C_BLUE}${C_BOLD}18)${C_RESET} ${E_CLOCK} $(_t "Cron Scheduler")"
|
||||||
echo -e " ${C_BLUE}${C_BOLD}20)${C_RESET} ${E_GIT} $(_t "View Git Stashes")"
|
echo -e " ${C_BLUE}${C_BOLD}20)${C_RESET} ${E_GIT} $(_t "View Git Stashes")"
|
||||||
|
echo -e " ${C_RED}${C_BOLD}21)${C_RESET} ${E_WRENCH} $(_t "Flyaway Repair")"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " ${C_RED}${C_BOLD}0)${C_RESET} $(_t "Exit")"
|
echo -e " ${C_RED}${C_BOLD}0)${C_RESET} $(_t "Exit")"
|
||||||
echo ""
|
echo ""
|
||||||
echo -en " ${C_CYAN}${C_BOLD}$(_t "Select [0-20]")${C_RESET}: "
|
echo -en " ${C_CYAN}${C_BOLD}$(_t "Select [0-21]")${C_RESET}: "
|
||||||
local choice; read -rt 30 choice
|
local choice; read -rt 30 choice
|
||||||
|
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
@@ -1884,6 +2015,7 @@ cmd_interactive() {
|
|||||||
18) (cmd_schedule) ;;
|
18) (cmd_schedule) ;;
|
||||||
19) SELECTIVE_UPDATE="dev"; (pick_branch_and_update) || warn "Dev mode had errors" ;;
|
19) SELECTIVE_UPDATE="dev"; (pick_branch_and_update) || warn "Dev mode had errors" ;;
|
||||||
20) (cmd_stash) ;;
|
20) (cmd_stash) ;;
|
||||||
|
21) (cmd_flyaway_repair) ;;
|
||||||
0|q|Q) echo -e "\n ${C_GREEN}$(_t "Goodbye!")${C_RESET}"; cursor_show; exit 0 ;;
|
0|q|Q) echo -e "\n ${C_GREEN}$(_t "Goodbye!")${C_RESET}"; cursor_show; exit 0 ;;
|
||||||
*) warn "Invalid selection" ;;
|
*) warn "Invalid selection" ;;
|
||||||
esac
|
esac
|
||||||
@@ -1921,6 +2053,7 @@ show_help() {
|
|||||||
echo -e " ${C_GREEN}compare${C_RESET} $(_t "Branch diff")"
|
echo -e " ${C_GREEN}compare${C_RESET} $(_t "Branch diff")"
|
||||||
echo -e " ${C_GREEN}schedule${C_RESET} $(_t "Cron setup")"
|
echo -e " ${C_GREEN}schedule${C_RESET} $(_t "Cron setup")"
|
||||||
echo -e " ${C_GREEN}stash${C_RESET} $(_t "View git stashes")"
|
echo -e " ${C_GREEN}stash${C_RESET} $(_t "View git stashes")"
|
||||||
|
echo -e " ${C_GREEN}repair${C_RESET} $(_t "Flyaway Repair")"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " ${C_BOLD}$(_t "OPTIONS:")${C_RESET}"
|
echo -e " ${C_BOLD}$(_t "OPTIONS:")${C_RESET}"
|
||||||
echo -e " ${C_CYAN}--branch, -b${C_RESET} $(_t "Branch (auto-detects)")"
|
echo -e " ${C_CYAN}--branch, -b${C_RESET} $(_t "Branch (auto-detects)")"
|
||||||
@@ -1956,6 +2089,7 @@ main() {
|
|||||||
logs|log) cmd="logs" ;;
|
logs|log) cmd="logs" ;;
|
||||||
clean|cl) cmd="clean" ;;
|
clean|cl) cmd="clean" ;;
|
||||||
stash|stashes) cmd="stash" ;;
|
stash|stashes) cmd="stash" ;;
|
||||||
|
repair|flyaway) cmd="repair" ;;
|
||||||
help|-h|--help) cmd="help" ;;
|
help|-h|--help) cmd="help" ;;
|
||||||
version|-V|--version) echo "v${SCRIPT_VERSION} (build ${SCRIPT_BUILD})"; exit 0 ;;
|
version|-V|--version) echo "v${SCRIPT_VERSION} (build ${SCRIPT_BUILD})"; exit 0 ;;
|
||||||
--branch|-b) shift; NITRO_BRANCH="$1" ;;
|
--branch|-b) shift; NITRO_BRANCH="$1" ;;
|
||||||
@@ -2021,7 +2155,8 @@ main() {
|
|||||||
gitlog) cmd_gitlog ;;
|
gitlog) cmd_gitlog ;;
|
||||||
compare) cmd_compare ;;
|
compare) cmd_compare ;;
|
||||||
schedule) cmd_schedule ;;
|
schedule) cmd_schedule ;;
|
||||||
stash) cmd_stash ;;
|
stash) cmd_stash ;;
|
||||||
|
repair) cmd_flyaway_repair ;;
|
||||||
help) show_help ;;
|
help) show_help ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user