Init for changereview
This commit is contained in:
parent
ec3a51695c
commit
f9903d7e77
1 changed files with 50 additions and 0 deletions
50
system/upgrade_debian_12_to_13.sh
Normal file
50
system/upgrade_debian_12_to_13.sh
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue