Update debian.sh

This commit is contained in:
Xiufeng Guo 2023-04-14 23:28:07 +10:00
parent fdc57f0daa
commit d03d1aa6cc
Signed by: showfom
GPG Key ID: 29A7777777777777

View File

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
######################################################### #########################################################
# Function :Initial Server Setup for Debian Server # # Function :Initial Server Setup for Debian Server #
# Platform :Debian 11.x Bullseye # # Platform :Debian 11.x Bullseye and 12.x Bookworm #
# Version :1.3 # # Version :1.4 #
# Date :12-17-2022 # # Date :04-14-2023 #
# Author :Xiufeng Guo # # Author :Xiufeng Guo #
# Contact :i@m.ac # # Contact :i@m.ac #
# Company :xTom # # Company :xTom #
@ -30,10 +30,10 @@ else
exit 1 exit 1
fi fi
# Check Debian Version, if it's not 10 or 11, exit # Check Debian Version, if it's not 10 or 11 or 12, exit
if [ "$(cat /etc/debian_version | cut -d'.' -f1)" != "10" ] && [ "$(cat /etc/debian_version | cut -d'.' -f1)" != "11" ]; then 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
printf "\E[0;31;40m" printf "\E[0;31;40m"
echo "### This script is only for Debian 10 or 11. Exiting... ###" echo "### This script is only for Debian 10 or 11 or 12. Exiting... ###"
printf "\E[0m" printf "\E[0m"
exit 1 exit 1
fi fi
@ -78,8 +78,10 @@ deb-src https://mirror-cdn.xtom.com/debian/ $codename-updates main contrib non-f
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
deb-src https://mirror-cdn.xtom.com/debian/ $codename-backports main contrib non-free deb-src https://mirror-cdn.xtom.com/debian/ $codename-backports main contrib non-free
EOF EOF
else
cat > /etc/apt/sources.list << EOF # If codename = bullseye, use the new 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 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-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
@ -89,6 +91,26 @@ deb-src https://mirror-cdn.xtom.com/debian/ $codename-updates main contrib non-f
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
deb-src https://mirror-cdn.xtom.com/debian/ $codename-backports main contrib non-free deb-src https://mirror-cdn.xtom.com/debian/ $codename-backports main contrib non-free
EOF EOF
# If codename = bookworm, use the new sources.list
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
EOF
# If codename = others, then exit
else
printf "\E[0;31;40m"
echo "### This script is only for Debian 10, 11 or 12. Exiting... ###"
printf "\E[0m"
exit 1
fi fi
printf "\E[0;35;40m" printf "\E[0;35;40m"
@ -303,6 +325,7 @@ net.ipv6.ip6frag_high_thresh = 4194304
net.ipv6.ip6frag_low_thresh = 3145728 net.ipv6.ip6frag_low_thresh = 3145728
net.ipv4.ipfrag_high_thresh = 4194304 net.ipv4.ipfrag_high_thresh = 4194304
net.ipv4.ipfrag_low_thresh = 3145728 net.ipv4.ipfrag_low_thresh = 3145728
net.ipv4.ping_group_range = 0 2147483647
EOF EOF
sysctl -p sysctl -p
printf "\E[0;33;40m" printf "\E[0;33;40m"
@ -315,7 +338,7 @@ function add_nginx_repo() {
echo '### Add n.wtf Nginx repo ###' echo '### Add n.wtf Nginx repo ###'
printf "\E[0m" printf "\E[0m"
curl -sS https://n.wtf/public.key | gpg --dearmor > /usr/share/keyrings/n.wtf.gpg 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/ $(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-quic/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/n.wtf.list
printf "\E[0;33;40m" printf "\E[0;33;40m"
echo "### n.wtf Nginx repo added ###" echo "### n.wtf Nginx repo added ###"
printf "\E[0m" printf "\E[0m"
@ -347,13 +370,24 @@ function add_mariadb_repo() {
printf "\E[0;35;40m" printf "\E[0;35;40m"
echo '### Add MariaDB repo ###' echo '### Add MariaDB repo ###'
printf "\E[0m" printf "\E[0m"
curl -sS https://mariadb.org/mariadb_release_signing_key.asc | gpg --dearmor > /usr/share/keyrings/mariadb.gpg curl -sSL https://mariadb.org/mariadb_release_signing_key.asc | gpg --dearmor > /usr/share/keyrings/mariadb.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mariadb.gpg] https://mirror-cdn.xtom.com/mariadb/repo/10.6/debian $(lsb_release -sc) main" > /etc/apt/sources.list.d/mariadb.list echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mariadb.gpg] https://mirror-cdn.xtom.com/mariadb/repo/10.11/debian $(lsb_release -sc) main" > /etc/apt/sources.list.d/mariadb.list
printf "\E[0;33;40m" printf "\E[0;33;40m"
echo "### MariaDB repo added ###" echo "### MariaDB repo added ###"
printf "\E[0m" printf "\E[0m"
} }
function add_postgresql_repo() {
printf "\E[0;35;40m"
echo '### Add PostgreSQL repo ###'
printf "\E[0m"
curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > /usr/share/keyrings/postgresql.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/postgresql.list
printf "\E[0;33;40m"
echo "### PostgreSQL repo added ###"
printf "\E[0m"
}
function add_tor_repo() { function add_tor_repo() {
printf "\E[0;35;40m" printf "\E[0;35;40m"
echo '### Add Tor repo ###' echo '### Add Tor repo ###'
@ -453,10 +487,11 @@ options=(1 "Install Packages" on # any option can be set to default to "on"
13 "Add Docker CE Repo" off 13 "Add Docker CE Repo" off
14 "Add Sury PHP Repo" off 14 "Add Sury PHP Repo" off
15 "Add MariaDB Repo" off 15 "Add MariaDB Repo" off
16 "Add Tor Project Repo" off 16 "Add PostgreSQL Repo" off
17 "Install acme.sh" off 17 "Add Tor Project Repo" off
18 "Install Rclone" off 18 "Install acme.sh" off
19 "Add update.sh" on) 19 "Install Rclone" off
20 "Add update.sh" on)
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear clear
for choice in $choices for choice in $choices
@ -508,15 +543,18 @@ do
add_mariadb_repo add_mariadb_repo
;; ;;
16) 16)
add_tor_repo add_postgresql_repo
;; ;;
17) 17)
add_acme_sh add_tor_repo
;; ;;
18) 18)
add_rclone add_acme_sh
;; ;;
19) 19)
add_rclone
;;
20)
add_update_sh add_update_sh
;; ;;
esac esac