Files
fluffy-pancake/files/etc/skel/.config/firstboot/firstboot-setup.sh
T
2026-03-12 21:09:19 +01:00

318 lines
10 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
DIALOG=dialog
HEIGHT=20
WIDTH=74
LOG="$HOME/.local/state/firstboot-setup.log"
if [[ -z "${TERM:-}" ]]; then
exec cosmic-terminal -- "$HOME/.config/firstboot/firstboot-user.sh"
fi
exec > >(tee -a "$LOG") 2>&1
abort() {
$DIALOG --title "Setup abbrechen?" --yesno \
"Der EinrichtungsAssistent wird dann
nicht erneut angezeigt.
Alle Anwendungen können jederzeit
über den COSMICShop installiert
oder entfernt werden.
Möchtest du den SetupAssistenten
wirklich abbrechen?" \
$HEIGHT $WIDTH
if [[ $? -eq 0 ]]; then
rm -f "$HOME/.config/firstboot/run"
systemctl --user disable firstboot-setup.service
clear
exit 0
fi
fi
# User hat sich gegen Abbruch entschieden → zurück
return 0
}
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
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
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
}
# ----------------------------
# Welcome
# ----------------------------
$DIALOG --title "Willkommen bei COSMIC" --msgbox \
"Dieser Assistent erleichtert dir den Einstieg,
indem er eine Auswahl gängiger Anwendungen anbietet.
Wichtig:
• Alle hier angebotenen Anwendungen können
jederzeit auch über den COSMICShop installiert
oder entfernt werden.
• Der Wizard ist optional und kann komplett
übersprungen werden.
• Er deckt nur eine Auswahl verbreiteter
Anwendungen ab nicht alles.
Nach Abschluss wird dieser Assistent
nicht erneut angezeigt." \
$HEIGHT $WIDTH || abort
# ----------------------------
# Selections
# ----------------------------
BROWSERS=()
OFFICE=()
GRAPHICS=()
MEDIA=()
AV=()
GAMES=()
MAIL=()
DEV=()
SYSTEM=()
# ----------------------------
# Browser
# ----------------------------
BROWSERS=($($DIALOG --title "Browser" --checklist \
"Webbrowser werden für viele Aufgaben benötigt
(z.B. Dokumentation, WebApps, LoginFlows)." \
$HEIGHT $WIDTH 5 \
"firefox" "Mozilla Firefox (empfohlen)" ON \
"chromium" "Chromium (OpenSource Basis)" OFF \
"brave" "Brave (datenschutzorientiert)" OFF \
2>&1 >/dev/tty)) || abort
# ----------------------------
# Office
# ----------------------------
OFFICE=($($DIALOG --title "Office & Dokumente" --checklist \
"Anwendungen für Dokumente, PDFs und Büroarbeit:" \
$HEIGHT $WIDTH 7 \
"libreoffice" "LibreOffice (OfficeSuite)" ON \
"onlyoffice" "OnlyOffice (MSOffice‑ähnlich)" OFF \
"collabora" "Collabora Office (LibreOfficebasiert)" OFF \
"papers" "Papers (PDFViewer)" ON \
"simplescan" "Simple Scan (ScannerAnwendung)" OFF \
2>&1 >/dev/tty)) || abort
# ----------------------------
# Graphics
# ----------------------------
GRAPHICS=($($DIALOG --title "Grafik & Kreativ" --checklist \
"Bildbearbeitung, Illustration und Vektorgrafik:" \
$HEIGHT $WIDTH 5 \
"gimp" "GIMP (Bildbearbeitung)" OFF \
"krita" "Krita (Zeichnen & Illustration)" OFF \
"inkscape" "Inkscape (Vektorgrafiken & SVG)" OFF \
2>&1 >/dev/tty)) || abort
# ----------------------------
# Media
# ----------------------------
MEDIA=($($DIALOG --title "Medien & Unterhaltung" --checklist \
"Wiedergabe von Audio und Video:" \
$HEIGHT $WIDTH 4 \
"vlc" "VLC Media Player" ON \
"spotify" "Spotify Client" OFF \
2>&1 >/dev/tty)) || abort
# ----------------------------
# Audio / Video Editing
# ----------------------------
AV=($($DIALOG --title "Audio & VideoBearbeitung" --checklist \
"Erstellung und Bearbeitung von Audio und Videoinhalten:" \
$HEIGHT $WIDTH 6 \
"shotcut" "Shotcut (einfacher VideoEditor)" OFF \
"kdenlive" "Kdenlive (leistungsfähiger VideoEditor)" OFF \
"audacity" "Audacity (AudioBearbeitung)" OFF \
"ardour" "Ardour (professionelle AudioProduktion)" OFF \
2>&1 >/dev/tty)) || abort
# ----------------------------
# Games
# ----------------------------
GAMES=($($DIALOG --title "Spiele" --checklist \
"Plattformen für PCSpiele.
Hinweis:
• Für Steam und Lutris ist ein Benutzerkonto erforderlich.
• Es werden keine Spiele automatisch installiert." \
$HEIGHT $WIDTH 4 \
"steam" "Steam (ValvePlattform)" OFF \
"lutris" "Lutris (MultiPlattformLauncher)" OFF \
2>&1 >/dev/tty)) || abort
# ----------------------------
# Mail
# ----------------------------
MAIL=($($DIALOG --title "EMail" --checklist \
"DesktopEMailProgramme für IMAP/POPKonten:" \
$HEIGHT $WIDTH 5 \
"thunderbird" "Thunderbird (vollständiger StandardClient)" ON \
"geary" "Geary (einfacher, moderner MailClient)" OFF \
"evolution" "Evolution (Business & ExchangeClient)" OFF \
2>&1 >/dev/tty)) || abort
# ----------------------------
# Development
# ----------------------------
DEV=($($DIALOG --title "Entwicklung" --checklist \
"Werkzeuge für SoftwareEntwicklung:" \
$HEIGHT $WIDTH 4 \
"vscode" "Visual Studio Code" OFF \
2>&1 >/dev/tty)) || abort
# ----------------------------
# System Tools
# ----------------------------
SYSTEM=($($DIALOG --title "SystemWerkzeuge" --checklist \
"Hilfsprogramme für SystemKonfiguration:" \
$HEIGHT $WIDTH 4 \
"flatseal" "Flatseal (FlatpakRechte verwalten)" OFF \
2>&1 >/dev/tty)) || abort
# ----------------------------
# Homebrew
# ----------------------------
USE_BREW=$($DIALOG --title "Homebrew (optional)" --yesno \
"Homebrew ist ein zusätzlicher Paketmanager
für Entwickler und CLIWerkzeuge.
• Installation im Benutzerverzeichnis
• Keine Änderung am Basissystem
• Komplett optional" \
$HEIGHT $WIDTH && echo yes || echo no)
# ----------------------------
# Summary
# ----------------------------
SUMMARY="Browser: ${BROWSERS[*]:-keine}
Office: ${OFFICE[*]:-keine}
Grafik: ${GRAPHICS[*]:-keine}
Medien: ${MEDIA[*]:-keine}
Audio/Video: ${AV[*]:-keine}
Spiele: ${GAMES[*]:-keine}
EMail: ${MAIL[*]:-keine}
Entwicklung: ${DEV[*]:-keine}
System: ${SYSTEM[*]:-keine}
Homebrew: $USE_BREW"
$DIALOG --title "Zusammenfassung" --yesno \
"Bitte bestätige die Installation:\n\n$SUMMARY" \
$HEIGHT $WIDTH || abort
# ----------------------------
# Installation
# ----------------------------
ensure_flathub
(
echo "10"; echo "# Installiere Browser..."
for b in "${BROWSERS[@]}"; do
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..."
[[ " ${OFFICE[*]} " == *" libreoffice "* ]] && flatpak install -y flathub org.libreoffice.LibreOffice
[[ " ${OFFICE[*]} " == *" onlyoffice "* ]] && flatpak install -y flathub org.onlyoffice.desktopeditors
[[ " ${OFFICE[*]} " == *" collabora "* ]] && flatpak install -y flathub com.collabora.CollaboraOffice
[[ " ${OFFICE[*]} " == *" papers "* ]] && flatpak install -y flathub org.gnome.Papers
[[ " ${OFFICE[*]} " == *" simplescan "* ]] && flatpak install -y flathub org.gnome.SimpleScan
echo "40"; echo "# Installiere GrafikTools..."
[[ " ${GRAPHICS[*]} " == *" gimp "* ]] && flatpak install -y flathub org.gimp.GIMP
[[ " ${GRAPHICS[*]} " == *" krita "* ]] && flatpak install -y flathub org.kde.krita
[[ " ${GRAPHICS[*]} " == *" inkscape "* ]] && flatpak install -y flathub org.inkscape.Inkscape
echo "55"; echo "# Installiere Medien..."
[[ " ${MEDIA[*]} " == *" vlc "* ]] && flatpak install -y flathub org.videolan.VLC
[[ " ${MEDIA[*]} " == *" spotify "* ]] && flatpak install -y flathub com.spotify.Client
echo "70"; echo "# Installiere Audio/VideoTools..."
[[ " ${AV[*]} " == *" shotcut "* ]] && flatpak install -y flathub org.shotcut.Shotcut
[[ " ${AV[*]} " == *" kdenlive "* ]] && flatpak install -y flathub org.kde.kdenlive
[[ " ${AV[*]} " == *" audacity "* ]] && flatpak install -y flathub org.audacityteam.Audacity
[[ " ${AV[*]} " == *" ardour "* ]] && flatpak install -y flathub org.ardour.Ardour
echo "85"; echo "# Installiere SpielePlattformen..."
[[ " ${GAMES[*]} " == *" steam "* ]] && flatpak install -y flathub com.valvesoftware.Steam
[[ " ${GAMES[*]} " == *" lutris "* ]] && flatpak install -y flathub net.lutris.Lutris
echo "90"; echo "# Installiere EMailClients..."
[[ " ${MAIL[*]} " == *" thunderbird "* ]] && flatpak install -y flathub org.mozilla.Thunderbird
[[ " ${MAIL[*]} " == *" geary "* ]] && flatpak install -y flathub org.gnome.Geary
[[ " ${MAIL[*]} " == *" evolution "* ]] && flatpak install -y flathub org.gnome.Evolution
echo "95"; echo "# Installiere Entwicklung..."
[[ " ${DEV[*]} " == *" vscode "* ]] && flatpak install -y flathub com.visualstudio.code
echo "97"; echo "# Installiere SystemTools..."
[[ " ${SYSTEM[*]} " == *" flatseal "* ]] && flatpak install -y flathub com.github.tchx84.Flatseal
echo "98"; echo "# Homebrew..."
[[ "$USE_BREW" == yes ]] && install_brew_and_setup_path
echo "100"; echo "# Fertig."
) | $DIALOG --title "Installation läuft" --gauge \
"Bitte warten..." \
$HEIGHT $WIDTH 0
# ----------------------------
# Mark wizard as done
# ----------------------------
rm -f "$HOME/.config/firstboot/run"
systemctl --user disable firstboot-user.service
$DIALOG --title "Fertig" --msgbox \
"Die Einrichtung ist abgeschlossen.
Weitere Anwendungen kannst du jederzeit
über den COSMICShop installieren.
Updates:
• Installierte Anwendungen werden über den COSMICShop aktualisiert.
• HomebrewPakete können mit folgendem Befehl aktualisiert werden:
>>>>> brew update && brew upgrade <<<<<
Der SetupWizard wird nicht erneut gestartet." \
$HEIGHT $WIDTH
clear