From 7f5d4108c1f16654b655c201d15244d442e1e92b Mon Sep 17 00:00:00 2001 From: Xiufeng Guo Date: Tue, 5 Sep 2023 12:34:39 +1000 Subject: [PATCH] Update debian.sh --- debian.sh | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/debian.sh b/debian.sh index 02f769b..03bbda0 100644 --- a/debian.sh +++ b/debian.sh @@ -3,7 +3,7 @@ # Function :Initial Server Setup for Debian Server # # Platform :Debian 11.x Bullseye and 12.x Bookworm # # Version :1.4 # -# Date :04-14-2023 # +# Date :09-05-2023 # # Author :Xiufeng Guo # # Contact :i@m.ac # # Company :xTom # @@ -51,9 +51,14 @@ function change_apt_sources() { printf "\E[0;35;40m" echo '### Remove all apt sources files ###' printf "\E[0m" - cp -r /etc/apt/sources.list /etc/apt/sources.list.$(date +"%Y_%m_%d_%I_%M_%p").bak - cp -r /etc/apt/sources.list.d /etc/apt/sources.list.d.$(date +"%Y_%m_%d_%I_%M_%p").bak - rm -rf /etc/apt/sources.list.d/* + # if /etc/apt/sources.list exists, then backup it + if [ -f /etc/apt/sources.list ]; then + cp -r /etc/apt/sources.list /etc/apt/sources.list.$(date +"%Y_%m_%d_%I_%M_%p").bak + fi + # if /etc/apt/sources.list.d exists, then backup it + if [ -d /etc/apt/sources.list.d ]; then + cp -r /etc/apt/sources.list.d /etc/apt/sources.list.d.$(date +"%Y_%m_%d_%I_%M_%p").bak + fi printf "\E[0;35;40m" echo '### Update system, install apt-transport-https and ca-certificates ###' @@ -96,14 +101,14 @@ EOF elif [ "$codename" == "bookworm" ]; then cat > /etc/apt/sources.list << EOF -deb http://mirror-cdn.xtom.com/debian/ $codename main contrib non-free non-free-firmware -deb-src http://mirror-cdn.xtom.com/debian/ $codename main contrib non-free non-free-firmware -deb http://mirror-cdn.xtom.com/debian-security $codename-security main contrib non-free non-free-firmware -deb-src http://mirror-cdn.xtom.com/debian-security $codename-security main contrib non-free non-free-firmware -deb http://mirror-cdn.xtom.com/debian/ $codename-updates main contrib non-free non-free-firmware -deb-src http://mirror-cdn.xtom.com/debian/ $codename-updates main contrib non-free non-free-firmware -deb http://mirror-cdn.xtom.com/debian/ $codename-backports main contrib non-free non-free-firmware -deb-src http://mirror-cdn.xtom.com/debian/ $codename-backports main contrib non-free non-free-firmware +deb https://mirror-cdn.xtom.com/debian/ $codename main contrib non-free non-free-firmware +deb-src https://mirror-cdn.xtom.com/debian/ $codename main contrib non-free non-free-firmware +deb https://mirror-cdn.xtom.com/debian-security $codename-security main contrib non-free non-free-firmware +deb-src https://mirror-cdn.xtom.com/debian-security $codename-security main contrib non-free non-free-firmware +deb https://mirror-cdn.xtom.com/debian/ $codename-updates main contrib non-free non-free-firmware +deb-src https://mirror-cdn.xtom.com/debian/ $codename-updates main contrib non-free non-free-firmware +deb https://mirror-cdn.xtom.com/debian/ $codename-backports main contrib non-free non-free-firmware +deb-src https://mirror-cdn.xtom.com/debian/ $codename-backports main contrib non-free non-free-firmware EOF # If codename = others, then exit else @@ -113,6 +118,9 @@ EOF exit 1 fi + # Delete all sources.list.d files + rm -rf /etc/apt/sources.list.d/* + printf "\E[0;35;40m" echo '### Updating system... ###' printf "\E[0m" @@ -342,7 +350,7 @@ function add_nginx_repo() { echo '### Add n.wtf Nginx repo ###' printf "\E[0m" curl -sS https://n.wtf/public.key | gpg --dearmor > /usr/share/keyrings/n.wtf.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/n.wtf.gpg] https://mirror-cdn.xtom.com/sb/nginx-quic/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/n.wtf.list + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/n.wtf.gpg] https://mirror-cdn.xtom.com/sb/nginx/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/n.wtf.list printf "\E[0;33;40m" echo "### n.wtf Nginx repo added ###" printf "\E[0m"