#!/bin/bash # Kubuntu Package Installer # Installs: LibreOffice, FreeCAD, VLC, Thunderbird, Firefox, # Timeshift, configures automatic updates + pre-apt snapshots, # SDDM auto-login, and Plymouth bgrt boot splash # ------------------------------------------------------------- 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 \ plymouth \ plymouth-themes \ hplip \ hplip-gui \ printer-driver-hpcups \ cups \ system-config-printer \ k3b \ k3b-data \ libk3b7-extracodecs # ------------------------------------------------------------- # 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 <" echo " sudo update-grub" echo "" echo " To list available themes:" echo " plymouth-set-default-theme --list" # ------------------------------------------------------------- # HPLIP: HP printer driver setup # ------------------------------------------------------------- echo "" echo "Configuring HP printer support (HPLIP)..." # Enable and start CUPS (print spooler) sudo systemctl enable cups sudo systemctl start cups # Add current user to the 'lpadmin' group for printer management sudo usermod -aG lpadmin "$CURRENT_USER" echo "HP printer support configured." echo "" echo " To set up your HP printer, run one of:" echo " hp-setup (terminal wizard)" echo " hp-setup -u (GUI wizard — recommended)" echo "" echo " For proprietary plugin printers (e.g. some LaserJet models):" echo " sudo hp-plugin (downloads and installs the binary plugin)" echo "" echo " Printer management UI (CUPS web interface):" echo " http://localhost:631" echo "" echo " NOTE: Log out and back in for the lpadmin group to take effect." # ------------------------------------------------------------- # 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 to take effect."