updated debian colors

This commit is contained in:
[yuri]
2025-11-10 14:56:50 +01:00
parent ad9d761979
commit d9e4e603b4

View File

@@ -34,10 +34,8 @@ TWM="${SELECTED_TWM:-none}"
INSTALL_LEVEL="${INSTALL_LEVEL:-minimal}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
color_cyan
echo
echo "Starting Debian setup..."
color_reset
echo "${CYAN}Starting Debian setup...${RESET}"
echo
echo "DE: $DE, TWM: $TWM, Install Level: $INSTALL_LEVEL"
@@ -47,10 +45,8 @@ echo "DE: $DE, TWM: $TWM, Install Level: $INSTALL_LEVEL"
# 0. Ensure curl is installed
##########################
if ! command -v curl >/dev/null 2>&1; then
color_yellow
echo
echo "curl is not installed. Installing..."
color_reset
echo "${YELLOW}curl is not installed. Installing...${RESET}"
sudo apt update
sudo apt -y install curl
fi
@@ -58,16 +54,12 @@ fi
##########################
# 1. Add contrib and non-free if missing
##########################
color_yellow
echo
echo "Checking /etc/apt/sources.list for contrib/non-free..."
color_reset
echo "${YELLOW}Checking /etc/apt/sources.list for contrib/non-free...${RESET}"
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak.$(date +%s)
sudo sed -i -r 's/^(deb\s+\S+\s+\S+)\s+(main)$/\1 main contrib non-free/' /etc/apt/sources.list
color_green
echo
echo "Updated sources.list to include contrib/non-free where needed."
color_reset
echo "${GREEN}Updated sources.list to include contrib/non-free where needed.${RESET}"
##########################
# 1a. Update archive.debian.org if needed
@@ -87,80 +79,60 @@ CURRENT_INDEX=$(codename_index "$CURRENT_CODENAME")
BULLSEYE_INDEX=$(codename_index "bullseye")
if [[ "$CURRENT_INDEX" -ge "$BULLSEYE_INDEX" ]] && grep -q "archive.debian.org" /etc/apt/sources.list; then
color_yellow
echo
echo "Found archive.debian.org in sources.list and system is Bullseye or newer, updating to deb.debian.org..."
color_reset
echo "${YELLOW}Found archive.debian.org in sources.list and system is Bullseye or newer, updating to deb.debian.org...${RESET}"
sudo sed -i -r 's|archive\.debian\.org|deb.debian.org|g' /etc/apt/sources.list
color_green
echo
echo "Updated sources.list to use deb.debian.org."
color_reset
echo "${GREEN}Updated sources.list to use deb.debian.org.${RESET}"
fi
##########################
# 2. Full update and upgrade
##########################
color_yellow
echo
echo "Updating package lists..."
color_reset
echo "${YELLOW}Updating package lists...${RESET}"
sudo apt update
# Autoremove before full-upgrade
AUTOREMOVE_PENDING=$(apt -s autoremove | grep -E 'Remv' || true)
if [[ -n "$AUTOREMOVE_PENDING" ]]; then
color_yellow
echo
echo "Removing packages that are no longer required before upgrade..."
color_reset
echo "${YELLOW}Removing packages that are no longer required before upgrade...${RESET}"
sudo apt -y autoremove
fi
color_yellow
echo
echo "Upgrading installed packages..."
color_reset
echo "${YELLOW}Upgrading installed packages...${RESET}"
sudo apt -y full-upgrade
# Autoremove after full-upgrade
AUTOREMOVE_PENDING=$(apt -s autoremove | grep -E 'Remv' || true)
if [[ -n "$AUTOREMOVE_PENDING" ]]; then
color_yellow
echo
echo "Removing packages that are no longer required after upgrade..."
color_reset
echo "${YELLOW}Removing packages that are no longer required after upgrade...${RESET}"
sudo apt -y autoremove
fi
UPGRADE_PENDING=$(apt list --upgradable 2>/dev/null | grep -v Listing || true)
if [[ -n "$UPGRADE_PENDING" ]]; then
color_red
echo
echo "Some packages were upgraded. A reboot is recommended before continuing."
color_reset
echo "${RED}Some packages were upgraded. A reboot is recommended before continuing.${RESET}"
read -rp "Reboot now? [y/N]: " reboot_choice
case "${reboot_choice,,}" in
y|yes)
color_red
echo
echo "Rebooting now. After reboot, please restart this script to continue..."
color_reset
echo "${RED}Rebooting now. After reboot, please restart this script to continue...${RESET}"
sudo reboot
;;
*)
color_yellow
echo
echo "Skipping reboot. Make sure to reboot manually before continuing upgrades."
color_reset
echo "${YELLOW}Skipping reboot. Make sure to reboot manually before continuing upgrades.${RESET}"
exit 0
;;
esac
else
color_green
echo
echo "All packages are up to date. Continuing to Debian major version check..."
color_reset
echo "${GREEN}All packages are up to date. Continuing to Debian major version check...${RESET}"
fi
##########################
@@ -170,11 +142,9 @@ DEBIAN_SEQUENCE=(buster bullseye bookworm trixie)
CURRENT_CODENAME=$(grep -Po 'deb\s+\S+\s+\K\S+' /etc/apt/sources.list | grep -E '^(buster|bullseye|bookworm|trixie)$' | head -n1)
LATEST_CODENAME=${DEBIAN_SEQUENCE[-1]}
color_cyan
echo
echo "Current codename: $CURRENT_CODENAME"
echo "Latest stable codename: $LATEST_CODENAME"
color_reset
echo "${CYAN}Current codename: $CURRENT_CODENAME"
echo "Latest stable codename: $LATEST_CODENAME${RESET}"
while [[ "$CURRENT_CODENAME" != "$LATEST_CODENAME" ]]; do
NEXT_CODENAME=""
@@ -186,38 +156,28 @@ while [[ "$CURRENT_CODENAME" != "$LATEST_CODENAME" ]]; do
done
if [[ -z "$NEXT_CODENAME" ]]; then
color_red
echo
echo "Error: Cannot determine next codename after $CURRENT_CODENAME"
color_reset
echo "${RED}Error: Cannot determine next codename after $CURRENT_CODENAME${RESET}"
exit 1
fi
color_yellow
echo
echo "Detected codename $CURRENT_CODENAME, next stable version: $NEXT_CODENAME"
color_reset
echo "${YELLOW}Detected codename $CURRENT_CODENAME, next stable version: $NEXT_CODENAME${RESET}"
read -rp "Do you want to upgrade to $NEXT_CODENAME? [y/N]: " choice
case "${choice,,}" in
y|yes)
color_yellow
echo
echo "Updating sources.list to $NEXT_CODENAME..."
color_reset
echo "${YELLOW}Updating sources.list to $NEXT_CODENAME...${RESET}"
sudo sed -i -r "s/\b$CURRENT_CODENAME\b/$NEXT_CODENAME/g" /etc/apt/sources.list
color_yellow
echo
echo "Updating packages..."
color_reset
echo "${YELLOW}Updating packages...${RESET}"
sudo apt update
AUTOREMOVE_PENDING=$(apt -s autoremove | grep -E 'Remv' || true)
if [[ -n "$AUTOREMOVE_PENDING" ]]; then
color_yellow
echo
echo "Removing packages that are no longer required before upgrade..."
color_reset
echo "${YELLOW}Removing packages that are no longer required before upgrade...${RESET}"
sudo apt -y autoremove
fi
@@ -225,25 +185,19 @@ while [[ "$CURRENT_CODENAME" != "$LATEST_CODENAME" ]]; do
AUTOREMOVE_PENDING=$(apt -s autoremove | grep -E 'Remv' || true)
if [[ -n "$AUTOREMOVE_PENDING" ]]; then
color_yellow
echo
echo "Removing packages that are no longer required after upgrade..."
color_reset
echo "${YELLOW}Removing packages that are no longer required after upgrade...${RESET}"
sudo apt -y autoremove
fi
color_green
echo
echo "Upgrade to $NEXT_CODENAME complete. A reboot is recommended."
color_reset
echo "${GREEN}Upgrade to $NEXT_CODENAME complete. A reboot is recommended.${RESET}"
read -rp "Press Enter to reboot..." _
sudo reboot
;;
*)
color_yellow
echo
echo "Skipping upgrade to $NEXT_CODENAME. Continuing with current version."
color_reset
echo "${YELLOW}Skipping upgrade to $NEXT_CODENAME. Continuing with current version.${RESET}"
break
;;
esac
@@ -251,41 +205,31 @@ while [[ "$CURRENT_CODENAME" != "$LATEST_CODENAME" ]]; do
CURRENT_CODENAME=$(grep -Po 'deb\s+\S+\s+\K\S+' /etc/apt/sources.list | grep -E '^(buster|bullseye|bookworm|trixie)$' | head -n1)
done
color_green
echo
echo "Debian is now at codename $CURRENT_CODENAME. Continuing with DE/TWM installation..."
color_reset
echo "${GREEN}Debian is now at codename $CURRENT_CODENAME. Continuing with DE/TWM installation...${RESET}"
##########################
# 4. Desktop Environment installation
##########################
case "$DE" in
xfce|plasma|gnome)
color_yellow
echo
echo "Preparing to install $DE..."
color_reset
echo "${YELLOW}Preparing to install $DE...${RESET}"
SCRIPT_NAME="$SCRIPT_DIR/${OS}-${DE}.sh"
if [[ -f "$SCRIPT_NAME" ]]; then
color_cyan
echo
echo "Running $SCRIPT_NAME..."
color_reset
echo "${CYAN}Running $SCRIPT_NAME...${RESET}"
bash "$SCRIPT_NAME"
else
color_red
echo
echo "Error: $SCRIPT_NAME not found!"
color_reset
echo "${RED}Error: $SCRIPT_NAME not found!${RESET}"
exit 1
fi
;;
none)
color_gray
echo
echo "No Desktop Environment selected, skipping DE installation."
color_reset
echo "${GRAY}No Desktop Environment selected, skipping DE installation.${RESET}"
;;
esac
@@ -294,31 +238,23 @@ esac
##########################
case "$TWM" in
chadwm|hyprland)
color_yellow
echo
echo "Installing $TWM..."
color_reset
echo "${YELLOW}Installing $TWM...${RESET}"
SCRIPT_NAME="$SCRIPT_DIR/${OS}-${TWM}.sh"
if [[ -f "$SCRIPT_NAME" ]]; then
color_cyan
echo
echo "Running $SCRIPT_NAME..."
color_reset
echo "${CYAN}Running $SCRIPT_NAME...${RESET}"
bash "$SCRIPT_NAME"
else
color_red
echo
echo "Error: $SCRIPT_NAME not found!"
color_reset
echo "${RED}Error: $SCRIPT_NAME not found!${RESET}"
exit 1
fi
;;
none)
color_gray
echo
echo "No tiling window manager selected."
color_reset
echo "${GRAY}No tiling window manager selected.${RESET}"
;;
esac
@@ -327,54 +263,40 @@ esac
##########################
case "$INSTALL_LEVEL" in
minimal|full|workstation|server)
color_cyan
echo
echo "Installation level: $INSTALL_LEVEL"
color_reset
echo "${CYAN}Installation level: $INSTALL_LEVEL${RESET}"
SCRIPT_NAME="$SCRIPT_DIR/${OS}-${INSTALL_LEVEL}.sh"
if [[ -f "$SCRIPT_NAME" ]]; then
color_cyan
echo
echo "Running $SCRIPT_NAME..."
color_reset
echo "${CYAN}Running $SCRIPT_NAME...${RESET}"
bash "$SCRIPT_NAME"
else
color_red
echo
echo "Error: $SCRIPT_NAME not found!"
color_reset
echo "${RED}Error: $SCRIPT_NAME not found!${RESET}"
exit 1
fi
;;
esac
color_green
echo
echo "Debian setup complete."
color_reset
echo "${GREEN}Debian setup complete.${RESET}"
##########################
# 7. Installation Finished
##########################
color_red
echo
echo "The installation has finished. A reboot is recommended before continuing."
color_reset
echo "${RED}The installation has finished. A reboot is recommended before continuing.${RESET}"
read -rp "Reboot now? [y/N]: " reboot_choice
case "${reboot_choice,,}" in
y|yes)
color_red
echo
echo "Rebooting now."
color_reset
echo "${RED}Rebooting now.${RESET}"
sudo reboot
;;
*)
color_yellow
echo
echo "Skipping reboot. Make sure to reboot manually before continuing upgrades."
color_reset
echo "${YELLOW}Skipping reboot. Make sure to reboot manually before continuing upgrades.${RESET}"
exit 0
;;
esac