From 6abadfc841ea3148b36044cd830c882afb4ce783 Mon Sep 17 00:00:00 2001 From: Sebastian Hanz Date: Mon, 24 Mar 2025 19:31:26 +0100 Subject: [PATCH] Added Debian-Upgrade-Scripts --- system/upgrade_debian_10_to_11.sh | 50 +++++++++++++++++++++++++++++++ system/upgrade_debian_11_to_12.sh | 50 +++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 system/upgrade_debian_10_to_11.sh create mode 100644 system/upgrade_debian_11_to_12.sh diff --git a/system/upgrade_debian_10_to_11.sh b/system/upgrade_debian_10_to_11.sh new file mode 100644 index 0000000..fcdd4f1 --- /dev/null +++ b/system/upgrade_debian_10_to_11.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +set -e # Exit on any error + +# Define color codes +RED='\e[31m' +GREEN='\e[32m' +YELLOW='\e[33m' +BLUE='\e[34m' +NC='\e[0m' # No Color + +# Ensure the script is run as root +if [[ $EUID -ne 0 ]]; then + echo -e "${RED}This script must be run as root. Try running it with sudo.${NC}" + exit 1 +fi + +echo -e "${BLUE}Updating package lists and upgrading installed packages...${NC}" +DEBIAN_FRONTEND=noninteractive apt update && apt upgrade -y -o Dpkg::Options::="--force-confold" + +echo -e "${BLUE}Upgrading full system...${NC}" +DEBIAN_FRONTEND=noninteractive apt full-upgrade -y -o Dpkg::Options::="--force-confold" + +echo -e "${BLUE}Removing obsolete packages...${NC}" +apt autoremove -y + +# Update all .list files in /etc/apt/sources.list.d/ and sources.list to Debian 11 Bullseye +echo -e "${YELLOW}Updating APT sources list to Debian 11 (Bullseye)...${NC}" +sed -i 's/buster/bullseye/g' /etc/apt/sources.list +sed -i 's/buster-security/bullseye-security/g' /etc/apt/sources.list +find /etc/apt/sources.list.d/ -type f -name "*.list" -exec sed -i 's/buster/bullseye/g' {} + +find /etc/apt/sources.list.d/ -type f -name "*.list" -exec sed -i 's/buster-security/bullseye-security/g' {} + + +# Update APT cache and perform upgrade +echo -e "${BLUE}Updating package lists...${NC}" +apt update + +echo -e "${BLUE}Upgrading to Debian 11 Bullseye...${NC}" +DEBIAN_FRONTEND=noninteractive apt upgrade -y -o Dpkg::Options::="--force-confold" +DEBIAN_FRONTEND=noninteractive apt full-upgrade -y -o Dpkg::Options::="--force-confold" + +echo -e "${BLUE}Cleaning up unnecessary packages...${NC}" +apt autoremove -y +apt clean + +echo -e "${GREEN}Upgrade completed. A system reboot is required.${NC}" +read -p "Do you want to reboot now? (y/N) " answer +if [[ "$answer" =~ ^[Yy]$ ]]; then + reboot +fi diff --git a/system/upgrade_debian_11_to_12.sh b/system/upgrade_debian_11_to_12.sh new file mode 100644 index 0000000..ab52622 --- /dev/null +++ b/system/upgrade_debian_11_to_12.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +set -e # Exit on any error + +# Define color codes +RED='\e[31m' +GREEN='\e[32m' +YELLOW='\e[33m' +BLUE='\e[34m' +NC='\e[0m' # No Color + +# Ensure the script is run as root +if [[ $EUID -ne 0 ]]; then + echo -e "${RED}This script must be run as root. Try running it with sudo.${NC}" + exit 1 +fi + +echo -e "${BLUE}Updating package lists and upgrading installed packages...${NC}" +DEBIAN_FRONTEND=noninteractive apt update && apt upgrade -y -o Dpkg::Options::="--force-confold" + +echo -e "${BLUE}Upgrading full system...${NC}" +DEBIAN_FRONTEND=noninteractive apt full-upgrade -y -o Dpkg::Options::="--force-confold" + +echo -e "${BLUE}Removing obsolete packages...${NC}" +apt autoremove -y + +# Update all .list files in /etc/apt/sources.list.d/ and sources.list to Debian 12 Bookworm +echo -e "${YELLOW}Updating APT sources list to Debian 12 (Bookworm)...${NC}" +sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list +sed -i 's/bullseye-security/bookworm-security/g' /etc/apt/sources.list +find /etc/apt/sources.list.d/ -type f -name "*.list" -exec sed -i 's/bullseye/bookworm/g' {} + +find /etc/apt/sources.list.d/ -type f -name "*.list" -exec sed -i 's/bullseye-security/bookworm-security/g' {} + + +# Update APT cache and perform upgrade +echo -e "${BLUE}Updating package lists...${NC}" +apt update + +echo -e "${BLUE}Upgrading to Debian 12 Bookworm...${NC}" +DEBIAN_FRONTEND=noninteractive apt upgrade -y -o Dpkg::Options::="--force-confold" +DEBIAN_FRONTEND=noninteractive apt full-upgrade -y -o Dpkg::Options::="--force-confold" + +echo -e "${BLUE}Cleaning up unnecessary packages...${NC}" +apt autoremove -y +apt clean + +echo -e "${GREEN}Upgrade completed. A system reboot is required.${NC}" +read -p "Do you want to reboot now? (y/N) " answer +if [[ "$answer" =~ ^[Yy]$ ]]; then + reboot +fi