mirror of
https://github.com/wickedyoda/public-setupfiles.git
synced 2026-11-16 13:31:56 -06:00
Update dist-upgrade.sh
This commit is contained in:
1 parent
fd32567e8f
commit
4e65d6a985
1 file changed
+189
-48
+189
-48
@@ -1,58 +1,199 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
# Backup existing sources
|
LOGFILE="./log.txt"
|
||||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup.$(date +%F-%H%M)
|
exec > >(tee -a "$LOGFILE") 2>&1
|
||||||
|
|
||||||
# Detect OS ID and VERSION_CODENAME
|
echo "===== Debian Upgrade Script Started: $(date) ====="
|
||||||
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release)
|
|
||||||
CODENAME=$(grep -oP '(?<=^VERSION_CODENAME=).+' /etc/os-release)
|
|
||||||
|
|
||||||
echo "Detected OS: $ID"
|
# --------------------------------------------------
|
||||||
echo "Detected Codename: $CODENAME"
|
# 1. Verify Debian-based OS
|
||||||
|
# --------------------------------------------------
|
||||||
# Debian Only
|
if [[ ! -f /etc/os-release ]]; then
|
||||||
if [ "$ID" == "debian" ]; then
|
echo "ERROR: Cannot detect OS."
|
||||||
echo "Debian system detected."
|
exit 1
|
||||||
|
|
||||||
# Check if we're on Bookworm
|
|
||||||
if [ "$CODENAME" != "bookworm" ]; then
|
|
||||||
echo "This script only upgrades Debian 12 (Bookworm). Current version is: $CODENAME"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Upgrading Debian 12 → Debian 13 (Trixie)..."
|
|
||||||
echo "Updating sources.list to Trixie..."
|
|
||||||
|
|
||||||
sudo tee /etc/apt/sources.list >/dev/null << EOF
|
|
||||||
deb http://deb.debian.org/debian trixie main contrib non-free non-free-firmware
|
|
||||||
deb-src http://deb.debian.org/debian trixie main contrib non-free non-free-firmware
|
|
||||||
|
|
||||||
deb http://deb.debian.org/debian trixie-updates main contrib non-free non-free-firmware
|
|
||||||
deb-src http://deb.debian.org/debian trixie-updates main contrib non-free non-free-firmware
|
|
||||||
|
|
||||||
deb http://deb.debian.org/debian-security trixie-security main contrib non-free non-free-firmware
|
|
||||||
deb-src http://deb.debian.org/debian-security trixie-security main contrib non-free non-free-firmware
|
|
||||||
EOF
|
|
||||||
|
|
||||||
else
|
|
||||||
echo "This script only supports Debian. Exiting."
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "=== Running apt update ==="
|
source /etc/os-release
|
||||||
sudo apt update
|
|
||||||
|
|
||||||
echo "=== Starting full upgrade ==="
|
if [[ "$ID_LIKE" != *"debian"* && "$ID" != "debian" ]]; then
|
||||||
sudo apt full-upgrade -y
|
echo "ERROR: This system is not Debian-based."
|
||||||
sudo apt dist-upgrade -y
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "=== Cleaning system ==="
|
echo "Detected OS: $PRETTY_NAME"
|
||||||
sudo apt autoremove -y
|
|
||||||
sudo apt clean -y
|
# --------------------------------------------------
|
||||||
sudo apt autopurge -y
|
# 2. Identify version and prompt
|
||||||
|
# --------------------------------------------------
|
||||||
|
DEBIAN_VERSION=$(grep -oP '(?<=VERSION_ID=").*(?=")' /etc/os-release)
|
||||||
|
DEBIAN_CODENAME=$(grep -oP '(?<=VERSION_CODENAME=).*' /etc/os-release)
|
||||||
|
|
||||||
|
echo "Current Debian Version: $DEBIAN_VERSION ($DEBIAN_CODENAME)"
|
||||||
|
read -rp "Continue? (yes/no): " CONFIRM
|
||||||
|
[[ "$CONFIRM" != "yes" ]] && exit 0
|
||||||
|
|
||||||
|
# --------------------------------------------------
|
||||||
|
# 3. Upgrade Menu
|
||||||
|
# --------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "Select upgrade option:"
|
||||||
|
echo "1) apt upgrade"
|
||||||
|
echo "2) apt full-upgrade"
|
||||||
|
echo "3) Debian distro upgrade"
|
||||||
|
echo "4) Convert Debian to Parrot Linux"
|
||||||
|
read -rp "Choice [1-4]: " CHOICE
|
||||||
|
|
||||||
|
# Ensure non-interactive config handling
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
APT_OPTS="-o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-confdef"
|
||||||
|
|
||||||
|
# --------------------------------------------------
|
||||||
|
# Option 3: Debian Distro Upgrade
|
||||||
|
# --------------------------------------------------
|
||||||
|
if [[ "$CHOICE" == "3" ]]; then
|
||||||
|
echo ""
|
||||||
|
echo "Select Debian upgrade target:"
|
||||||
|
echo "1) Debian 12 (Bookworm - Stable)"
|
||||||
|
echo "2) Debian 13 (Trixie - Testing)"
|
||||||
|
read -rp "Choice [1-2]: " TARGET
|
||||||
|
|
||||||
|
# Backup sources.list
|
||||||
|
cp /etc/apt/sources.list /etc/apt/sources.list.bak.$(date +%F)
|
||||||
|
|
||||||
|
# Comment out existing entries (do not delete)
|
||||||
|
sed -i 's/^[^#]/#&/' /etc/apt/sources.list
|
||||||
|
|
||||||
|
if [[ "$TARGET" == "1" ]]; then
|
||||||
|
echo "Preparing upgrade to Debian 12 (Bookworm)"
|
||||||
|
|
||||||
|
cat <<EOF >> /etc/apt/sources.list
|
||||||
|
|
||||||
|
# Debian 12 Bookworm Repositories
|
||||||
|
deb 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 http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
|
||||||
|
EOF
|
||||||
|
|
||||||
|
elif [[ "$TARGET" == "2" ]]; then
|
||||||
|
echo "WARNING: Debian 13 (Trixie) is TESTING."
|
||||||
|
|
||||||
|
read -rp "Type I UNDERSTAND to continue: " CONFIRM1
|
||||||
|
read -rp "Type UPGRADE TO 13 to confirm: " CONFIRM2
|
||||||
|
|
||||||
|
if [[ "$CONFIRM1" != "I UNDERSTAND" || "$CONFIRM2" != "UPGRADE TO 13" ]]; then
|
||||||
|
echo "Upgrade to Debian 13 aborted."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<EOF >> /etc/apt/sources.list
|
||||||
|
|
||||||
|
# Debian 13 Trixie Repositories
|
||||||
|
deb http://deb.debian.org/debian trixie main contrib non-free non-free-firmware
|
||||||
|
deb http://deb.debian.org/debian trixie-updates main contrib non-free non-free-firmware
|
||||||
|
deb http://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware
|
||||||
|
EOF
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Invalid selection."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Running upgrade process..."
|
||||||
|
|
||||||
|
apt update
|
||||||
|
apt full-upgrade -y $APT_OPTS
|
||||||
|
apt autoremove -y
|
||||||
|
apt clean
|
||||||
|
apt purge -y '~c'
|
||||||
|
|
||||||
|
echo "Debian upgrade process completed."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --------------------------------------------------
|
||||||
|
# Option 4: Parrot Linux Conversion
|
||||||
|
# --------------------------------------------------
|
||||||
|
if [[ "$CHOICE" == "4" ]]; then
|
||||||
|
echo "WARNING: This will convert Debian into Parrot Linux."
|
||||||
|
read -rp "Type CONVERT to proceed: " PARROT_CONFIRM
|
||||||
|
[[ "$PARROT_CONFIRM" != "CONVERT" ]] && exit 1
|
||||||
|
|
||||||
|
git clone https://gitlab.com/parrotsec/project/debian-conversion-script.git
|
||||||
|
cd debian-conversion-script || exit 1
|
||||||
|
chmod +x ./install.sh
|
||||||
|
./install.sh
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --------------------------------------------------
|
||||||
|
# Option 3: Debian Distro Upgrade
|
||||||
|
# --------------------------------------------------
|
||||||
|
if [[ "$CHOICE" != "3" ]]; then
|
||||||
|
echo "Invalid selection."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "======================================================"
|
echo "Select Debian target:"
|
||||||
echo " Debian upgrade to TRIXIE is complete!"
|
echo "1) Debian 12 (Bookworm)"
|
||||||
echo " It is recommended to reboot now: sudo reboot"
|
echo "2) Debian 13 (Trixie - TESTING)"
|
||||||
echo "======================================================"
|
read -rp "Choice [1-2]: " TARGET
|
||||||
|
|
||||||
|
# Backup sources.list
|
||||||
|
cp /etc/apt/sources.list /etc/apt/sources.list.bak.$(date +%F)
|
||||||
|
|
||||||
|
# Comment out existing entries
|
||||||
|
sed -i 's/^[^#]/#&/' /etc/apt/sources.list
|
||||||
|
|
||||||
|
# --------------------------------------------------
|
||||||
|
# Debian 12
|
||||||
|
# --------------------------------------------------
|
||||||
|
if [[ "$TARGET" == "1" ]]; then
|
||||||
|
cat <<EOF >> /etc/apt/sources.list
|
||||||
|
|
||||||
|
# Debian 12 Bookworm Repositories
|
||||||
|
deb 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 http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
|
||||||
|
EOF
|
||||||
|
|
||||||
|
apt update
|
||||||
|
apt full-upgrade -y $APT_OPTS
|
||||||
|
echo "Upgrade to Debian 12 completed."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --------------------------------------------------
|
||||||
|
# Debian 13 (Double Confirmation)
|
||||||
|
# --------------------------------------------------
|
||||||
|
if [[ "$TARGET" == "2" ]]; then
|
||||||
|
echo "WARNING: Debian 13 (Trixie) is TESTING."
|
||||||
|
read -rp "Type I UNDERSTAND to continue: " CONFIRM1
|
||||||
|
read -rp "Type UPGRADE TO 13 to confirm: " CONFIRM2
|
||||||
|
|
||||||
|
if [[ "$CONFIRM1" != "I UNDERSTAND" || "$CONFIRM2" != "UPGRADE TO 13" ]]; then
|
||||||
|
echo "Upgrade aborted."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<EOF >> /etc/apt/sources.list
|
||||||
|
|
||||||
|
# Debian 13 Trixie Repositories
|
||||||
|
deb http://deb.debian.org/debian trixie main contrib non-free non-free-firmware
|
||||||
|
deb http://deb.debian.org/debian trixie-updates main contrib non-free non-free-firmware
|
||||||
|
deb http://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware
|
||||||
|
EOF
|
||||||
|
|
||||||
|
apt update
|
||||||
|
apt full-upgrade -y $APT_OPTS
|
||||||
|
apt autoremove -y
|
||||||
|
apt clean
|
||||||
|
apt purge -y '~c'
|
||||||
|
|
||||||
|
echo "Upgrade to Debian 13 completed."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Unknown error occurred."
|
||||||
|
exit 1
|
||||||
Reference in new issue
Block a user