Update debian.sh

This commit is contained in:
Xiufeng Guo 2023-09-05 12:34:39 +10:00
parent 92809914cc
commit 7f5d4108c1
Signed by: showfom
GPG Key ID: 29A7777777777777

View File

@ -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"