Skip to content

Commit 59aa289

Browse files
committed
Add | Oublié de add menu.sh
1 parent dcde699 commit 59aa289

File tree

1 file changed

+173
-110
lines changed

1 file changed

+173
-110
lines changed

menu.sh

Lines changed: 173 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,178 @@
1-
#!/bin/bash
2-
# Définir les couleurs
3-
GREEN=$(tput setaf 2)
4-
RED=$(tput setaf 1)
5-
BLUE=$(tput setaf 4)
6-
VIOLET=$(tput setaf 5)
7-
YELLOW=$(tput setaf 3)
8-
BOLD=$(tput bold)
9-
RESET=$(tput sgr0)
1+
#!/usr/bin/env bash
2+
# ==============================================================================
3+
# menu.sh — Lanceur interactif des scripts OverStyleFR
4+
#
5+
# USAGE :
6+
# sudo ./menu.sh
7+
#
8+
# CARACTÉRISTIQUES :
9+
# - Menu en boucle (1..9)
10+
# - Vérifie root, relance via sudo si nécessaire
11+
# - Couleurs avec fallback si tput indisponible
12+
# - Télécharge chaque script dans /tmp avec mktemp, exécute, affiche le statut
13+
# - Nettoyage auto des fichiers temporaires
14+
# ==============================================================================
1015

11-
########################################## INITIALISATION ROOT ##########################################
12-
# Vérifier si l'utilisateur est root
13-
if [[ $EUID -ne 0 ]]; then
14-
echo "${RED}${BOLD}Ce script doit être exécuté en tant que root${RESET}"
15-
# Demander le mot de passe
16-
sudo "$0" "$@"
17-
exit 1
16+
# Pas de "set -e" pour ne pas quitter le menu sur une simple erreur de sous-commande
17+
set -uo pipefail
18+
19+
# ------------------------------- Couleurs -------------------------------------
20+
if command -v tput >/dev/null 2>&1 && [[ -t 1 ]]; then
21+
GREEN="$(tput setaf 2)"; RED="$(tput setaf 1)"; BLUE="$(tput setaf 4)"
22+
VIOLET="$(tput setaf 5)"; YELLOW="$(tput setaf 3)"
23+
BOLD="$(tput bold)"; RESET="$(tput sgr0)"
24+
else
25+
GREEN=""; RED=""; BLUE=""; VIOLET=""; YELLOW=""; BOLD=""; RESET=""
26+
fi
27+
28+
# ------------------------------ Vérif root ------------------------------------
29+
if [[ ${EUID:-$UID} -ne 0 ]]; then
30+
echo -e "${RED}${BOLD}Ce script doit être exécuté en tant que root.${RESET}"
31+
exec sudo -E bash "$0" "$@"
1832
fi
1933

20-
# Le reste du script ici
21-
clear
34+
# ----------------------------- URLs des scripts --------------------------------
35+
DOCKER_URL="https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main/.assets/dockerinstall.sh"
36+
YARN_URL="https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main/.assets/yarninstall.sh"
37+
NEW_URL="https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/refs/heads/fix/script-new-interactive-mode/.assets/new.sh"
38+
SPEED_URL="https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main/.assets/speedtest.sh"
39+
FASTFETCH_URL="https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main/.assets/fastfetch-install.sh"
40+
PANEL_REINSTALL_URL="https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main/.assets/pterodactylpanelreinstall.sh"
41+
PTERO_MENU_URL="https://raw.githubusercontent.com/OverStyleFR/Pterodactyl-Installer-Menu/main/PterodactylMenu.sh"
42+
SSH_MENU_URL="https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main/menu_id.sh"
43+
44+
# ------------------------------- Helpers --------------------------------------
45+
pause() { read -n 1 -s -r -p "Appuyez sur une touche pour retourner au menu..." ; echo; }
46+
47+
download_to_tmp() {
48+
# $1=url $2=prefix (nom lisible)
49+
local url="$1" prefix="${2:-script}"
50+
local tmp
51+
tmp="$(mktemp -p /tmp "${prefix}.XXXXXX")" || { echo -e "${RED}${BOLD}mktemp a échoué${RESET}"; return 98; }
52+
53+
# Nettoyage automatique à la sortie de la fonction:
54+
trap 'rm -f "$tmp" 2>/dev/null || true' RETURN
55+
56+
if command -v curl >/dev/null 2>&1; then
57+
if ! curl -fsSL --retry 3 --retry-delay 1 "$url" -o "$tmp"; then
58+
echo -e "${RED}${BOLD}Téléchargement échoué (curl)${RESET}"; return 90
59+
fi
60+
elif command -v wget >/dev/null 2>&1; then
61+
if ! wget -q "$url" -O "$tmp"; then
62+
echo -e "${RED}${BOLD}Téléchargement échoué (wget)${RESET}"; return 90
63+
fi
64+
else
65+
echo -e "${RED}${BOLD}Ni curl ni wget disponible pour télécharger${RESET}"; return 91
66+
fi
67+
68+
chmod +x "$tmp"
69+
echo "$tmp" # retourne le chemin
70+
}
71+
72+
run_remote() {
73+
# $1=url $2=nom_affiché
74+
local url="$1" label="${2:-script}"
75+
echo -e "${YELLOW}${BOLD}Téléchargement de ${label}${RESET}"
76+
local tmp rc
77+
if ! tmp="$(download_to_tmp "$url" "$label")"; then
78+
echo -e "${RED}${BOLD}Échec de préparation pour ${label}${RESET}"
79+
return 90
80+
fi
81+
echo -e "${YELLOW}${BOLD}Exécution de ${label}${RESET}"
82+
bash "$tmp"; rc=$?
83+
if [[ $rc -eq 0 ]]; then
84+
echo -e "${GREEN}${BOLD}${label} terminé avec succès${RESET}"
85+
else
86+
echo -e "${RED}${BOLD}${label} a échoué (rc=${rc})${RESET}"
87+
# indice utile pour new.sh
88+
ls -1 /var/log/new-basics-*.log 2>/dev/null | tail -n 1 | sed "s/^/Dernier log: /"
89+
fi
90+
return $rc
91+
}
92+
93+
draw_menu() {
94+
clear
95+
echo " +------------+"
96+
echo " | ${BOLD}${VIOLET}M${GREEN}e${YELLOW}n${BLUE}u${RESET}${BOLD} :${RESET} |"
97+
echo " +--------+------------+----------+"
98+
echo " | ${VIOLET}${BOLD}Installation${RESET}${BOLD} :${RESET} |"
99+
echo "+------+--------------------------------+------+"
100+
echo "| 1. Installer docker |"
101+
echo "| 2. Installer yarn |"
102+
echo "+----------------------------------------------+"
103+
echo ""
104+
echo " +-------------+"
105+
echo " | ${GREEN}${BOLD}Script${RESET}${BOLD} :${RESET} |"
106+
echo " +-------------+-------------+----------------+"
107+
echo " | 3. Exécuter 'new.sh' |"
108+
echo " | |"
109+
echo " | 4. Exécuter 'speedtest.sh' |"
110+
echo " | |"
111+
echo " | 5. Exécuter 'fastfetch.sh' |"
112+
echo " | |"
113+
echo " | 6. Exécuter 'pterodactyl-panel-reinstaller'|"
114+
echo " +--------------------------------------------+"
115+
echo " | 7. ${BLUE}${BOLD}Exécuter le Pterodactyl Menu${RESET} |"
116+
echo " | └ ${YELLOW}${BOLD}OverStyleFR/Pterodactyl-Installer-Menu${RESET} |"
117+
echo " +--------------------------------------------+"
118+
echo " | 8. ${BOLD}${VIOLET}M${GREEN}e${YELLOW}n${BLUE}u${RESET}${BOLD} SSH ${RESET} |"
119+
echo " | └ ${VIOLET}${BOLD}OverStyleFR/AutoScriptBash${RESET} |"
120+
echo " +-------------+------------+-----------------+"
121+
echo " | ${RED}${BOLD}9. Quitter${RESET} |"
122+
echo " +------------+"
123+
echo
124+
}
125+
126+
# --------------------------------- Boucle -------------------------------------
22127
while true; do
23-
# Affichage du menu
24-
echo " +------------+"
25-
echo " | ${BOLD}${VIOLET}M${GREEN}e${YELLOW}n${BLUE}u${RESET}${BOLD} :${RESET} |"
26-
echo " +--------+------------+----------+"
27-
echo " | ${VIOLET}${BOLD}Installation${RESET}${BOLD} :${RESET} |"
28-
echo "+------+--------------------------------+------+"
29-
echo "| 1. Installer docker |"
30-
echo "| 2. Installer yarn |"
31-
echo "+----------------------------------------------+"
32-
echo ""
33-
echo " +-------------+"
34-
echo " | ${GREEN}${BOLD}Script${RESET}${BOLD} :${RESET} |"
35-
echo " +-------------+-------------+----------------+"
36-
echo " | 3. Exécuter 'new.sh' |"
37-
echo " | |"
38-
echo " | 4. Exécuter 'speedtest.sh' |"
39-
echo " | |"
40-
echo " | 5. Exécuter 'fastfetch.sh' |"
41-
echo " | |"
42-
echo " | 6. Exécuter 'pterodactyl-panel-reinstaller'|"
43-
echo " +--------------------------------------------+"
44-
echo " | 7. ${BLUE}${BOLD}Exécuter le Pterodactyl Menu${RESET} |"
45-
echo " | └ ${YELLOW}${BOLD}OverStyleFR/Pterodactyl-Installer-Menu${RESET} |"
46-
echo " +--------------------------------------------+"
47-
echo " | 8. ${BOLD}${VIOLET}M${GREEN}e${YELLOW}n${BLUE}u${RESET}${BOLD} SSH ${RESET} |"
48-
echo " | └ ${VIOLET}${BOLD}OverStyleFR/AutoScriptBash${RESET} |"
49-
echo " +-------------+------------+-----------------+"
50-
echo " | ${RED}${BOLD}9. Quitter${RESET} |"
51-
echo " +------------+"
52-
53-
# Lecture du choix de l'utilisateur
54-
read -p "Choisissez une option (1-9) : " choix
55-
56-
# Traitement du choix
57-
case $choix in
58-
1)
59-
echo "Installation de Docker."
60-
bash <(curl -s https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main/.assets/dockerinstall.sh)
61-
;;
62-
2)
63-
echo "Installation de Yarn."
64-
bash <(curl -s https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main/.assets/yarninstall.sh)
65-
;;
66-
3)
67-
echo "Exécution du script 'new.sh'."
68-
# Télécharge et exécute le script new.sh depuis /tmp
69-
tmp_file="/tmp/new.sh"
70-
curl -s https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/refs/heads/fix/script-new-interactive-mode/.assets/new.sh -o "$tmp_file" && chmod +x "$tmp_file"
71-
bash "$tmp_file" && rm -f "$tmp_file" # Exécution et suppression du script
72-
read -n 1 -s -r -p "Appuyez sur une touche pour retourner au menu..."
73-
;;
74-
4)
75-
echo "Exécution du script 'speedtest.sh'."
76-
tmp_file="/tmp/speedtest.sh"
77-
curl -s https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main/.assets/speedtest.sh -o "$tmp_file" && chmod +x "$tmp_file"
78-
bash "$tmp_file" && rm -f "$tmp_file"
79-
read -n 1 -s -r -p "Appuyez sur une touche pour retourner au menu..."
80-
;;
81-
5)
82-
echo "Exécution du script 'fastfetch.sh'."
83-
tmp_file="/tmp/fastfetch.sh"
84-
curl -s https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/refs/heads/main/.assets/fastfetch-install.sh -o "$tmp_file" && chmod +x "$tmp_file"
85-
bash "$tmp_file" && rm -f "$tmp_file"
86-
read -n 1 -s -r -p "Appuyez sur une touche pour retourner au menu..."
87-
;;
88-
6)
89-
echo "Exécution du script 'pterodactyl-panel-reinstaller'"
90-
tmp_file="/tmp/pterodactylpanelreinstall.sh"
91-
curl -s https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main/.assets/pterodactylpanelreinstall.sh -o "$tmp_file" && chmod +x "$tmp_file"
92-
bash "$tmp_file" && rm -f "$tmp_file"
93-
read -n 1 -s -r -p "Appuyez sur une touche pour retourner au menu..."
94-
;;
95-
7)
96-
echo "${BLUE}${BOLD}Exécuter le Pterodactyl Menu${RESET}"
97-
tmp_file="/tmp/PterodactylMenu.sh"
98-
curl -s https://raw.githubusercontent.com/OverStyleFR/Pterodactyl-Installer-Menu/main/PterodactylMenu.sh -o "$tmp_file" && chmod +x "$tmp_file"
99-
bash "$tmp_file" && rm -f "$tmp_file"
100-
;;
101-
8)
102-
echo "${BOLD}${VIOLET}M${GREEN}e${YELLOW}n${BLUE}u${RESET}${BOLD} SSH ${RESET}"
103-
tmp_file="/tmp/menu_id.sh"
104-
curl -s https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main/menu_id.sh -o "$tmp_file" && chmod +x "$tmp_file"
105-
bash "$tmp_file" && rm -f "$tmp_file"
106-
;;
107-
9)
108-
echo "Au revoir !"
109-
exit 0
110-
;;
111-
*)
112-
echo "Choix non valide. Veuillez entrer un numéro entre 1 et 9."
113-
;;
114-
esac
128+
draw_menu
129+
read -rp "Choisissez une option (1-9) : " choix
130+
case "${choix:-}" in
131+
1)
132+
echo "Installation de Docker."
133+
run_remote "$DOCKER_URL" "dockerinstall.sh"
134+
pause
135+
;;
136+
2)
137+
echo "Installation de Yarn."
138+
run_remote "$YARN_URL" "yarninstall.sh"
139+
pause
140+
;;
141+
3)
142+
echo "Exécution du script 'new.sh'."
143+
run_remote "$NEW_URL" "new.sh"
144+
pause
145+
;;
146+
4)
147+
echo "Exécution du script 'speedtest.sh'."
148+
run_remote "$SPEED_URL" "speedtest.sh"
149+
pause
150+
;;
151+
5)
152+
echo "Exécution du script 'fastfetch-install.sh'."
153+
run_remote "$FASTFETCH_URL" "fastfetch-install.sh"
154+
pause
155+
;;
156+
6)
157+
echo "Exécution du script 'pterodactyl-panel-reinstaller'."
158+
run_remote "$PANEL_REINSTALL_URL" "pterodactylpanelreinstall.sh"
159+
pause
160+
;;
161+
7)
162+
echo -e "${BLUE}${BOLD}Exécuter le Pterodactyl Menu${RESET}"
163+
run_remote "$PTERO_MENU_URL" "PterodactylMenu.sh"
164+
pause
165+
;;
166+
8)
167+
echo -e "${BOLD}${VIOLET}Menu SSH${RESET}"
168+
run_remote "$SSH_MENU_URL" "menu_id.sh"
169+
pause
170+
;;
171+
9)
172+
echo "Au revoir !"; exit 0 ;;
173+
*)
174+
echo -e "${RED}Choix non valide. Veuillez entrer un numéro entre 1 et 9.${RESET}"
175+
sleep 1
176+
;;
177+
esac
115178
done

0 commit comments

Comments
 (0)