Skip to content

Commit 5bfb787

Browse files
committed
Fix | Script V2.0-beta4
Fix syntax error Point à améliorer : - Problème lors de l'affichage des catégories sur le récap.
1 parent 32a046e commit 5bfb787

File tree

1 file changed

+61
-61
lines changed

1 file changed

+61
-61
lines changed

.assets/new.sh

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
#!/usr/bin/env bash
22
# ==============================================================================
3-
# new.sh bootstrap multi-distros (console propre + logs détaillés + récap par catégories)
3+
# new.sh â bootstrap multi-distros (console propre + logs dÃétaillÃés + rÃécap par catÃégories)
44
#
55
# USAGE:
66
# sudo ./new.sh [OPTIONS]
77
#
88
# OPTIONS:
99
# --debug Active le mode debug (bash -x) et les messages [DEBUG]
10-
# --dry-run N'exécute pas les commandes (simule) tout est loggué, console propre
11-
# --quiet|-q Réduit la verbosité console (n'affiche que WARN/ERROR, le log reste complet)
10+
# --dry-run N'exÃécute pas les commandes (simule) â tout est logguÃé, console propre
11+
# --quiet|-q RÃéduit la verbositÃé console (n'affiche que WARN/ERROR, le log reste complet)
1212
#
1313
# COMPORTEMENT:
14-
# - Détecte la distribution / gestionnaire de paquets
15-
# - MAJ index + upgrade système
16-
# - Installe des paquets communs (curl, wget, htop, ) + groupes spécifiques (gnupg, lm-sensors, dnsutils…)
17-
# - Installe fastfetch depuis les dépôts si dispo, sinon via script externe
14+
# - DÃétecte la distribution / gestionnaire de paquets
15+
# - MAJ index + upgrade systÃème
16+
# - Installe des paquets communs (curl, wget, htop, âæ) + groupes spÃécifiques (gnupg, lm-sensors, dnsutilsâæ)
17+
# - Installe fastfetch depuis les dÃépÃôts si dispo, sinon via script externe
1818
# - Remplace le ~/.bashrc (sans rechargement)
19-
# - Règle la timezone sur Europe/Paris
20-
# - Active avahi-daemon si présent
21-
# - Console : statut d’étapes uniquement ; Logs : détails complets et lisibles (/var/log)
19+
# - RÃègle la timezone sur Europe/Paris
20+
# - Active avahi-daemon si prÃésent
21+
# - Console : statut dâÃétapes uniquement ; Logs : dÃétails complets et lisibles (/var/log)
2222
# ==============================================================================
2323

2424
set -euo pipefail
@@ -84,26 +84,26 @@ run() {
8484
log "OK: (dry-run) $desc"
8585
REPORT_SKIP+=("$desc")
8686
_step_log_block "$desc" "SKIPPED (dry-run)" "0" "$cmd_str" /dev/null
87-
return 100 # code spécial "skip"
87+
return 100 # code spÃécial "skip"
8888
fi
8989
printf "%b[%s] [EXEC ]%b %s\n" "$BOLD" "$(_now)" "$C0" "$desc"
9090
if "$@" >"$tmp_out" 2>&1; then
91-
local d=$(_since "$ts"); log "OK: $desc (durée $d)"
91+
local d=$(_since "$ts"); log "OK: $desc (durÃée $d)"
9292
REPORT_OK+=("$desc")
9393
_step_log_block "$desc" "OK" "${d%s}" "$cmd_str" "$tmp_out"
9494
rm -f "$tmp_out"
9595
return 0
9696
else
9797
local rc=$?; local d=$(_since "$ts")
98-
err "ECHEC: $desc (durée $d, rc=$rc)"
98+
err "ECHEC: $desc (durÃée $d, rc=$rc)"
9999
REPORT_FAIL+=("$desc (rc=$rc)")
100100
_step_log_block "$desc" "FAIL (rc=$rc)" "${d%s}" "$cmd_str" "$tmp_out"
101101
rm -f "$tmp_out"
102102
return $rc
103103
fi
104104
}
105105

106-
# ============================== Catégories =====================================
106+
# ============================== CatÃégories =====================================
107107
# Status: 0=UNKNOWN, 1=OK, 2=SKIP, 3=FAIL (plus grand = pire)
108108
declare -A CAT
109109
_set_cat() {
@@ -113,37 +113,37 @@ _set_cat() {
113113
}
114114
_status_str() {
115115
case "$1" in
116-
1) printf "%b✓ OK%b" "$GRN" "$C0" ;;
117-
2) printf "%b⏭ SKIP%b" "$YEL" "$C0" ;;
118-
3) printf "%b✗ FAIL%b" "$RED" "$C0" ;;
116+
1) printf "%bâ OK%b" "$GRN" "$C0" ;;
117+
2) printf "%bâí SKIP%b" "$YEL" "$C0" ;;
118+
3) printf "%bâ FAIL%b" "$RED" "$C0" ;;
119119
*) printf "-" ;;
120120
esac
121121
}
122122

123123
# ============================== Root & contexte ================================
124124
if [[ $EUID -ne 0 ]]; then
125-
warn "Ce script doit être exécuté en root. Tentative avec sudo…"
125+
warn "Ce script doit Ãêtre exÃécutÃé en root. Tentative avec sudoâæ"
126126
exec sudo -E "$0" "$@"
127127
fi
128128

129-
trap 'err "Interruption ou erreur (code=$?) voir '"$LOG_FILE"'"; exit 1' INT TERM
129+
trap 'err "Interruption ou erreur (code=$?) â voir '"$LOG_FILE"'"; exit 1' INT TERM
130130

131131
log "Journal complet: $LOG_FILE"
132-
log "Hôte: $(hostname) | Kernel: $(uname -r) | Arch: $(uname -m)"
132+
log "HÃôte: $(hostname) | Kernel: $(uname -r) | Arch: $(uname -m)"
133133
log "Shell: $SHELL | DEBUG=$DEBUG | DRYRUN=$DRYRUN | QUIET=$QUIET"
134134

135-
# ============================== Détection distro ===============================
135+
# ============================== DÃétection distro ===============================
136136
DIST_ID=""; DIST_LIKE=""
137137
if [[ -r /etc/os-release ]]; then
138138
# shellcheck disable=SC1091
139139
. /etc/os-release
140140
DIST_ID="${ID:-unknown}"
141141
DIST_LIKE="${ID_LIKE:-}"
142142
else
143-
err "/etc/os-release introuvable abandon."
143+
err "/etc/os-release introuvable â abandon."
144144
exit 1
145145
fi
146-
log "Distribution détectée: ID=${DIST_ID} | ID_LIKE=${DIST_LIKE}"
146+
log "Distribution dÃétectÃée: ID=${DIST_ID} | ID_LIKE=${DIST_LIKE}"
147147

148148
# ============================== Gestionnaire paquets ===========================
149149
PKG_MGR="" PKG_UPDATE="" PKG_UPGRADE="" PKG_INSTALL=""
@@ -196,7 +196,7 @@ case "$DIST_ID" in
196196
else
197197
PKG_MGR="yum"; PKG_UPDATE="yum -y makecache"; PKG_UPGRADE="yum -y update"; PKG_INSTALL="yum -y install"
198198
fi ;;
199-
*) err "Distribution non gérée (ID=$DIST_ID ID_LIKE=$DIST_LIKE)"; exit 1 ;;
199+
*) err "Distribution non gÃérÃée (ID=$DIST_ID ID_LIKE=$DIST_LIKE)"; exit 1 ;;
200200
esac
201201
;;
202202
esac
@@ -236,7 +236,7 @@ install_if_exists() {
236236
return 1
237237
fi
238238
else
239-
run "Installer ($group) dry-run" echo "$PKG_INSTALL ${ok[*]}" >/dev/null
239+
run "Installer ($group) â dry-run" echo "$PKG_INSTALL ${ok[*]}" >/dev/null
240240
return 100
241241
fi
242242
else
@@ -245,9 +245,9 @@ install_if_exists() {
245245
fi
246246
}
247247

248-
# ============================== MAJ système ===================================
248+
# ============================== MAJ systÃème ===================================
249249
rc=$(run "MAJ index paquets" bash -lc "$PKG_UPDATE"); (( rc==0 )) && _set_cat "update_index" 1 || _set_cat "update_index" 3
250-
rc=$(run "Upgrade système" bash -lc "$PKG_UPGRADE"); (( rc==0 )) && _set_cat "upgrade_system" 1 || _set_cat "upgrade_system" 3
250+
rc=$(run "Upgrade systÃème" bash -lc "$PKG_UPGRADE"); (( rc==0 )) && _set_cat "upgrade_system" 1 || _set_cat "upgrade_system" 3
251251

252252
# ============================== Mapping paquets ===============================
253253
PKG_GNUPG=(gnupg gnupg2)
@@ -266,8 +266,8 @@ PKG_AVAHI_OTH=(avahi avahi-daemon)
266266
PKG_BPY=(bpytop)
267267
PKG_BTOP=(btop bashtop)
268268

269-
log "Sélection des paquets selon famille: $DIST_ID ($PKG_MGR)"
270-
# Paquets communs (même nom multi-distros)
269+
log "SÃélection des paquets selon famille: $DIST_ID ($PKG_MGR)"
270+
# Paquets communs (mÃême nom multi-distros)
271271
case "$PKG_MGR" in
272272
apt) rc=$(install_if_exists "commun" "${PKG_COMMON[@]}" "${PKG_MAN_DEB[@]}" "${PKG_DNS_DEB[@]}" "${PKG_AVAHI_DEB[@]}") ;;
273273
dnf|yum)rc=$(install_if_exists "commun" "${PKG_COMMON[@]}" "${PKG_MAN_RPM[@]}" "${PKG_DNS_RPM[@]}" "${PKG_AVAHI_OTH[@]}") ;;
@@ -281,7 +281,7 @@ case "$rc" in
281281
*) _set_cat "install_common" 3 ;;
282282
esac
283283

284-
# Groupes spécifiques
284+
# Groupes spÃécifiques
285285
install_if_exists "gnupg" "${PKG_GNUPG[@]}" >/dev/null 2>&1 || true
286286
if [[ "$PKG_MGR" == "pacman" ]]; then
287287
install_if_exists "lm-sensors" "${PKG_LMSENS_ARCH[@]}" >/dev/null 2>&1 || true
@@ -298,12 +298,12 @@ fi
298298
FASTFETCH_URL="https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main/.assets/fastfetch-install.sh"
299299
install_fastfetch() {
300300
if pkg_available fastfetch; then
301-
run "Installer (fastfetch via dépôts)" $PKG_INSTALL fastfetch
301+
run "Installer (fastfetch via dÃépÃôts)" $PKG_INSTALL fastfetch
302302
return $?
303303
fi
304-
warn "fastfetch non dispo dans les dépôts — fallback script externe"
304+
warn "fastfetch non dispo dans les dÃépÃôts â fallback script externe"
305305
if [[ $DRYRUN -eq 1 ]]; then
306-
run "Installer (fastfetch via script) dry-run" echo "bash <(curl -fsSL $FASTFETCH_URL)" >/dev/null
306+
run "Installer (fastfetch via script) â dry-run" echo "bash <(curl -fsSL $FASTFETCH_URL)" >/dev/null
307307
return 100
308308
fi
309309
if command -v curl >/dev/null 2>&1; then
@@ -313,7 +313,7 @@ install_fastfetch() {
313313
run "Installer (fastfetch via script)" bash -lc "bash <(wget -qO- \"$FASTFETCH_URL\")"
314314
return $?
315315
else
316-
err "Ni curl ni wget disponibles fastfetch non installé."
316+
err "Ni curl ni wget disponibles â fastfetch non installÃé."
317317
return 1
318318
fi
319319
}
@@ -326,16 +326,16 @@ esac
326326

327327
# ============================== Timezone ======================================
328328
if command -v timedatectl >/dev/null 2>&1; then
329-
rc=$(run "Réglage timezone Europe/Paris" timedatectl set-timezone Europe/Paris);
329+
rc=$(run "RÃéglage timezone Europe/Paris" timedatectl set-timezone Europe/Paris);
330330
else
331-
warn "timedatectl indisponible tentative via /etc/localtime"
331+
warn "timedatectl indisponible â tentative via /etc/localtime"
332332
ZF="/usr/share/zoneinfo/Europe/Paris"
333333
if [[ -f "$ZF" ]]; then
334-
rc=$(run "Lien /etc/localtime Europe/Paris" ln -sf "$ZF" /etc/localtime || true; echo)
334+
rc=$(run "Lien /etc/localtime â Europe/Paris" ln -sf "$ZF" /etc/localtime || true; echo)
335335
[[ -w /etc/timezone ]] && echo "Europe/Paris" >/etc/timezone || true
336336
else
337337
rc=1
338-
err "Zoneinfo non trouvée"
338+
err "Zoneinfo non trouvÃée"
339339
fi
340340
fi
341341
(( rc==0 || rc==100 )) && _set_cat "timezone" $(( rc==100 ? 2 : 1 )) || _set_cat "timezone" 3
@@ -351,62 +351,62 @@ BRC_RC=0
351351
log "Remplacement du .bashrc pour $TARGET_USER ($TARGET_HOME)"
352352
[[ -f "$TARGET_RC" ]] && { run "Backup $TARGET_RC" cp -a "$TARGET_RC" "$BK" || BRC_RC=1; } || true
353353
if command -v curl >/dev/null 2>&1; then
354-
if ! run "Télécharger .bashrc" curl -fsSL "$BRC_URL" -o "$TARGET_RC"; then BRC_RC=1; fi
354+
if ! run "TÃélÃécharger .bashrc" curl -fsSL "$BRC_URL" -o "$TARGET_RC"; then BRC_RC=1; fi
355355
elif command -v wget >/dev/null 2>&1; then
356-
if ! run "Télécharger .bashrc" wget -q "$BRC_URL" -O "$TARGET_RC"; then BRC_RC=1; fi
356+
if ! run "TÃélÃécharger .bashrc" wget -q "$BRC_URL" -O "$TARGET_RC"; then BRC_RC=1; fi
357357
else
358-
warn "Ni curl ni wget pour récupérer le .bashrc"; BRC_RC=1
358+
warn "Ni curl ni wget pour rÃécupÃérer le .bashrc"; BRC_RC=1
359359
fi
360360
[[ -f "$TARGET_RC" ]] && { run "Chown .bashrc" chown "$TARGET_USER":"$TARGET_USER" "$TARGET_RC" || BRC_RC=1; } || true
361361
if [[ -d /etc/skel && -f "$TARGET_RC" ]]; then
362362
run "Copie .bashrc vers /etc/skel" cp -f "$TARGET_RC" /etc/skel/.bashrc || BRC_RC=1
363363
fi
364364
(( BRC_RC==0 )) && _set_cat "bashrc" 1 || _set_cat "bashrc" 3
365-
# NOTE: rechargement du .bashrc volontairement désactivé
365+
# NOTE: rechargement du .bashrc volontairement dÃésactivÃé
366366

367-
# ============================== Avahi (enable si présent) =====================
367+
# ============================== Avahi (enable si prÃésent) =====================
368368
if command -v systemctl >/dev/null 2>&1; then
369369
if systemctl list-unit-files | grep -q '^avahi-daemon\.service'; then
370370
rc=$(run "Activer avahi-daemon" systemctl enable --now avahi-daemon)
371371
(( rc==0 || rc==100 )) && _set_cat "avahi" $(( rc==100 ? 2 : 1 )) || _set_cat "avahi" 3
372372
else
373-
debug "Service avahi-daemon non présent — ignoré."
373+
debug "Service avahi-daemon non prÃésent â ignorÃé."
374374
_set_cat "avahi" 2
375375
fi
376376
else
377-
debug "systemctl indisponible probablement sans systemd."
377+
debug "systemctl indisponible â probablement sans systemd."
378378
_set_cat "avahi" 2
379379
fi
380380

381-
# ============================== Récapitulatif (catégories) =====================
381+
# ============================== RÃécapitulatif (catÃégories) =====================
382382
echo
383-
echo -e "${BOLD}============================= RÉCAPITULATIF =============================${C0}"
383+
echo -e "${BOLD}============================= RÃCAPITULATIF =============================${C0}"
384384
echo " Journal : $LOG_FILE"
385385
echo " Distro : ID=$DIST_ID | LIKE=$DIST_LIKE | PM=$PKG_MGR"
386-
echo " Durée : $(_since "$_start_ts")"
386+
echo " DurÃée : $(_since "$_start_ts")"
387387
echo
388-
echo -e "${BOLD}Catégories:${C0}"
389-
printf " %-28s : %s\n" "Détection gestionnaire" "$(_status_str "${CAT[detect_pm]:-0}")"
388+
echo -e "${BOLD}CatÃégories:${C0}"
389+
printf " %-28s : %s\n" "DÃétection gestionnaire" "$(_status_str "${CAT[detect_pm]:-0}")"
390390
printf " %-28s : %s\n" "MAJ index paquets" "$(_status_str "${CAT[update_index]:-0}")"
391-
printf " %-28s : %s\n" "Upgrade système" "$(_status_str "${CAT[upgrade_system]:-0}")"
391+
printf " %-28s : %s\n" "Upgrade systÃème" "$(_status_str "${CAT[upgrade_system]:-0}")"
392392
printf " %-28s : %s\n" "Paquets communs" "$(_status_str "${CAT[install_common]:-0}")"
393393
printf " %-28s : %s\n" "Fastfetch" "$(_status_str "${CAT[fastfetch]:-0}")"
394394
printf " %-28s : %s\n" "Timezone (Europe/Paris)" "$(_status_str "${CAT[timezone]:-0}")"
395-
printf " %-28s : %s\n" ".bashrc (déploiement)" "$(_status_str "${CAT[bashrc]:-0}")"
396-
printf " %-28s : %s\n" "Avahi (enable si présent)" "$(_status_str "${CAT[avahi]:-0}")"
395+
printf " %-28s : %s\n" ".bashrc (dÃéploiement)" "$(_status_str "${CAT[bashrc]:-0}")"
396+
printf " %-28s : %s\n" "Avahi (enable si prÃésent)" "$(_status_str "${CAT[avahi]:-0}")"
397397
echo
398-
echo -e "${BOLD}Détail étapes:${C0}"
399-
echo " Étapes OK : ${#REPORT_OK[@]}"
400-
for s in "${REPORT_OK[@]}"; do echo " ${GRN}${C0} $s"; done
398+
echo -e "${BOLD}DÃétail Ãétapes:${C0}"
399+
echo " Ãtapes OK : ${#REPORT_OK[@]}"
400+
for s in "${REPORT_OK[@]}"; do echo " ${GRN}â${C0} $s"; done
401401
echo
402-
echo " Étapes FAIL : ${#REPORT_FAIL[@]}"
403-
for s in "${REPORT_FAIL[@]}"; do echo " ${RED}${C0} $s"; done
402+
echo " Ãtapes FAIL : ${#REPORT_FAIL[@]}"
403+
for s in "${REPORT_FAIL[@]}"; do echo " ${RED}â${C0} $s"; done
404404
if [[ $DRYRUN -eq 1 || ${#REPORT_SKIP[@]} -gt 0 ]]; then
405405
echo
406-
echo " Étapes SKIP : ${#REPORT_SKIP[@]}"
407-
for s in "${REPORT_SKIP[@]}"; do echo " ${YEL}${C0} $s"; done
406+
echo " Ãtapes SKIP : ${#REPORT_SKIP[@]}"
407+
for s in "${REPORT_SKIP[@]}"; do echo " ${YEL}âí${C0} $s"; done
408408
fi
409409
echo -e "${BOLD}=========================================================================${C0}"
410410

411-
log "Configuration terminée."
411+
log "Configuration terminÃée."
412412
# Fin

0 commit comments

Comments
 (0)