Files
InnotexBootloarder/install.sh
2025-12-28 17:47:06 +01:00

101 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
set -e # Quitte le script en cas d'erreur
# --- 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 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
sudo apt-get update && sudo apt-get install -y plymouth plymouth-themes
elif command -v dnf >/dev/null 2>&1; then
sudo dnf install -y plymouth plymouth-themes
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -Sy --noconfirm plymouth plymouth-themes
else
echo "Impossible de détecter le gestionnaire de paquets. Installez plymouth manuellement."
exit 1
fi
fi
# 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
# awk
if ! command -v awk >/dev/null 2>&1; then
echo "La commande 'awk' est manquante. Installez gawk ou awk."
exit 1
fi
# --- 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"