Skip to content

Commit 0f7bd74

Browse files
committed
Fix | Delete file before execute
J’avais mis un trap RETURN dans download_to_tmp, donc le fichier temporaire était supprimé dès le retour de la fonction, avant son exécution
1 parent 59aa289 commit 0f7bd74

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

menu.sh

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env bash
22
# ==============================================================================
3-
# menu.sh Lanceur interactif des scripts OverStyleFR
3+
# menu.sh â Lanceur interactif des scripts OverStyleFR
44
#
55
# USAGE :
66
# sudo ./menu.sh
77
#
8-
# CARACTÉRISTIQUES :
8+
# CARACTÃRISTIQUES :
99
# - Menu en boucle (1..9)
10-
# - Vérifie root, relance via sudo si nécessaire
10+
# - Vérifie root, relance via sudo si nécessaire
1111
# - Couleurs avec fallback si tput indisponible
12-
# - Télécharge chaque script dans /tmp avec mktemp, exécute, affiche le statut
12+
# - Télécharge chaque script dans /tmp avec mktemp, exécute, affiche le statut
1313
# - Nettoyage auto des fichiers temporaires
1414
# ==============================================================================
1515

@@ -25,9 +25,9 @@ else
2525
GREEN=""; RED=""; BLUE=""; VIOLET=""; YELLOW=""; BOLD=""; RESET=""
2626
fi
2727

28-
# ------------------------------ Vérif root ------------------------------------
28+
# ------------------------------ Vérif root ------------------------------------
2929
if [[ ${EUID:-$UID} -ne 0 ]]; then
30-
echo -e "${RED}${BOLD}Ce script doit être exécuté en tant que root.${RESET}"
30+
echo -e "${RED}${BOLD}Ce script doit être exécuté en tant que root.${RESET}"
3131
exec sudo -E bash "$0" "$@"
3232
fi
3333

@@ -48,42 +48,42 @@ download_to_tmp() {
4848
# $1=url $2=prefix (nom lisible)
4949
local url="$1" prefix="${2:-script}"
5050
local tmp
51-
tmp="$(mktemp -p /tmp "${prefix}.XXXXXX")" || { echo -e "${RED}${BOLD}mktemp a échoué${RESET}"; return 98; }
51+
tmp="$(mktemp -p /tmp "${prefix}.XXXXXX")" || { echo -e "${RED}${BOLD}mktemp a échoué${RESET}"; return 98; }
5252

53-
# Nettoyage automatique à la sortie de la fonction:
53+
# Nettoyage automatique à la sortie de la fonction:
5454
trap 'rm -f "$tmp" 2>/dev/null || true' RETURN
5555

5656
if command -v curl >/dev/null 2>&1; then
5757
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
58+
echo -e "${RED}${BOLD}Téléchargement échoué (curl)${RESET}"; return 90
5959
fi
6060
elif command -v wget >/dev/null 2>&1; then
6161
if ! wget -q "$url" -O "$tmp"; then
62-
echo -e "${RED}${BOLD}Téléchargement échoué (wget)${RESET}"; return 90
62+
echo -e "${RED}${BOLD}Téléchargement échoué (wget)${RESET}"; return 90
6363
fi
6464
else
65-
echo -e "${RED}${BOLD}Ni curl ni wget disponible pour télécharger${RESET}"; return 91
65+
echo -e "${RED}${BOLD}Ni curl ni wget disponible pour télécharger${RESET}"; return 91
6666
fi
6767

6868
chmod +x "$tmp"
6969
echo "$tmp" # retourne le chemin
7070
}
7171

7272
run_remote() {
73-
# $1=url $2=nom_affiché
73+
# $1=url $2=nom_affiché
7474
local url="$1" label="${2:-script}"
75-
echo -e "${YELLOW}${BOLD}Téléchargement de ${label}${RESET}"
75+
echo -e "${YELLOW}${BOLD}Téléchargement de ${label}â¦${RESET}"
7676
local tmp rc
7777
if ! tmp="$(download_to_tmp "$url" "$label")"; then
78-
echo -e "${RED}${BOLD}Échec de préparation pour ${label}${RESET}"
78+
echo -e "${RED}${BOLD}Ãchec de préparation pour ${label}${RESET}"
7979
return 90
8080
fi
81-
echo -e "${YELLOW}${BOLD}Exécution de ${label}${RESET}"
81+
echo -e "${YELLOW}${BOLD}Exécution de ${label}â¦${RESET}"
8282
bash "$tmp"; rc=$?
8383
if [[ $rc -eq 0 ]]; then
84-
echo -e "${GREEN}${BOLD} ${label} terminé avec succès${RESET}"
84+
echo -e "${GREEN}${BOLD}â ${label} terminé avec succès${RESET}"
8585
else
86-
echo -e "${RED}${BOLD} ${label} a échoué (rc=${rc})${RESET}"
86+
echo -e "${RED}${BOLD}â ${label} a échoué (rc=${rc})${RESET}"
8787
# indice utile pour new.sh
8888
ls -1 /var/log/new-basics-*.log 2>/dev/null | tail -n 1 | sed "s/^/Dernier log: /"
8989
fi
@@ -104,19 +104,19 @@ draw_menu() {
104104
echo " +-------------+"
105105
echo " | ${GREEN}${BOLD}Script${RESET}${BOLD} :${RESET} |"
106106
echo " +-------------+-------------+----------------+"
107-
echo " | 3. Exécuter 'new.sh' |"
107+
echo " | 3. Exécuter 'new.sh' |"
108108
echo " | |"
109-
echo " | 4. Exécuter 'speedtest.sh' |"
109+
echo " | 4. Exécuter 'speedtest.sh' |"
110110
echo " | |"
111-
echo " | 5. Exécuter 'fastfetch.sh' |"
111+
echo " | 5. Exécuter 'fastfetch.sh' |"
112112
echo " | |"
113-
echo " | 6. Exécuter 'pterodactyl-panel-reinstaller'|"
113+
echo " | 6. Exécuter 'pterodactyl-panel-reinstaller'|"
114114
echo " +--------------------------------------------+"
115-
echo " | 7. ${BLUE}${BOLD}Exécuter le Pterodactyl Menu${RESET} |"
116-
echo " | ${YELLOW}${BOLD}OverStyleFR/Pterodactyl-Installer-Menu${RESET} |"
115+
echo " | 7. ${BLUE}${BOLD}Exécuter le Pterodactyl Menu${RESET} |"
116+
echo " | â ${YELLOW}${BOLD}OverStyleFR/Pterodactyl-Installer-Menu${RESET} |"
117117
echo " +--------------------------------------------+"
118118
echo " | 8. ${BOLD}${VIOLET}M${GREEN}e${YELLOW}n${BLUE}u${RESET}${BOLD} SSH ${RESET} |"
119-
echo " | ${VIOLET}${BOLD}OverStyleFR/AutoScriptBash${RESET} |"
119+
echo " | â ${VIOLET}${BOLD}OverStyleFR/AutoScriptBash${RESET} |"
120120
echo " +-------------+------------+-----------------+"
121121
echo " | ${RED}${BOLD}9. Quitter${RESET} |"
122122
echo " +------------+"
@@ -139,27 +139,27 @@ while true; do
139139
pause
140140
;;
141141
3)
142-
echo "Exécution du script 'new.sh'."
142+
echo "Exécution du script 'new.sh'."
143143
run_remote "$NEW_URL" "new.sh"
144144
pause
145145
;;
146146
4)
147-
echo "Exécution du script 'speedtest.sh'."
147+
echo "Exécution du script 'speedtest.sh'."
148148
run_remote "$SPEED_URL" "speedtest.sh"
149149
pause
150150
;;
151151
5)
152-
echo "Exécution du script 'fastfetch-install.sh'."
152+
echo "Exécution du script 'fastfetch-install.sh'."
153153
run_remote "$FASTFETCH_URL" "fastfetch-install.sh"
154154
pause
155155
;;
156156
6)
157-
echo "Exécution du script 'pterodactyl-panel-reinstaller'."
157+
echo "Exécution du script 'pterodactyl-panel-reinstaller'."
158158
run_remote "$PANEL_REINSTALL_URL" "pterodactylpanelreinstall.sh"
159159
pause
160160
;;
161161
7)
162-
echo -e "${BLUE}${BOLD}Exécuter le Pterodactyl Menu${RESET}"
162+
echo -e "${BLUE}${BOLD}Exécuter le Pterodactyl Menu${RESET}"
163163
run_remote "$PTERO_MENU_URL" "PterodactylMenu.sh"
164164
pause
165165
;;
@@ -171,7 +171,7 @@ while true; do
171171
9)
172172
echo "Au revoir !"; exit 0 ;;
173173
*)
174-
echo -e "${RED}Choix non valide. Veuillez entrer un numéro entre 1 et 9.${RESET}"
174+
echo -e "${RED}Choix non valide. Veuillez entrer un numéro entre 1 et 9.${RESET}"
175175
sleep 1
176176
;;
177177
esac

0 commit comments

Comments
 (0)