Buat file baru dengan nama tambah_repositori.sh

nano tambah_repositori.sh

isikan script berikut ini :

#!/bin/bash
# Script sederhana dengan auto-fix

# Auto-fix function
auto_fix() {
    # Fix line endings
    sed -i 's/\r$//' "$0" 2>/dev/null
    # Ensure executable
    [ ! -x "$0" ] && chmod +x "$0"
    # Check shebang
    if ! head -1 "$0" | grep -q "^#!/bin/bash"; then
        exec bash "$0"
    fi
}

# Run auto-fix first
auto_fix

# Main script
echo "=== Auto-Fix Repository Setup ==="

# Cek root
[ "$EUID" -ne 0 ] && echo "❌ Run with sudo!" && exit 1

# Backup
cp /etc/apt/sources.list /etc/apt/sources.list.backup.$(date +%Y%m%d_%H%M%S)

# Hapus cdrom dan tambah repo
sed -i '/^deb cdrom/d' /etc/apt/sources.list

cat >> /etc/apt/sources.list << EOF

# Debian 12 Repos
deb http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
deb http://deb.debian.org/debian/ bookworm-updates main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian/ bookworm-updates main contrib non-free non-free-firmware
deb http://deb.debian.org/debian/ bookworm-backports main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian/ bookworm-backports main contrib non-free non-free-firmware
deb http://security.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
deb-src http://security.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
EOF

# Update
apt update && apt upgrade -y

echo "✅ Done!"

Simpan script tersebut. beri hak akses eksekusi

chmod +x tambah_repositori.sh

jalankan script

./tambah_repositori.sh