Skip to content

Commit 66f8a31

Browse files
committed
Update | Script V2.0-beta1
Script OK Point a améliorer : - Faire du dry-run par défaut (ne pas afficher les résultats de commandes. - Plus de détails dans les logs et ajouter une vrai différence entre les logs et la console. Actuellement les deux sont exactements les mêmes. - Désactivement du rechargement du .bashrc (interromp le script en cours de ce fait). - Modifier le récap a la fin, ajouter si toutes les étapes ont été réussi, si ce n'est pas le cas alors afficher les étapes échoué.
1 parent 75e6e00 commit 66f8a31

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

.assets/new.sh

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env bash
2-
# new-basics.sh version verbose pour techniciens
2+
# new-basics.sh â version verbose pour techniciens
33
# Objectif :
4-
# - Détecte la distro et installe : gnupg{,2} lm-sensors curl wget htop nload screen vim git ncdu bpytop rsync man avahi-daemon tree dnsutils net-tools ripgrep
5-
# - fastfetch : depuis les dépôts si dispo, sinon script externe (GitHub)
6-
# - Remplace le .bashrc de l’utilisateur appelant (SUDO_USER le cas échéant)
4+
# - Détecte la distro et installe : gnupg{,2} lm-sensors curl wget htop nload screen vim git ncdu bpytop rsync man avahi-daemon tree dnsutils net-tools ripgrep
5+
# - fastfetch : depuis les dépôts si dispo, sinon script externe (GitHub)
6+
# - Remplace le .bashrc de lâutilisateur appelant (SUDO_USER le cas échéant)
77
# - Timezone -> Europe/Paris
8-
# - Logs détaillés dans /var/log + affichage verbeux, options --debug --dry-run --quiet
8+
# - Logs détaillés dans /var/log + affichage verbeux, options --debug --dry-run --quiet
99

1010
set -euo pipefail
1111

@@ -45,44 +45,44 @@ run() {
4545
local desc="$1"; shift
4646
local ts=$(date +%s)
4747
if [[ $DRYRUN -eq 1 ]]; then
48-
printf "%b[%s] [DRYRN]%b %s %s\n" "$DIM" "$(_now)" "$C0" "$desc" "$*"
48+
printf "%b[%s] [DRYRN]%b %s â %s\n" "$DIM" "$(_now)" "$C0" "$desc" "$*"
4949
return 0
5050
fi
5151
printf "%b[%s] [EXEC ]%b %s\n" "$BOLD" "$(_now)" "$C0" "$desc"
5252
debug "Commande: $*"
5353
if "$@"; then
54-
log "OK: $desc (durée $(_since "$ts"))"
54+
log "OK: $desc (durée $(_since "$ts"))"
5555
return 0
5656
else
57-
err "ECHEC: $desc (durée $(_since "$ts"))"
57+
err "ECHEC: $desc (durée $(_since "$ts"))"
5858
return 1
5959
fi
6060
}
6161

6262
# ============================== Root & contexte ================================
6363
if [[ $EUID -ne 0 ]]; then
64-
warn "Ce script doit être exécuté en root. Tentative avec sudo…"
64+
warn "Ce script doit être exécuté en root. Tentative avec sudoâ¦"
6565
exec sudo -E "$0" "$@"
6666
fi
6767

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

7070
log "Journal complet: $LOG_FILE"
71-
log "Hôte: $(hostname) | Kernel: $(uname -r) | Arch: $(uname -m)"
71+
log "Hôte: $(hostname) | Kernel: $(uname -r) | Arch: $(uname -m)"
7272
log "Shell: $SHELL | DEBUG=$DEBUG | DRYRUN=$DRYRUN | QUIET=$QUIET"
7373

74-
# ============================== Détection distro ===============================
74+
# ============================== Détection distro ===============================
7575
DIST_ID=""; DIST_LIKE=""
7676
if [[ -r /etc/os-release ]]; then
7777
# shellcheck disable=SC1091
7878
. /etc/os-release
7979
DIST_ID="${ID:-unknown}"
8080
DIST_LIKE="${ID_LIKE:-}"
8181
else
82-
err "/etc/os-release introuvable abandon."
82+
err "/etc/os-release introuvable â abandon."
8383
exit 1
8484
fi
85-
log "Distribution détectée: ID=${DIST_ID} | ID_LIKE=${DIST_LIKE}"
85+
log "Distribution détectée: ID=${DIST_ID} | ID_LIKE=${DIST_LIKE}"
8686

8787
# ============================== Gestionnaire paquets ===========================
8888
PKG_MGR="" PKG_UPDATE="" PKG_UPGRADE="" PKG_INSTALL="" PKG_Q_AVAIL=""
@@ -145,7 +145,7 @@ case "$DIST_ID" in
145145
PKG_MGR="yum"; PKG_UPDATE="yum -y makecache"; PKG_UPGRADE="yum -y update"; PKG_INSTALL="yum -y install"; PKG_Q_AVAIL="yum -q info"
146146
fi ;;
147147
*)
148-
err "Distribution non gérée (ID=$DIST_ID ID_LIKE=$DIST_LIKE)"; exit 1 ;;
148+
err "Distribution non gérée (ID=$DIST_ID ID_LIKE=$DIST_LIKE)"; exit 1 ;;
149149
esac
150150
;;
151151
esac
@@ -186,14 +186,14 @@ install_if_exists() {
186186
fi
187187
}
188188

189-
# ============================== MAJ système ===================================
189+
# ============================== MAJ système ===================================
190190
ts_update=$(date +%s)
191-
run "MAJ index paquets" bash -c "$PKG_UPDATE" || warn "Update partielle/échouée"
192-
run "Upgrade système" bash -c "$PKG_UPGRADE" || warn "Upgrade partielle/échouée"
193-
log "Section MAJ terminée (durée $(_since "$ts_update"))"
191+
run "MAJ index paquets" bash -c "$PKG_UPDATE" || warn "Update partielle/échouée"
192+
run "Upgrade système" bash -c "$PKG_UPGRADE" || warn "Upgrade partielle/échouée"
193+
log "Section MAJ terminée (durée $(_since "$ts_update"))"
194194

195195
# ============================== Mapping paquets ===============================
196-
# Liste demandée : gnupg{,2} lm-sensors curl wget htop nload screen vim git ncdu bpytop rsync man avahi-daemon tree dnsutils net-tools ripgrep
196+
# Liste demandée : gnupg{,2} lm-sensors curl wget htop nload screen vim git ncdu bpytop rsync man avahi-daemon tree dnsutils net-tools ripgrep
197197
PKG_GNUPG=(gnupg gnupg2)
198198
PKG_LMSENS_DEB_RPM=(lm-sensors)
199199
PKG_LMSENS_ARCH=(lm_sensors)
@@ -210,7 +210,7 @@ PKG_AVAHI_OTH=(avahi avahi-daemon) # RPM/Arch/openSUSE/Alpine (selon cas)
210210
PKG_BPY=(bpytop)
211211
PKG_BTOP=(btop bashtop) # fallback si bpytop indispo
212212

213-
log "Sélection des paquets selon famille: $DIST_ID ($PKG_MGR)"
213+
log "Sélection des paquets selon famille: $DIST_ID ($PKG_MGR)"
214214
case "$PKG_MGR" in
215215
apt)
216216
install_if_exists "gnupg" "${PKG_GNUPG[@]}"
@@ -249,12 +249,12 @@ FASTFETCH_URL="https://raw.githubusercontent.com/OverStyleFR/AutoScriptBash/main
249249
install_fastfetch() {
250250
local ts=$(date +%s)
251251
if pkg_available fastfetch; then
252-
log "fastfetch disponible dans les dépôts: installation via $PKG_MGR"
252+
log "fastfetch disponible dans les dépôts: installation via $PKG_MGR"
253253
install_if_exists "fastfetch" fastfetch
254-
log "fastfetch installé via dépôts (durée $(_since "$ts"))"
254+
log "fastfetch installé via dépôts (durée $(_since "$ts"))"
255255
return 0
256256
fi
257-
warn "fastfetch non dispo dans les dépôts — fallback script externe"
257+
warn "fastfetch non dispo dans les dépôts â fallback script externe"
258258
if [[ $DRYRUN -eq 1 ]]; then
259259
printf "[DRYRUN] bash <(curl -fsSL %s)\n" "$FASTFETCH_URL"
260260
return 0
@@ -264,20 +264,20 @@ install_fastfetch() {
264264
elif command -v wget >/dev/null 2>&1; then
265265
run "Installer fastfetch (script)" bash -c "bash <(wget -qO- \"$FASTFETCH_URL\")"
266266
else
267-
err "Ni curl ni wget disponibles fastfetch non installé."
267+
err "Ni curl ni wget disponibles â fastfetch non installé."
268268
return 1
269269
fi
270-
log "fastfetch via script terminé (durée $(_since "$ts"))"
270+
log "fastfetch via script terminé (durée $(_since "$ts"))"
271271
}
272-
install_fastfetch || warn "Installation fastfetch échouée (script)."
272+
install_fastfetch || warn "Installation fastfetch échouée (script)."
273273

274274
# ============================== Timezone ======================================
275275
if command -v timedatectl >/dev/null 2>&1; then
276-
run "Réglage timezone Europe/Paris" timedatectl set-timezone Europe/Paris || warn "Echec réglage timezone"
276+
run "Réglage timezone Europe/Paris" timedatectl set-timezone Europe/Paris || warn "Echec réglage timezone"
277277
else
278-
warn "timedatectl indisponible tentative via /etc/localtime"
278+
warn "timedatectl indisponible â tentative via /etc/localtime"
279279
ZF="/usr/share/zoneinfo/Europe/Paris"
280-
[[ -f "$ZF" ]] && run "Lien /etc/localtime Europe/Paris" ln -sf "$ZF" /etc/localtime || warn "Zoneinfo non trouvée"
280+
[[ -f "$ZF" ]] && run "Lien /etc/localtime â Europe/Paris" ln -sf "$ZF" /etc/localtime || warn "Zoneinfo non trouvée"
281281
[[ -w /etc/timezone ]] && echo "Europe/Paris" >/etc/timezone || true
282282
fi
283283

@@ -294,12 +294,12 @@ if [[ -f "$TARGET_RC" ]]; then
294294
fi
295295
if command -v curl >/dev/null 2>&1; then
296296
[[ $DRYRUN -eq 1 ]] && echo "[DRYRUN] curl -fsSL $BRC_URL -o $TARGET_RC" \
297-
|| run "Télécharger .bashrc" curl -fsSL "$BRC_URL" -o "$TARGET_RC"
297+
|| run "Télécharger .bashrc" curl -fsSL "$BRC_URL" -o "$TARGET_RC"
298298
elif command -v wget >/dev/null 2>&1; then
299299
[[ $DRYRUN -eq 1 ]] && echo "[DRYRUN] wget -q $BRC_URL -O $TARGET_RC" \
300-
|| run "Télécharger .bashrc" wget -q "$BRC_URL" -O "$TARGET_RC"
300+
|| run "Télécharger .bashrc" wget -q "$BRC_URL" -O "$TARGET_RC"
301301
else
302-
warn "Ni curl ni wget pour récupérer le .bashrc"
302+
warn "Ni curl ni wget pour récupérer le .bashrc"
303303
fi
304304
# Permissions
305305
if [[ $DRYRUN -eq 0 && -f "$TARGET_RC" ]]; then
@@ -315,25 +315,25 @@ if [[ -n "${PS1:-}" && -n "${BASH_VERSION:-}" && $DRYRUN -eq 0 && "$TARGET_HOME"
315315
run "Recharger ~/.bashrc" bash -lc "source \"$HOME/.bashrc\"" || true
316316
fi
317317

318-
# ============================== Avahi (enable si présent) =====================
318+
# ============================== Avahi (enable si présent) =====================
319319
if command -v systemctl >/dev/null 2>&1; then
320320
if systemctl list-unit-files | grep -q '^avahi-daemon\.service'; then
321321
run "Activer avahi-daemon" systemctl enable --now avahi-daemon || warn "Impossible d'activer avahi-daemon"
322322
else
323-
debug "Service avahi-daemon non présent — ignoré."
323+
debug "Service avahi-daemon non présent â ignoré."
324324
fi
325325
else
326-
debug "systemctl indisponible probablement sans systemd."
326+
debug "systemctl indisponible â probablement sans systemd."
327327
fi
328328

329-
# ============================== Récapitulatif =================================
329+
# ============================== Récapitulatif =================================
330330
echo
331-
echo -e "${BOLD}============================= RÉCAPITULATIF =============================${C0}"
331+
echo -e "${BOLD}============================= RÃCAPITULATIF =============================${C0}"
332332
echo " - Journal complet : $LOG_FILE"
333333
echo " - Distro : ID=$DIST_ID | LIKE=$DIST_LIKE | PKG_MGR=$PKG_MGR"
334334
echo " - DEBUG : $DEBUG | DRYRUN=$DRYRUN | QUIET=$QUIET"
335-
echo " - Durée totale : $(_since "$_start_ts")"
335+
echo " - Durée totale : $(_since "$_start_ts")"
336336
echo -e "${BOLD}=========================================================================${C0}"
337337

338-
log "Configuration terminée."
338+
log "Configuration terminée."
339339
# Fin

0 commit comments

Comments
 (0)