Remove Debian 10

Debian 10 Buster reached EOL, remove it.
This commit is contained in:
Xiufeng Guo 2024-07-04 21:50:31 +09:00
parent b18de8ddae
commit 5d4594edec
Signed by: showfom
GPG Key ID: 29A7777777777777

View File

@ -30,10 +30,10 @@ else
exit 1 exit 1
fi fi
# Check Debian Version, if it's not 10 or 11 or 12, exit # Check Debian Version, if it's not 11 or 12, exit
if [ "$(cat /etc/debian_version | cut -d'.' -f1)" != "12" ] && [ "$(cat /etc/debian_version | cut -d'.' -f1)" != "11" ] && [ "$(cat /etc/debian_version | cut -d'.' -f1)" != "10" ]; then if [ "$(cat /etc/debian_version | cut -d'.' -f1)" != "12" ] && [ "$(cat /etc/debian_version | cut -d'.' -f1)" != "11" ]; then
printf "\E[0;31;40m" printf "\E[0;31;40m"
echo "### This script is only for Debian 10 or 11 or 12. Exiting... ###" echo "### This script is only for Debian 11 or 12. Exiting... ###"
printf "\E[0m" printf "\E[0m"
exit 1 exit 1
fi fi
@ -71,46 +71,34 @@ function change_apt_sources() {
printf "\E[0m" printf "\E[0m"
codename=$(lsb_release -sc) codename=$(lsb_release -sc)
# If codename = buster, use the old sources.list
if [ "$codename" == "buster" ]; then
cat > /etc/apt/sources.list << EOF
deb https://mirror-cdn.xtom.com/debian/ $codename main contrib non-free
deb https://mirror-cdn.xtom.com/debian-security/ $codename/updates main contrib non-free # If codename = bullseye, use it's sources.list
deb https://mirror-cdn.xtom.com/debian/ $codename-updates main contrib non-free
deb https://mirror-cdn.xtom.com/debian/ $codename-backports main contrib non-free
EOF
# If codename = bullseye, use the new sources.list
elif [ "$codename" == "bullseye" ]; then elif [ "$codename" == "bullseye" ]; then
cat > /etc/apt/sources.list << EOF cat > /etc/apt/sources.list << EOF
deb https://mirror-cdn.xtom.com/debian/ $codename main contrib non-free deb https://mirror-cdn.xtom.com/debian/ $codename main contrib non-free
#deb-src https://mirror-cdn.xtom.com/debian/ $codename main contrib non-free
deb https://mirror-cdn.xtom.com/debian-security/ $codename-security main contrib non-free deb https://mirror-cdn.xtom.com/debian-security/ $codename-security main contrib non-free
#deb-src https://mirror-cdn.xtom.com/debian-security/ $codename-security main contrib non-free
deb https://mirror-cdn.xtom.com/debian/ $codename-updates main contrib non-free deb https://mirror-cdn.xtom.com/debian/ $codename-updates main contrib non-free
#deb-src https://mirror-cdn.xtom.com/debian/ $codename-updates main contrib non-free
deb https://mirror-cdn.xtom.com/debian/ $codename-backports main contrib non-free deb https://mirror-cdn.xtom.com/debian/ $codename-backports main contrib non-free
EOF EOF
# If codename = bookworm, use the new sources.list # If codename = bookworm, use the new sources.list
elif [ "$codename" == "bookworm" ]; then elif [ "$codename" == "bookworm" ]; then
cat > /etc/apt/sources.list << EOF cat > /etc/apt/sources.list << EOF
deb https://mirror-cdn.xtom.com/debian/ $codename 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 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 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 https://mirror-cdn.xtom.com/debian/ $codename-backports main contrib non-free non-free-firmware
EOF EOF
# If codename = others, then exit # If codename = others, then exit
else else
printf "\E[0;31;40m" printf "\E[0;31;40m"
echo "### This script is only for Debian 10, 11 or 12. Exiting... ###" echo "### This script is only for Debian 11 or 12. Exiting... ###"
printf "\E[0m" printf "\E[0m"
exit 1 exit 1
fi fi
@ -139,7 +127,8 @@ function install_packages() {
bash-completion git whois rsyslog \ bash-completion git whois rsyslog \
fail2ban iptables haveged gnupg vnstat lrzsz jq \ fail2ban iptables haveged gnupg vnstat lrzsz jq \
unattended-upgrades apt-listchanges \ unattended-upgrades apt-listchanges \
htop iftop p7zip-full zstd systemd-timesyncd htop iftop p7zip-full zstd systemd-timesyncd \
bat python3-systemd
printf "\E[0;35;40m" printf "\E[0;35;40m"
echo '### Updating system... ###' echo '### Updating system... ###'
printf "\E[0m" printf "\E[0m"
@ -189,14 +178,14 @@ function disable_ssh_password() {
echo '### Disable SSH password ###' echo '### Disable SSH password ###'
printf "\E[0m" printf "\E[0m"
codename=$(lsb_release -sc) # codename=$(lsb_release -sc)
#
if [ "$codename" == "buster" ]; then # if [ "$codename" == "buster" ]; then
cp -r /etc/ssh/sshd_config /etc/ssh/sshd_config.$(date +"%Y_%m_%d_%I_%M_%p").bak # cp -r /etc/ssh/sshd_config /etc/ssh/sshd_config.$(date +"%Y_%m_%d_%I_%M_%p").bak
sed -i -E 's/#?PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config # sed -i -E 's/#?PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
sed -i -E 's/#?PermitRootLogin.*/PermitRootLogin without-password/' /etc/ssh/sshd_config # sed -i -E 's/#?PermitRootLogin.*/PermitRootLogin without-password/' /etc/ssh/sshd_config
echo 'DebianBanner no' >> /etc/ssh/sshd_config # echo 'DebianBanner no' >> /etc/ssh/sshd_config
else # else
cat > /etc/ssh/sshd_config.d/disable_password.conf << EOF cat > /etc/ssh/sshd_config.d/disable_password.conf << EOF
PermitRootLogin prohibit-password PermitRootLogin prohibit-password
PasswordAuthentication no PasswordAuthentication no
@ -491,6 +480,10 @@ EOF
printf "\E[0m" printf "\E[0m"
} }
# Install Dialog
apt update
apt install dialog -y
# Dialog box begins here # Dialog box begins here
cmd=(dialog --title "Debian Server Initial Setup" --separate-output --checklist "Select options:" 22 76 16) cmd=(dialog --title "Debian Server Initial Setup" --separate-output --checklist "Select options:" 22 76 16)
options=(1 "Install Packages" on # any option can be set to default to "on" options=(1 "Install Packages" on # any option can be set to default to "on"