#!/bin/bash

# Script to add AILinux repositories to the apt sources list

# Check for root privileges
if [ "$(id -u)" -ne 0 ]; then
  echo "This script must be run as root" 1>&2
  exit 1
fi

# Repositories for amd64 and i386 (from local folders)
echo "Adding AILinux repositories..."

# Ubuntu Base Repositories
echo "deb [arch=amd64] file:///root/mirror/ubuntu/ noble main universe multiverse restricted" > /etc/apt/sources.list.d/ailinux.list
echo "deb [arch=i386] file:///root/mirror/ubuntu/ noble main universe multiverse restricted" >> /etc/apt/sources.list.d/ailinux.list

# Ubuntu Updates & Security
echo "deb [arch=amd64] file:///root/mirror/ubuntu/ noble-updates main universe multiverse restricted" >> /etc/apt/sources.list.d/ailinux.list
echo "deb [arch=i386] file:///root/mirror/ubuntu/ noble-updates main universe multiverse restricted" >> /etc/apt/sources.list.d/ailinux.list
echo "deb [arch=amd64] file:///root/mirror/ubuntu/ noble-security main universe multiverse restricted" >> /etc/apt/sources.list.d/ailinux.list
echo "deb [arch=i386] file:///root/mirror/ubuntu/ noble-security main universe multiverse restricted" >> /etc/apt/sources.list.d/ailinux.list

# KDE Neon
echo "deb [arch=amd64] file:///root/mirror/neon.kde.org/user noble main" >> /etc/apt/sources.list.d/ailinux.list
echo "deb [arch=i386] file:///root/mirror/neon.kde.org/user noble main" >> /etc/apt/sources.list.d/ailinux.list

# WineHQ
echo "deb [arch=amd64] file:///root/mirror/dl.winehq.org/wine-builds/ubuntu noble main" >> /etc/apt/sources.list.d/ailinux.list
echo "deb [arch=i386] file:///root/mirror/dl.winehq.org/wine-builds/ubuntu noble main" >> /etc/apt/sources.list.d/ailinux.list

# Kernel Mainline
echo "deb [arch=amd64] file:///root/mirror/kernel.ubuntu.com/~kernel-ppa/mainline/ daily-build main" >> /etc/apt/sources.list.d/ailinux.list
echo "deb [arch=i386] file:///root/mirror/kernel.ubuntu.com/~kernel-ppa/mainline/ daily-build main" >> /etc/apt/sources.list.d/ailinux.list

# Radeon Treiber
echo "deb [arch=amd64] file:///root/mirror/repo.radeon.com/amdgpu/apt/ubuntu noble main" >> /etc/apt/sources.list.d/ailinux.list
echo "deb [arch=i386] file:///root/mirror/repo.radeon.com/amdgpu/apt/ubuntu noble main" >> /etc/apt/sources.list.d/ailinux.list

# Google Chrome
echo "deb [arch=amd64] file:///root/mirror/dl.google.com/linux/chrome/deb stable main" >> /etc/apt/sources.list.d/ailinux.list

# LibreOffice Fresh
echo "deb [arch=amd64] file:///root/mirror/ppa.launchpadcontent.net/libreoffice/ppa/ubuntu noble main" >> /etc/apt/sources.list.d/ailinux.list
echo "deb [arch=i386] file:///root/mirror/ppa.launchpadcontent.net/libreoffice/ppa/ubuntu noble main" >> /etc/apt/sources.list.d/ailinux.list

# XFCE Desktop (aktuelle Version)
echo "deb [arch=amd64] file:///root/mirror/ppa.launchpadcontent.net/xubuntu-dev/staging/ubuntu noble main" >> /etc/apt/sources.list.d/ailinux.list
echo "deb [arch=i386] file:///root/mirror/ppa.launchpadcontent.net/xubuntu-dev/staging/ubuntu noble main" >> /etc/apt/sources.list.d/ailinux.list

# AILinux Repositories (using local mirror structure)
echo "deb [arch=amd64] file:///root/mirror/ailinux.me/mirror/main/ stable main contrib non-free" >> /etc/apt/sources.list.d/ailinux.list
echo "deb [arch=i386] file:///root/mirror/ailinux.me/mirror/main/ stable main contrib non-free" >> /etc/apt/sources.list.d/ailinux.list
echo "deb [arch=amd64] file:///root/mirror/ailinux.me/mirror/ai/ stable main" >> /etc/apt/sources.list.d/ailinux.list
echo "deb [arch=i386] file:///root/mirror/ailinux.me/mirror/ai/ stable main" >> /etc/apt/sources.list.d/ailinux.list
echo "deb [arch=amd64] file:///root/mirror/ailinux.me/mirror/apps/ stable main" >> /etc/apt/sources.list.d/ailinux.list
echo "deb [arch=i386] file:///root/mirror/ailinux.me/mirror/apps/ stable main" >> /etc/apt/sources.list.d/ailinux.list

echo "AILinux repositories added successfully!"

# Update apt
echo "Updating package list..."
apt update
