97 lines
3.8 KiB
Bash
Executable File
97 lines
3.8 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)
|
|
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
|
|
|
|
# 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"
|
|
|
|
# Activer le service de shutdown (installation avant extinction)
|
|
systemctl enable 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 ""
|