#!/bin/bash #by spiritlhl #from https://github.com/spiritLHLS/one-click-installation-script #version: 2022.12.18 red(){ echo -e "\033[31m\033[01m$1$2\033[0m"; } green(){ echo -e "\033[32m\033[01m$1$2\033[0m"; } yellow(){ echo -e "\033[33m\033[01m$1$2\033[0m"; } reading(){ read -rp "$(green "$1")" "$2"; } head() { # 支持系统:Ubuntu 12+,Debian 6+ ver="2022.12.18" changeLog="一键修复apt源,加载对应的源" clear echo "#######################################################################" echo "# ${YELLOW}一键修复apt源脚本${PLAIN} #" echo "# 版本:$ver #" echo "# 更新日志:$changeLog #" echo "# ${GREEN}作者${PLAIN}: spiritlhl #" echo "# ${GREEN}作仓库${PLAIN}: https://github.com/spiritLHLS/one-click-installation-script #" echo "#######################################################################" echo "支持系统:Ubuntu 12+,Debian 6+" echo "0.修复apt源broken损坏" echo "1.修复apt源锁死" echo "2.修复apt源公钥缺失" echo "3.修复替换系统可用的apt源列表,国内用阿里源,国外用官方源" echo "4.修复本机的Ubuntu系统是EOL非长期维护的版本,将替换为Ubuntu官方的old-releases仓库以支持apt的使用" # Display prompt asking whether to proceed with checking reading "Do you want to proceed with checking? [y/n] " confirm echo "" # Check user's input and exit if they do not want to proceed if [ "$confirm" != "y" ]; then exit 0 fi } change_debian_apt_sources() { # Check if the IP is in China ip=$(curl -s https://ipapi.co/ip) location=$(curl -s https://ipapi.co/$ip/country_name) # Backup current sources list cp /etc/apt/sources.list /etc/apt/sources.list.bak # Determine Debian version DEBIAN_VERSION=$(lsb_release -sr) if [ "$location" = "China" ]; then # IP is in China, update apt sources echo "IP is in China, updating apt sources." if [ "$DEBIAN_VERSION" = "6.0" ]; then # Debian 6 cat > /etc/apt/sources.list < /etc/apt/sources.list < /etc/apt/sources.list < /etc/apt/sources.list < /etc/apt/sources.list < /etc/apt/sources.list < /etc/apt/sources.list < /etc/apt/sources.list < /etc/apt/sources.list < /etc/apt/sources.list < /etc/apt/sources.list < /etc/apt/sources.list <