Files
fluffy-pancake/files/etc/skel/.config/firstboot/firstboot-setup.sh
T

355 lines
10 KiB
Bash
Raw Normal View History

2026-03-12 20:54:23 +01:00
#!/usr/bin/env bash
set -euo pipefail
2026-03-12 21:09:19 +01:00
LOG="$HOME/.local/state/firstboot-setup.log"
mkdir -p "$(dirname "$LOG")"
2026-03-12 20:54:23 +01:00
exec > >(tee -a "$LOG") 2>&1
# ----------------------------
# Session check
# ----------------------------
if [[ -z "${WAYLAND_DISPLAY:-}" && -z "${DISPLAY:-}" ]]; then
echo "Keine grafische Session verfügbar breche ab."
exit 1
fi
# ----------------------------
# Cleanup trap (nur bei Fehlern)
# ----------------------------
cleanup() {
local code=$?
if [[ $code -ne 0 ]]; then
echo "Wizard abgebrochen oder mit Fehler beendet (Exitcode: $code)."
rm -f "$HOME/.config/firstboot/run"
systemctl --user disable firstboot-setup.service || true
fi
}
trap cleanup EXIT
# ----------------------------
# Abort dialog
# ----------------------------
2026-03-12 20:54:23 +01:00
abort() {
local code=$?
echo "Abort ausgelöst (Exitcode: $code)."
2026-03-13 10:04:21 +01:00
zenity --question \
--title="Setup abbrechen?" \
--text="<big><b>Setup abbrechen?</b></big>\n
Der Einrichtungs-Assistent wird dann nicht erneut angezeigt.\n
Alle Anwendungen können jederzeit über den COSMIC-Shop installiert oder entfernt werden.\n
Möchtest du den Setup-Assistenten wirklich abbrechen?" || return 0
2026-03-12 20:54:23 +01:00
exit 0
2026-03-12 20:54:23 +01:00
}
# ----------------------------
# Helper functions
# ----------------------------
2026-03-12 20:54:23 +01:00
ensure_flathub() {
flatpak remote-list --columns=name 2>/dev/null | grep -qx flathub || \
flatpak remote-add --if-not-exists flathub \
https://dl.flathub.org/repo/flathub.flatpakrepo
}
install_brew_and_setup_path() {
if ! command -v brew >/dev/null 2>&1; then
NONINTERACTIVE=1 CI=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2026-03-12 20:54:23 +01:00
fi
local BREW_PREFIX="/home/linuxbrew/.linuxbrew"
local BREW_BIN="$BREW_PREFIX/bin/brew"
[[ -x "$BREW_BIN" ]] || BREW_BIN="$(command -v brew)"
eval "$("$BREW_BIN" shellenv)"
for rc in "$HOME/.bashrc" "$HOME/.zshrc"; do
[[ -f "$rc" ]] || continue
grep -q 'brew shellenv' "$rc" || {
echo "" >> "$rc"
echo "# Homebrew" >> "$rc"
echo "eval \"\$($BREW_BIN shellenv)\"" >> "$rc"
}
done
}
2026-03-13 10:04:21 +01:00
choose_list() {
local title="$1"
local text="$2"
shift 2
local result
result=$(zenity --list \
--title="$title" \
--text="$text" \
--checklist \
--column="Auswahl" \
--column="ID" \
--column="Beschreibung" \
FALSE "$@" \
--separator="|" \
) || abort
echo "${result:-}"
2026-03-13 10:04:21 +01:00
}
2026-03-12 20:54:23 +01:00
# ----------------------------
# Welcome
# ----------------------------
zenity --info \
--title="Willkommen bei COSMIC" \
--text="<big><b>Willkommen bei COSMIC</b></big>\n
Dieser Assistent hilft dir beim Einstieg in dein System.\n
<b>Hinweise:</b>\n
• Alle Anwendungen können später jederzeit über den COSMIC-Shop installiert oder entfernt werden.\n
• Der Assistent ist optional und erscheint nur einmal.\n
• Die Auswahl deckt gängige Anwendungen ab, aber nicht alles." \
|| abort
# ----------------------------
# Auswahl
2026-03-12 20:54:23 +01:00
# ----------------------------
2026-03-13 10:04:21 +01:00
BROWSERS=$(choose_list \
"Browser" \
"<big><b>Browser auswählen</b></big>\nWähle einen oder mehrere Webbrowser aus." \
2026-03-13 10:04:21 +01:00
firefox "Mozilla Firefox (empfohlen)" \
chromium "Chromium (Open-Source Basis)" \
2026-03-13 10:04:21 +01:00
brave "Brave (datenschutzorientiert)" \
)
2026-03-12 20:54:23 +01:00
2026-03-13 10:04:21 +01:00
OFFICE=$(choose_list \
"Office & Dokumente" \
"<big><b>Office & Dokumente</b></big>\nWähle Anwendungen für Büroarbeit und PDFs." \
libreoffice "LibreOffice (Office-Suite)" \
onlyoffice "OnlyOffice (MS-Office-ähnlich)" \
2026-03-13 10:04:21 +01:00
collabora "Collabora Office" \
papers "Papers (PDF-Viewer)" \
2026-03-13 10:04:21 +01:00
simplescan "Simple Scan" \
)
2026-03-12 20:54:23 +01:00
2026-03-13 10:04:21 +01:00
GRAPHICS=$(choose_list \
"Grafik & Kreativ" \
"<big><b>Grafik & Kreativ</b></big>\nWerkzeuge für Bildbearbeitung und Illustration." \
2026-03-13 10:04:21 +01:00
gimp "GIMP" \
krita "Krita" \
inkscape "Inkscape" \
)
2026-03-12 20:54:23 +01:00
2026-03-13 10:04:21 +01:00
MEDIA=$(choose_list \
"Medien & Unterhaltung" \
"<big><b>Medien & Unterhaltung</b></big>\nAudio- und Video-Wiedergabe." \
2026-03-13 10:04:21 +01:00
vlc "VLC Media Player" \
showtime "Gnome Video Player" \
2026-03-13 10:04:21 +01:00
spotify "Spotify Client" \
)
2026-03-12 20:54:23 +01:00
2026-03-13 10:04:21 +01:00
AV=$(choose_list \
"Audio & Video-Bearbeitung" \
"<big><b>Audio & Video-Bearbeitung</b></big>\nWerkzeuge für kreative Medienproduktion." \
2026-03-13 10:04:21 +01:00
shotcut "Shotcut" \
kdenlive "Kdenlive" \
audacity "Audacity" \
ardour "Ardour" \
)
2026-03-12 20:54:23 +01:00
2026-03-13 10:04:21 +01:00
GAMES=$(choose_list \
"Spiele" \
"<big><b>Spiele-Plattformen</b></big>\nWähle Plattformen für PC-Spiele." \
2026-03-13 10:04:21 +01:00
steam "Steam" \
lutris "Lutris" \
)
2026-03-12 20:54:23 +01:00
2026-03-13 10:04:21 +01:00
MAIL=$(choose_list \
"E-Mail" \
"<big><b>E-Mail-Programme</b></big>\nWähle einen oder mehrere Mail-Clients." \
2026-03-13 10:04:21 +01:00
thunderbird "Thunderbird" \
geary "Geary" \
evolution "Evolution" \
)
2026-03-12 20:54:23 +01:00
2026-03-13 10:04:21 +01:00
DEV=$(choose_list \
"Entwicklung" \
"<big><b>Entwicklung</b></big>\nWerkzeuge für Software-Entwicklung." \
2026-03-13 10:04:21 +01:00
vscode "Visual Studio Code" \
)
2026-03-12 20:54:23 +01:00
2026-03-13 10:04:21 +01:00
SYSTEM=$(choose_list \
"System-Werkzeuge" \
"<big><b>System-Werkzeuge</b></big>\nHilfsprogramme für Konfiguration und Verwaltung." \
2026-03-13 10:04:21 +01:00
flatseal "Flatseal" \
)
2026-03-12 20:54:23 +01:00
# ----------------------------
# Homebrew
# ----------------------------
2026-03-13 10:04:21 +01:00
zenity --question \
--title="Homebrew (optional)" \
--text="<big><b>Homebrew installieren?</b></big>\n
Homebrew ist ein zusätzlicher Paketmanager für Entwickler- und CLI-Werkzeuge.\n
• Installation im Benutzerverzeichnis\n
• Keine Änderung am Basissystem\n
• Komplett optional"
2026-03-13 10:04:21 +01:00
USE_BREW=$([[ $? -eq 0 ]] && echo yes || echo no)
2026-03-12 20:54:23 +01:00
2026-03-13 10:20:03 +01:00
# ----------------------------
# Auto-Update
2026-03-13 10:20:03 +01:00
# ----------------------------
zenity --question \
--title="Automatische Systemaktualisierung" \
--text="<big><b>Automatische Updates aktivieren?</b></big>\n
Wenn aktiviert, prüft das System einmal pro Woche auf neue Aktualisierungen und installiert sie automatisch.\n
<b>Manuelle Aktualisierung:</b>\n
<tt>bootc upgrade</tt>\n
<b>Dienst manuell starten:</b>\n
<tt>systemctl --user start bootc-update.service</tt>"
2026-03-13 10:20:03 +01:00
AUTO_UPDATE=$([[ $? -eq 0 ]] && echo yes || echo no)
2026-03-12 20:54:23 +01:00
# ----------------------------
# Summary
# ----------------------------
2026-03-13 10:04:21 +01:00
SUMMARY="Browser: ${BROWSERS:-keine}
Office: ${OFFICE:-keine}
Grafik: ${GRAPHICS:-keine}
Medien: ${MEDIA:-keine}
Audio/Video: ${AV:-keine}
Spiele: ${GAMES:-keine}
E-Mail: ${MAIL:-keine}
2026-03-13 10:04:21 +01:00
Entwicklung: ${DEV:-keine}
System: ${SYSTEM:-keine}
2026-03-12 20:54:23 +01:00
2026-03-13 10:20:03 +01:00
Homebrew: $USE_BREW
Automatische Updates: $AUTO_UPDATE"
2026-03-13 10:04:21 +01:00
zenity --question \
--title="Zusammenfassung" \
--text="<big><b>Bitte bestätige die Installation</b></big>\n\n$SUMMARY" \
2026-03-13 10:04:21 +01:00
|| abort
2026-03-12 20:54:23 +01:00
# ----------------------------
# Installation
# ----------------------------
ensure_flathub
(
echo "10"; echo "# Installiere Browser..."
2026-03-13 10:04:21 +01:00
for b in ${BROWSERS//|/ }; do
[[ -z "$b" ]] && continue
2026-03-12 20:54:23 +01:00
case "$b" in
firefox) flatpak install -y flathub org.mozilla.firefox ;;
chromium) flatpak install -y flathub org.chromium.Chromium ;;
brave) flatpak install -y flathub com.brave.Browser ;;
esac
done
echo "25"; echo "# Installiere Office..."
for o in ${OFFICE//|/ }; do
[[ -z "$o" ]] && continue
case "$o" in
libreoffice) flatpak install -y flathub org.libreoffice.LibreOffice ;;
onlyoffice) flatpak install -y flathub org.onlyoffice.desktopeditors ;;
collabora) flatpak install -y flathub com.collabora.CollaboraOffice ;;
papers) flatpak install -y flathub org.gnome.Papers ;;
simplescan) flatpak install -y flathub org.gnome.SimpleScan ;;
esac
done
2026-03-12 20:54:23 +01:00
echo "40"; echo "# Installiere Grafik-Tools..."
for g in ${GRAPHICS//|/ }; do
[[ -z "$g" ]] && continue
case "$g" in
gimp) flatpak install -y flathub org.gimp.GIMP ;;
krita) flatpak install -y flathub org.kde.krita ;;
inkscape) flatpak install -y flathub org.inkscape.Inkscape ;;
esac
done
2026-03-12 20:54:23 +01:00
echo "55"; echo "# Installiere Medien..."
for m in ${MEDIA//|/ }; do
[[ -z "$m" ]] && continue
case "$m" in
vlc) flatpak install -y flathub org.videolan.VLC ;;
spotify) flatpak install -y flathub com.spotify.Client ;;
showtime) flatpak install -y flathub org.gnome.Showtime ;;
esac
done
2026-03-13 10:20:03 +01:00
echo "70"; echo "# Installiere Audio/Video-Tools..."
for a in ${AV//|/ }; do
[[ -z "$a" ]] && continue
case "$a" in
shotcut) flatpak install -y flathub org.shotcut.Shotcut ;;
kdenlive) flatpak install -y flathub org.kde.kdenlive ;;
audacity) flatpak install -y flathub org.audacityteam.Audacity ;;
ardour) flatpak install -y flathub org.ardour.Ardour ;;
esac
done
2026-03-12 20:54:23 +01:00
echo "85"; echo "# Installiere Spiele-Plattformen..."
for g in ${GAMES//|/ }; do
[[ -z "$g" ]] && continue
case "$g" in
steam) flatpak install -y flathub com.valvesoftware.Steam ;;
lutris) flatpak install -y flathub net.lutris.Lutris ;;
esac
done
2026-03-12 20:54:23 +01:00
echo "90"; echo "# Installiere E-Mail-Clients..."
for m in ${MAIL//|/ }; do
[[ -z "$m" ]] && continue
case "$m" in
thunderbird) flatpak install -y flathub org.mozilla.Thunderbird ;;
geary) flatpak install -y flathub org.gnome.Geary ;;
evolution) flatpak install -y flathub org.gnome.Evolution ;;
esac
done
2026-03-12 20:54:23 +01:00
echo "95"; echo "# Installiere Entwicklung..."
for d in ${DEV//|/ }; do
[[ -z "$d" ]] && continue
case "$d" in
vscode) flatpak install -y flathub com.visualstudio.code ;;
esac
done
2026-03-12 20:54:23 +01:00
echo "97"; echo "# Installiere System-Werkzeuge..."
for s in ${SYSTEM//|/ }; do
[[ -z "$s" ]] && continue
case "$s" in
flatseal) flatpak install -y flathub com.github.tchx84.Flatseal ;;
esac
done
2026-03-12 20:54:23 +01:00
echo "98"; echo "# Homebrew..."
[[ "$USE_BREW" == yes ]] && install_brew_and_setup_path
echo "100"; echo "# Fertig."
2026-03-13 10:04:21 +01:00
) | zenity --progress \
--title="Installation läuft" \
--text="Bitte warten..." \
--percentage=0 \
--auto-close
2026-03-12 20:54:23 +01:00
2026-03-13 10:20:03 +01:00
# ----------------------------
# Auto-Update aktivieren
2026-03-13 10:20:03 +01:00
# ----------------------------
if [[ "$AUTO_UPDATE" == yes ]]; then
systemctl --user enable --now bootc-update.timer
fi
2026-03-12 20:54:23 +01:00
# ----------------------------
# Wizard done (sauberer Abschluss)
2026-03-12 20:54:23 +01:00
# ----------------------------
trap - EXIT
2026-03-12 21:09:19 +01:00
rm -f "$HOME/.config/firstboot/run"
systemctl --user disable firstboot-setup.service || true
2026-03-12 21:09:19 +01:00
2026-03-13 10:04:21 +01:00
zenity --info \
--title="Fertig" \
--text="<big><b>Die Einrichtung ist abgeschlossen.</b></big>\n
Weitere Anwendungen kannst du jederzeit über den COSMIC-Shop installieren.\n
<b>Homebrew aktualisieren:</b>\n
<tt>brew update && brew upgrade</tt>\n
Der Setup-Assistent wird nicht erneut gestartet."