chore(install): added install script for basic linux preperation

This commit is contained in:
2026-04-03 11:30:28 +02:00
commit 2aa1459b15
+156
View File
@@ -0,0 +1,156 @@
#!/bin/bash
# Kubuntu Package Installer
# Installs: LibreOffice, FreeCAD, VLC, Thunderbird, Firefox,
# Timeshift, configures automatic updates + pre-apt snapshots,
# and enables SDDM auto-login for the current user
# -------------------------------------------------------------
set -e
# Capture the user running the script (works even under sudo)
CURRENT_USER="${SUDO_USER:-$USER}"
echo "Updating package lists..."
sudo apt update && sudo apt upgrade -y
echo "Installing packages..."
sudo apt install -y \
libreoffice \
libreoffice-l10n-de \
libreoffice-kde \
freecad \
vlc \
vlc-plugin-access-extra \
vlc-plugin-notify \
thunderbird \
firefox \
ubuntu-restricted-extras \
ffmpeg \
ttf-mscorefonts-installer \
timeshift \
unattended-upgrades \
apt-listchanges
# -------------------------------------------------------------
# Auto-updates: configure unattended-upgrades
# -------------------------------------------------------------
echo ""
echo "Configuring automatic updates..."
sudo dpkg-reconfigure --priority=low unattended-upgrades
sudo tee /etc/apt/apt.conf.d/50unattended-upgrades > /dev/null <<'EOF'
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}";
"${distro_id}:${distro_codename}-security";
"${distro_id}ESMApps:${distro_codename}-apps-security";
"${distro_id}ESM:${distro_codename}-infra-security";
"${distro_id}:${distro_codename}-updates";
};
// Automatically reboot if required (e.g. kernel update) — set to true if desired
Unattended-Upgrade::Automatic-Reboot "false";
Unattended-Upgrade::Automatic-Reboot-Time "03:00";
// Remove unused kernel packages after upgrade
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
// Remove unused dependencies
Unattended-Upgrade::Remove-Unused-Dependencies "true";
// Send email on errors (optional — replace with your address or leave empty)
// Unattended-Upgrade::Mail "you@example.com";
// Unattended-Upgrade::MailReport "on-change";
EOF
sudo tee /etc/apt/apt.conf.d/20auto-upgrades > /dev/null <<'EOF'
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";
EOF
echo "Auto-updates configured."
# -------------------------------------------------------------
# Timeshift pre-apt hook
# Creates a snapshot automatically before any apt install/upgrade
# -------------------------------------------------------------
echo ""
echo "Installing Timeshift pre-apt snapshot hook..."
sudo tee /usr/local/bin/timeshift-pre-apt.sh > /dev/null <<'EOF'
#!/bin/bash
# Auto-snapshot before apt operations
LOGFILE="/var/log/timeshift-auto.log"
TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$TIMESTAMP] apt operation detected — creating Timeshift snapshot..." | tee -a "$LOGFILE"
if ! command -v timeshift &>/dev/null; then
echo "[$TIMESTAMP] WARNING: timeshift not found, skipping snapshot." | tee -a "$LOGFILE"
exit 0
fi
if ! timeshift --list &>/dev/null; then
echo "[$TIMESTAMP] WARNING: Timeshift not configured yet, skipping snapshot." | tee -a "$LOGFILE"
exit 0
fi
timeshift --create --comments "auto: pre-apt $(date '+%Y-%m-%d %H:%M')" --tags D 2>&1 | tee -a "$LOGFILE"
echo "[$TIMESTAMP] Snapshot complete." | tee -a "$LOGFILE"
EOF
sudo chmod +x /usr/local/bin/timeshift-pre-apt.sh
sudo tee /etc/apt/apt.conf.d/80timeshift-pre-apt > /dev/null <<'EOF'
DPkg::Pre-Invoke { "/usr/local/bin/timeshift-pre-apt.sh"; };
EOF
echo "Timeshift pre-apt hook installed."
echo " Hook script: /usr/local/bin/timeshift-pre-apt.sh"
echo " apt config: /etc/apt/apt.conf.d/80timeshift-pre-apt"
echo " Log file: /var/log/timeshift-auto.log"
# -------------------------------------------------------------
# SDDM auto-login for current user
# -------------------------------------------------------------
echo ""
echo "Configuring SDDM auto-login for user: $CURRENT_USER"
sudo mkdir -p /etc/sddm.conf.d
sudo tee /etc/sddm.conf.d/autologin.conf > /dev/null <<EOF
[Autologin]
User=$CURRENT_USER
Session=plasma
Relogin=false
EOF
echo "SDDM auto-login configured."
echo " Config file: /etc/sddm.conf.d/autologin.conf"
echo " User: $CURRENT_USER"
echo " Session: plasma"
echo ""
echo " To disable auto-login later, run:"
echo " sudo rm /etc/sddm.conf.d/autologin.conf"
# -------------------------------------------------------------
# Timeshift: installed — manual setup required
# -------------------------------------------------------------
echo ""
echo "--------------------------------------------------------------"
echo " NEXT STEP: Configure Timeshift manually (required once)"
echo "--------------------------------------------------------------"
echo " Run: sudo timeshift-gtk"
echo " Recommended settings:"
echo " - Snapshot type: RSYNC (works on any filesystem)"
echo " OR BTRFS if your root partition uses btrfs"
echo " - Schedule: Daily + keep 5, Weekly + keep 2"
echo " - Include: / (root) — exclude /home if space is tight"
echo ""
echo " The pre-apt hook will SKIP snapshots until Timeshift is"
echo " configured with a valid snapshot location."
echo "--------------------------------------------------------------"
echo ""
echo "All done! Reboot for all changes (including auto-login) to take effect."