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
fi
# Check Debian Version, if it's not 10 or 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
# 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" ]; then
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"
exit 1
fi
@ -71,46 +71,34 @@ function change_apt_sources() {
printf "\E[0m"
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
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
# If codename = bullseye, use it's sources.list
elif [ "$codename" == "bullseye" ]; then
cat > /etc/apt/sources.list << EOF
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-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-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
EOF
# If codename = bookworm, use the new sources.list
elif [ "$codename" == "bookworm" ]; then
cat > /etc/apt/sources.list << EOF
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
EOF
# If codename = others, then exit
else
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"
exit 1
fi
@ -139,7 +127,8 @@ function install_packages() {
bash-completion git whois rsyslog \
fail2ban iptables haveged gnupg vnstat lrzsz jq \
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"
echo '### Updating system... ###'
printf "\E[0m"
@ -189,14 +178,14 @@ function disable_ssh_password() {
echo '### Disable SSH password ###'
printf "\E[0m"
codename=$(lsb_release -sc)
if [ "$codename" == "buster" ]; then
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/#?PermitRootLogin.*/PermitRootLogin without-password/' /etc/ssh/sshd_config
echo 'DebianBanner no' >> /etc/ssh/sshd_config
else
# codename=$(lsb_release -sc)
#
# if [ "$codename" == "buster" ]; then
# 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/#?PermitRootLogin.*/PermitRootLogin without-password/' /etc/ssh/sshd_config
# echo 'DebianBanner no' >> /etc/ssh/sshd_config
# else
cat > /etc/ssh/sshd_config.d/disable_password.conf << EOF
PermitRootLogin prohibit-password
PasswordAuthentication no
@ -491,6 +480,10 @@ EOF
printf "\E[0m"
}
# Install Dialog
apt update
apt install dialog -y
# Dialog box begins here
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"