119 lines
4.7 KiB
Bash
Executable File
119 lines
4.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Script d'installation de CachyOS Updater
|
|
set -euo pipefail
|
|
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
info() { echo -e "${GREEN}[✓]${NC} $*"; }
|
|
warn() { echo -e "${YELLOW}[!]${NC} $*"; }
|
|
error() { echo -e "${RED}[✗]${NC} $*" >&2; }
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
error "Ce script doit être lancé en tant que root (sudo ./install.sh)"
|
|
exit 1
|
|
fi
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
# ── Vérification des dépendances ───────────────────────────────────────────
|
|
info "Vérification des dépendances…"
|
|
|
|
deps=(python python-gobject gtk4 libadwaita pacman-contrib)
|
|
|
|
# Active l'intégration Secure Boot si une paire de clés MOK existe déjà.
|
|
secure_boot_configured=false
|
|
if [[ -r /root/secureboot-mok/MOK.key && -r /root/secureboot-mok/MOK.crt ]]; then
|
|
secure_boot_configured=true
|
|
deps+=(grub shim-signed sbsigntools)
|
|
fi
|
|
missing=()
|
|
for dep in "${deps[@]}"; do
|
|
if ! pacman -Qi "$dep" &>/dev/null; then
|
|
missing+=("$dep")
|
|
fi
|
|
done
|
|
|
|
if [[ ${#missing[@]} -gt 0 ]]; then
|
|
warn "Paquets manquants : ${missing[*]}"
|
|
info "Installation des dépendances…"
|
|
pacman -S --noconfirm --needed "${missing[@]}"
|
|
fi
|
|
|
|
# ── Installation des fichiers ──────────────────────────────────────────────
|
|
info "Installation des fichiers…"
|
|
|
|
# Bibliothèques Python
|
|
install -d /usr/lib/cachyos-updater
|
|
install -m 644 "$SCRIPT_DIR"/lib/*.py /usr/lib/cachyos-updater/
|
|
|
|
# Exécutables
|
|
install -m 755 "$SCRIPT_DIR"/bin/cachyos-updater /usr/bin/cachyos-updater
|
|
install -m 755 "$SCRIPT_DIR"/bin/cachyos-updater-ui /usr/bin/cachyos-updater-ui
|
|
install -m 755 "$SCRIPT_DIR"/bin/cachyos-updater-shutdown /usr/bin/cachyos-updater-shutdown
|
|
|
|
if $secure_boot_configured; then
|
|
install -d /usr/local/sbin /etc/pacman.d/hooks
|
|
install -m 750 \
|
|
"$SCRIPT_DIR"/secureboot/secureboot-sign-cachyos \
|
|
/usr/local/sbin/secureboot-sign-cachyos
|
|
install -m 644 \
|
|
"$SCRIPT_DIR"/secureboot/99-secureboot-sign-cachyos.hook \
|
|
/etc/pacman.d/hooks/99-secureboot-sign-cachyos.hook
|
|
info "Intégration Secure Boot installée"
|
|
else
|
|
warn "Clés MOK absentes : intégration Secure Boot non installée"
|
|
fi
|
|
|
|
# Unités systemd
|
|
install -m 644 "$SCRIPT_DIR"/systemd/cachyos-updater.service \
|
|
/usr/lib/systemd/system/cachyos-updater.service
|
|
install -m 644 "$SCRIPT_DIR"/systemd/cachyos-updater.timer \
|
|
/usr/lib/systemd/system/cachyos-updater.timer
|
|
install -m 644 "$SCRIPT_DIR"/systemd/cachyos-updater-shutdown.service \
|
|
/usr/lib/systemd/system/cachyos-updater-shutdown.service
|
|
|
|
# Icône
|
|
install -d /usr/share/icons/hicolor/scalable/apps
|
|
install -m 644 "$SCRIPT_DIR"/data/cachyos-updater.svg \
|
|
/usr/share/icons/hicolor/scalable/apps/cachyos-updater.svg
|
|
gtk-update-icon-cache -f -t /usr/share/icons/hicolor &>/dev/null || true
|
|
|
|
# Fichier .desktop
|
|
install -m 644 "$SCRIPT_DIR"/data/cachyos-updater.desktop \
|
|
/usr/share/applications/cachyos-updater.desktop
|
|
|
|
# Répertoire de données
|
|
install -d -m 755 /var/lib/cachyos-updater
|
|
|
|
# ── Activation des services ────────────────────────────────────────────────
|
|
info "Configuration des services systemd…"
|
|
|
|
systemctl daemon-reload
|
|
|
|
# Activer le timer (démarrage automatique au boot)
|
|
systemctl enable --now cachyos-updater.timer
|
|
info "Timer activé : vérification au démarrage puis toutes les heures"
|
|
|
|
# Récrée les liens pour migrer les anciennes installations qui ciblaient
|
|
# directement poweroff.target/reboot.target, puis arme ExecStop.
|
|
systemctl reenable --now cachyos-updater-shutdown.service
|
|
systemctl start cachyos-updater-shutdown.service
|
|
info "Service shutdown activé : installation des mises à jour reportées à l'extinction"
|
|
|
|
# ── Résumé ─────────────────────────────────────────────────────────────────
|
|
echo ""
|
|
echo -e "${GREEN}Installation terminée !${NC}"
|
|
echo ""
|
|
echo " • Les mises à jour sont vérifiées automatiquement toutes les heures"
|
|
echo " • Les paquets sûrs sont installés en arrière-plan sans interruption"
|
|
echo " • Les mises à jour nécessitant un redémarrage (kernel, systemd…)"
|
|
echo " seront installées automatiquement à la prochaine extinction du PC"
|
|
echo ""
|
|
echo " Interface graphique : cachyos-updater-ui"
|
|
echo " Journaux daemon : journalctl -u cachyos-updater -f"
|
|
echo " Journaux shutdown : journalctl -u cachyos-updater-shutdown"
|
|
echo ""
|