From 8e3251ed7f062392cb1eaa452c222fce7a0a0e2b Mon Sep 17 00:00:00 2001 From: root Date: Sun, 28 Dec 2025 17:47:06 +0100 Subject: [PATCH] update du script d'installation --- install.sh | 129 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 80 insertions(+), 49 deletions(-) diff --git a/install.sh b/install.sh index 2591258..4233355 100755 --- a/install.sh +++ b/install.sh @@ -1,69 +1,100 @@ #!/bin/bash +set -e # Quitte le script en cas d'erreur -# Configurables -PLYMOUTH_DIR=/usr/share/plymouth/themes -PLYMOUTH_THEME=InnotexBootloarder -THEME_IMAGE=InnotexBootloarder/InnotexBootloarder.png # Chemin vers l'image dans le thème +# --- Configurables --- +PLYMOUTH_DIR="/usr/share/plymouth/themes" +PLYMOUTH_THEME="InnotexBootloarder" +THEME_DIR="InnotexBootloarder" +THEME_IMAGE="$THEME_DIR/InnotexBootloarder.png" +SCRIPT_IN="$THEME_DIR/InnotexBootloarder.script.in" +SCRIPT_OUT="$THEME_DIR/InnotexBootloarder.script" +# --- Fin Configurables --- -# Vérification et installation de plymouth si nécessaire +# --- Vérification des dépendances --- +echo "Vérification des dépendances..." + +# Plymouth if ! command -v plymouthd >/dev/null 2>&1; then echo "Plymouth n'est pas installé. Installation en cours..." if command -v apt-get >/dev/null 2>&1; then - apt-get update && apt-get install -y plymouth plymouth-themes + sudo apt-get update && sudo apt-get install -y plymouth plymouth-themes elif command -v dnf >/dev/null 2>&1; then - dnf install -y plymouth plymouth-themes + sudo dnf install -y plymouth plymouth-themes elif command -v pacman >/dev/null 2>&1; then - pacman -Sy --noconfirm plymouth plymouth-themes + sudo pacman -Sy --noconfirm plymouth plymouth-themes else echo "Impossible de détecter le gestionnaire de paquets. Installez plymouth manuellement." exit 1 fi fi -# Sanity Checks -if [[ ! -f "$THEME_IMAGE" ]]; then - echo "Sorry, I can't find the theme image at $THEME_IMAGE" - echo "Please make sure the image exists in your theme directory." +# ImageMagick (convert) +if ! command -v convert >/dev/null 2>&1; then + echo "ImageMagick (convert) n'est pas installé. Installation en cours..." + if command -v apt-get >/dev/null 2>&1; then + sudo apt-get install -y imagemagick + elif command -v dnf >/dev/null 2>&1; then + sudo dnf install -y imagemagick + elif command -v pacman >/dev/null 2>&1; then + sudo pacman -Sy --noconfirm imagemagick + else + echo "Impossible d'installer ImageMagick automatiquement. Installez-le manuellement." + exit 1 + fi +fi + +# coreutils (install) +if ! command -v install >/dev/null 2>&1; then + echo "La commande 'install' (coreutils) est manquante. Installez coreutils." exit 1 fi -command -v convert >/dev/null 2>&1 || { echo >&2 "I require convert (from imagemagick) but it's not installed. Aborting."; exit 1; } -command -v install >/dev/null 2>&1 || { echo >&2 "I require install (from coreutils) but it's not installed. Aborting."; exit 1; } -command -v awk >/dev/null 2>&1 || { echo >&2 "I require awk but it's not installed. Aborting."; exit 1; } - -# OK. On suppose que l'image est déjà au bon format et au bon endroit -# Si besoin de conversion, décommentez la ligne suivante et adaptez -# convert "$THEME_IMAGE" "$THEME_IMAGE" - -# Remplace les placeholders avec les offsets (à adapter selon tes besoins) -# Si tu veux garder les offsets, il faut les définir manuellement ici ou les lire d'un fichier de config -BGRTLEFT=0 -BGRTTOP=100 - -< InnotexBootloarder/InnotexBootloarder.script.in awk \ - -v BGRTLEFT="$BGRTLEFT" \ - -v BGRTTOP="$BGRTTOP" \ - '{gsub (/\$BGRTLEFT\$/, BGRTLEFT); - gsub (/\$BGRTTOP\$/, BGRTTOP); - print}' > InnotexBootloarder/InnotexBootloarder.script - -# Enfin, installe le thème -install -d ${PLYMOUTH_DIR}/${PLYMOUTH_THEME} -install -m644 InnotexBootloarder/InnotexBootloarder.plymouth ${PLYMOUTH_DIR}/${PLYMOUTH_THEME}/ -install -m644 InnotexBootloarder/InnotexBootloarder.{script,png} ${PLYMOUTH_DIR}/${PLYMOUTH_THEME}/ -install -m644 InnotexBootloarder/{box,bullet,progress_{bar,box}}.png ${PLYMOUTH_DIR}/${PLYMOUTH_THEME}/ - -[ -d /lib/lsb/init-functions.d ] && install -m644 scripts/init-functions /lib/lsb/init-functions.d/999-bgrt -[ -d /etc/initramfs-tools/hooks ] && install -m755 scripts/initramfs-hook /etc/initramfs-tools/hooks/bgrt-fonts - -# Mise à jour de l'initramfs si nécessaire -if [ -x /usr/bin/update-initramfs ]; then - update-initramfs -u -elif [ -x /usr/bin/dracut ]; then - dracut --force +# awk +if ! command -v awk >/dev/null 2>&1; then + echo "La commande 'awk' est manquante. Installez gawk ou awk." + exit 1 fi -echo "Install complete." -echo "To use this theme, run as root:" -echo " plymouth-set-default-theme -R ${PLYMOUTH_THEME}" +# --- Vérification des fichiers du thème --- +echo "Vérification des fichiers du thème..." +if [[ ! -f "$THEME_IMAGE" ]]; then + echo "Erreur : l'image '$THEME_IMAGE' est introuvable." + exit 1 +fi +if [[ ! -f "$SCRIPT_IN" ]]; then + echo "Erreur : le fichier script '$SCRIPT_IN' est introuvable." + exit 1 +fi + +# --- Génération du script Plymouth --- +echo "Génération du script Plymouth..." +BGRTLEFT=0 +BGRTTOP=100 +awk -v BGRTLEFT="$BGRTLEFT" -v BGRTTOP="$BGRTTOP" \ + '{gsub(/\$BGRTLEFT\$/, BGRTLEFT); gsub(/\$BGRTTOP\$/, BGRTTOP); print}' \ + "$SCRIPT_IN" > "$SCRIPT_OUT" + +# --- Installation du thème --- +echo "Installation du thème Plymouth..." +sudo install -d "$PLYMOUTH_DIR/$PLYMOUTH_THEME" +sudo install -m644 "$THEME_DIR"/*.plymouth "$PLYMOUTH_DIR/$PLYMOUTH_THEME/" +sudo install -m644 "$THEME_DIR"/*.{script,png} "$PLYMOUTH_DIR/$PLYMOUTH_THEME/" + +# --- Mise à jour de l'initramfs --- +echo "Mise à jour de l'initramfs..." +if [ -x /usr/bin/update-initramfs ]; then + sudo update-initramfs -u +elif [ -x /usr/bin/dracut ]; then + sudo dracut --force +elif [ -x /usr/bin/mkinitcpio ]; then + sudo mkinitcpio -P +else + echo "Impossible de mettre à jour l'initramfs automatiquement. Faites-le manuellement." +fi + +# --- Instructions finales --- +echo "" +echo "Installation terminée avec succès !" +echo "Pour activer ce thème, exécutez en tant que root :" +echo " plymouth-set-default-theme -R $PLYMOUTH_THEME"