Chaque lanceur trouve ou propose d'installer Python puis appelle l'assistant. .gitattributes impose LF pour .sh/.command et CRLF pour .bat ; bit exécutable posé dans git. Sous Windows, chcp et les tests Python lisent <nul pour ne pas vider l'entrée standard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
1.8 KiB
Bash
Executable File
54 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Assistant de génération des supports (Linux) : clic droit > « Exécuter comme un programme »,
|
|
# ou dans un terminal : ./generer-documents.sh
|
|
cd "$(dirname "$(readlink -f "$0")")" || exit 1
|
|
|
|
# Lancé hors d'un terminal (double-clic) : on se relance dans une fenêtre de terminal.
|
|
if [ ! -t 0 ]; then
|
|
for t in x-terminal-emulator gnome-terminal konsole xfce4-terminal xterm; do
|
|
if command -v "$t" >/dev/null 2>&1; then
|
|
case "$t" in
|
|
gnome-terminal) exec "$t" -- "$0" ;;
|
|
*) exec "$t" -e "$0" ;;
|
|
esac
|
|
fi
|
|
done
|
|
fi
|
|
|
|
trouver_python() {
|
|
if command -v python3 >/dev/null 2>&1 && python3 -c "import venv, ensurepip" >/dev/null 2>&1; then
|
|
PY=python3
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
if ! trouver_python; then
|
|
echo "Python 3 (avec le module venv) est nécessaire mais n'a pas été trouvé."
|
|
if command -v apt-get >/dev/null 2>&1; then
|
|
cmd="sudo apt-get install -y python3 python3-venv"
|
|
elif command -v dnf >/dev/null 2>&1; then
|
|
cmd="sudo dnf install -y python3"
|
|
elif command -v pacman >/dev/null 2>&1; then
|
|
cmd="sudo pacman -S --needed --noconfirm python"
|
|
elif command -v zypper >/dev/null 2>&1; then
|
|
cmd="sudo zypper install -y python3"
|
|
fi
|
|
if [ -n "$cmd" ]; then
|
|
read -r -p "Lancer l'installation ($cmd) ? Votre mot de passe sera demandé. [O/n] " rep
|
|
if [[ ! "$rep" =~ ^[nN] ]]; then
|
|
$cmd
|
|
fi
|
|
fi
|
|
if ! trouver_python; then
|
|
echo "Installez Python 3 et son module venv avec le gestionnaire de paquets de votre distribution,"
|
|
echo "puis relancez ce fichier."
|
|
read -r -p "Appuyez sur Entrée pour fermer... "
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
"$PY" scripts/assistant.py
|
|
echo
|
|
read -r -p "Appuyez sur Entrée pour fermer... "
|