Skip to content

Commit 04b4337

Browse files
committed
Update | 'menu.sh' V2.1
1 parent 7dd14b6 commit 04b4337

File tree

1 file changed

+79
-100
lines changed

1 file changed

+79
-100
lines changed

menu.sh

Lines changed: 79 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env bash
22
# ==============================================================================
3-
# menu.sh — TUI façon raspi-config (whiptail/dialog) avec fallback menu texte
3+
# menu.sh — TUI whiptail/dialog avec fallback Bash (ASCII style OverStyleFR)
44
#
55
# USAGE :
66
# bash <(curl -fsSL https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main/menu.sh)
77
# bash <(curl -fsSL https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main/menu.sh) --bash
88
#
99
# OPTIONS :
10-
# --bash Force le menu texte (désactive whiptail/dialog même s'ils sont présents)
10+
# --bash Force le menu Bash (ASCII), même si whiptail/dialog sont présents
1111
# ==============================================================================
1212

1313
set -uo pipefail
@@ -20,9 +20,18 @@ for arg in "$@"; do
2020
esac
2121
done
2222

23+
# ------------------------------- Couleurs -------------------------------------
24+
if command -v tput >/dev/null 2>&1 && [[ -t 1 ]]; then
25+
GREEN="$(tput setaf 2)"; RED="$(tput setaf 1)"; BLUE="$(tput setaf 4)"
26+
VIOLET="$(tput setaf 5)"; YELLOW="$(tput setaf 3)"
27+
BOLD="$(tput bold)"; RESET="$(tput sgr0)"
28+
else
29+
GREEN=""; RED=""; BLUE=""; VIOLET=""; YELLOW=""; BOLD=""; RESET=""
30+
fi
31+
2332
# ------------------------------ Vérif root ------------------------------------
2433
if [[ ${EUID:-$UID} -ne 0 ]]; then
25-
echo "Ce script doit être exécuté en root."
34+
echo -e "${RED}${BOLD}Ce script doit être exécuté en tant que root.${RESET}"
2635
exec sudo -E bash "$0" "$@"
2736
fi
2837

@@ -36,17 +45,6 @@ PANEL_REINSTALL_URL="https://raw.githubusercontent.com/OverStyleFR/AutoScriptBas
3645
PTERO_MENU_URL="https://raw.githubusercontent.com/OverStyleFR/Pterodactyl-Installer-Menu/main/PterodactylMenu.sh"
3746
SSH_MENU_URL="https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main/menu_id.sh"
3847

39-
# ------------------------------ Backend UI ------------------------------------
40-
DIALOG_BIN=""
41-
if [[ $FORCE_BASH -eq 0 ]]; then
42-
if command -v whiptail >/dev/null 2>&1; then
43-
DIALOG_BIN="whiptail"
44-
elif command -v dialog >/dev/null 2>&1; then
45-
DIALOG_BIN="dialog"
46-
fi
47-
fi
48-
# Si DIALOG_BIN vide -> on utilisera le menu texte
49-
5048
# ------------------------------ Options new.sh --------------------------------
5149
NEW_F_DEBUG=0
5250
NEW_F_DRYRUN=0
@@ -87,18 +85,32 @@ download_to_tmp() {
8785
run_remote() {
8886
local url="$1" label="${2:-script}"; shift 2 || true
8987
local args=( "$@" ) tmp rc
90-
tmp="$(download_to_tmp "$url" "$label")" || { echo "Échec de téléchargement de ${label}."; return 90; }
91-
clear; echo "=== Exécution de ${label} ==="
88+
echo -e "${YELLOW}${BOLD}Téléchargement de ${label}${RESET}"
89+
if ! tmp="$(download_to_tmp "$url" "$label")"; then
90+
echo -e "${RED}${BOLD}Échec de téléchargement.${RESET}"; return 90
91+
fi
92+
echo -e "${YELLOW}${BOLD}Exécution de ${label}${RESET}"
9293
bash "$tmp" "${args[@]}"; rc=$?
9394
rm -f "$tmp" 2>/dev/null || true
94-
if [[ $rc -ne 0 ]]; then
95-
local hint; hint="$(ls -1 /var/log/new-basics-*.log 2>/dev/null | tail -n 1)"
96-
[[ -n "$hint" ]] && echo "Dernier log : $hint"
95+
if [[ $rc -eq 0 ]]; then
96+
echo -e "${GREEN}${BOLD}${label} terminé avec succès${RESET}"
97+
else
98+
echo -e "${RED}${BOLD}${label} a échoué (rc=$rc)${RESET}"
99+
ls -1 /var/log/new-basics-*.log 2>/dev/null | tail -n 1 | sed "s/^/Dernier log : /"
97100
fi
98101
return $rc
99102
}
100103

101104
# =============================== UI: WHIPTAIL/DIALOG ==========================
105+
DIALOG_BIN=""
106+
if [[ $FORCE_BASH -eq 0 ]]; then
107+
if command -v whiptail >/dev/null 2>&1; then
108+
DIALOG_BIN="whiptail"
109+
elif command -v dialog >/dev/null 2>&1; then
110+
DIALOG_BIN="dialog"
111+
fi
112+
fi
113+
102114
ui_menu() {
103115
local title="$1" prompt="$2" h="$3" w="$4" mh="$5"; shift 5
104116
local status out
@@ -230,87 +242,54 @@ main_menu_ui() {
230242
done
231243
}
232244

233-
# =============================== UI: MENU TEXTE ===============================
234-
pause() { read -rp $'\n(Entrée pour continuer) ' _; }
235-
adv_menu_text() {
236-
echo; echo "=== Options avancées (new.sh) ==="
237-
echo "Actuelles : $(flags_inline_if_any)"
238-
read -rp "Activer --debug ? (y/N) " r; [[ "$r" =~ ^[Yy]$ ]] && NEW_F_DEBUG=1 || NEW_F_DEBUG=0
239-
read -rp "Activer --dry-run ? (y/N) " r; [[ "$r" =~ ^[Yy]$ ]] && NEW_F_DRYRUN=1 || NEW_F_DRYRUN=0
240-
read -rp "Activer --quiet ? (y/N) " r; [[ "$r" =~ ^[Yy]$ ]] && NEW_F_QUIET=1 || NEW_F_QUIET=0
241-
read -rp "Autres arguments (ligne unique) : " NEW_EXTRA_ARGS
242-
echo "Mis à jour : $(flags_inline_if_any)"; pause
243-
}
244-
submenu_installation_text() {
245-
while true; do
246-
clear; cat <<'TXT'
247-
=== Installation ===
248-
1) Installer docker
249-
2) Installer yarn
250-
r) Retour
251-
TXT
252-
read -rp "Choix : " c
253-
case "$c" in
254-
1) run_remote "$DOCKER_URL" "dockerinstall.sh" ; pause ;;
255-
2) run_remote "$YARN_URL" "yarninstall.sh" ; pause ;;
256-
r|R) return 0 ;;
257-
esac
258-
done
259-
}
260-
submenu_scripts_text() {
261-
while true; do
262-
clear; echo "=== Scripts ==="
263-
echo "Flags new.sh : $(flags_inline_if_any)"
264-
cat <<'TXT'
265-
1) Exécuter 'new.sh'
266-
2) Exécuter 'speedtest.sh'
267-
3) Exécuter 'fastfetch-install.sh'
268-
4) Exécuter 'pterodactyl-panel-reinstaller'
269-
r) Retour
270-
TXT
271-
read -rp "Choix : " c
272-
case "$c" in
273-
1) build_new_flags; run_remote "$NEW_URL" "new.sh" "${NEW_FLAGS[@]}"; pause ;;
274-
2) run_remote "$SPEED_URL" "speedtest.sh" ; pause ;;
275-
3) run_remote "$FASTFETCH_URL" "fastfetch-install.sh" ; pause ;;
276-
4) run_remote "$PANEL_REINSTALL_URL" "pterodactylpanelreinstall.sh"; pause ;;
277-
r|R) return 0 ;;
278-
esac
279-
done
280-
}
281-
submenu_autres_text() {
282-
while true; do
283-
clear; cat <<'TXT'
284-
=== Autres menus ===
285-
1) Pterodactyl Menu
286-
2) Menu SSH
287-
r) Retour
288-
TXT
289-
read -rp "Choix : " c
290-
case "$c" in
291-
1) run_remote "$PTERO_MENU_URL" "PterodactylMenu.sh" ; pause ;;
292-
2) run_remote "$SSH_MENU_URL" "menu_id.sh" ; pause ;;
293-
r|R) return 0 ;;
294-
esac
295-
done
245+
# =============================== UI: MENU BASH (ASCII) ========================
246+
pause() { read -n 1 -s -r -p "Appuyez sur une touche pour retourner au menu..." ; echo; }
247+
248+
draw_ascii_menu() {
249+
clear
250+
echo " +------------+"
251+
echo " | ${BOLD}${VIOLET}M${GREEN}e${YELLOW}n${BLUE}u${RESET}${BOLD} :${RESET} |"
252+
echo " +--------+------------+----------+"
253+
echo " | ${VIOLET}${BOLD}Installation${RESET}${BOLD} :${RESET} |"
254+
echo "+------+--------------------------------+------+"
255+
echo "| 1. Installer docker |"
256+
echo "| 2. Installer yarn |"
257+
echo "+----------------------------------------------+"
258+
echo ""
259+
echo " +-------------+"
260+
echo " | ${GREEN}${BOLD}Script${RESET}${BOLD} :${RESET} |"
261+
echo " +-------------+-------------+----------------+"
262+
echo " | 3. Exécuter 'new.sh' |"
263+
echo " | 4. Exécuter 'speedtest.sh' |"
264+
echo " | 5. Exécuter 'fastfetch-install.sh' |"
265+
echo " | 6. Exécuter 'pterodactyl-panel-reinstaller'|"
266+
echo " +--------------------------------------------+"
267+
echo " | 7. ${BLUE}${BOLD}Exécuter le Pterodactyl Menu${RESET} |"
268+
echo " | └ ${YELLOW}${BOLD}OverStyleFR/Pterodactyl-Installer-Menu${RESET} |"
269+
echo " +--------------------------------------------+"
270+
echo " | 8. ${BOLD}${VIOLET}Menu SSH ${RESET} |"
271+
echo " | └ ${VIOLET}${BOLD}OverStyleFR/AutoScriptBash${RESET} |"
272+
echo " +-------------+------------+-----------------+"
273+
echo " | ${RED}${BOLD}9. Quitter${RESET} |"
274+
echo " +------------+"
275+
echo
296276
}
297-
main_menu_text() {
277+
278+
main_menu_ascii() {
298279
while true; do
299-
clear; cat <<'TXT'
300-
=========== MENU ===========
301-
1) Installation
302-
2) Scripts
303-
3) Autres menus
304-
4) Options avancées (new.sh)
305-
q) Quitter
306-
TXT
307-
read -rp "Choix : " c
308-
case "$c" in
309-
1) submenu_installation_text ;;
310-
2) submenu_scripts_text ;;
311-
3) submenu_autres_text ;;
312-
4) adv_menu_text ;;
313-
q|Q) exit 0 ;;
280+
draw_ascii_menu
281+
read -rp "Choisissez une option (1-9) : " choix
282+
case "${choix:-}" in
283+
1) echo "Installation de Docker." ; run_remote "$DOCKER_URL" "dockerinstall.sh" ; pause ;;
284+
2) echo "Installation de Yarn." ; run_remote "$YARN_URL" "yarninstall.sh" ; pause ;;
285+
3) echo "Exécution du script 'new.sh'." ; build_new_flags; run_remote "$NEW_URL" "new.sh" "${NEW_FLAGS[@]}"; pause ;;
286+
4) echo "Exécution du script 'speedtest.sh'." ; run_remote "$SPEED_URL" "speedtest.sh" ; pause ;;
287+
5) echo "Exécution du script 'fastfetch-install.sh'." ; run_remote "$FASTFETCH_URL" "fastfetch-install.sh" ; pause ;;
288+
6) echo "Exécution du script 'pterodactyl-panel-reinstaller'." ; run_remote "$PANEL_REINSTALL_URL" "pterodactylpanelreinstall.sh" ; pause ;;
289+
7) echo -e "${BLUE}${BOLD}Exécuter le Pterodactyl Menu${RESET}" ; run_remote "$PTERO_MENU_URL" "PterodactylMenu.sh" ; pause ;;
290+
8) echo -e "${BOLD}${VIOLET}Menu SSH${RESET}" ; run_remote "$SSH_MENU_URL" "menu_id.sh" ; pause ;;
291+
9) echo "Au revoir !" ; exit 0 ;;
292+
*) echo -e "${RED}Choix non valide. Veuillez entrer un numéro entre 1 et 9.${RESET}"; sleep 1 ;;
314293
esac
315294
done
316295
}
@@ -319,6 +298,6 @@ TXT
319298
if [[ -n "$DIALOG_BIN" ]]; then
320299
main_menu_ui
321300
else
322-
echo "(UI texte : whiptail/dialog indisponibles ou --bash forcé)"
323-
main_menu_text
301+
echo "(UI Bash : whiptail/dialog indisponibles ou --bash forcé)"
302+
main_menu_ascii
324303
fi

0 commit comments

Comments
 (0)