mirror of
https://github.com/spiritLHLS/one-click-installation-script.git
synced 2024-11-16 07:32:19 +08:00
Update package.sh
This commit is contained in:
parent
7d9fa02750
commit
d71712777f
110
package.sh
110
package.sh
|
@ -41,8 +41,6 @@ change_debian_apt_sources() {
|
|||
cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
# Determine Debian version
|
||||
DEBIAN_VERSION=$(lsb_release -sr)
|
||||
# Get the current system version
|
||||
DEBIAN_VERSION=$(lsb_release -sr)
|
||||
|
||||
if [ "$location" = "China" ]; then
|
||||
# IP is in China, update apt sources
|
||||
|
@ -165,58 +163,66 @@ EOF
|
|||
|
||||
|
||||
change_ubuntu_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)
|
||||
|
||||
# Check the system's Ubuntu version
|
||||
ubuntu_version=$(lsb_release -r | awk '{print $2}')
|
||||
|
||||
if [ "$ubuntu_version" = "12.04" ]; then
|
||||
# Backup the current sources.list
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
# Write the Ubuntu 12.04 apt sources list that can be used with apt to sources.list
|
||||
echo "deb http://old-releases.ubuntu.com/ubuntu precise main restricted universe multiverse" | sudo tee /etc/apt/sources.list
|
||||
echo "deb http://old-releases.ubuntu.com/ubuntu precise-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://old-releases.ubuntu.com/ubuntu precise-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
elif [ "$ubuntu_version" = "14.04" ]; then
|
||||
# Backup the current sources.list
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
# Write the standard Ubuntu 14.04 apt sources list to sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse" | sudo tee /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
elif [ "$ubuntu_version" = "16.04" ]; then
|
||||
# Backup the current sources.list
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
# Write the standard Ubuntu 16.04 apt sources list to sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse" | sudo tee /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu xenial-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu xenial-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
elif [ "$ubuntu_version" = "18.04" ]; then
|
||||
# Backup the current sources.list
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
# Write the standard Ubuntu 18.04 apt sources list to sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse" | sudo tee /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu bionic-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
elif [ "$ubuntu_version" = "20.04" ]; then
|
||||
# Backup the current sources.list
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
# Write the standard Ubuntu 20.04 apt sources list to sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse" | sudo tee /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu focal-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
elif [ "$ubuntu_version" = "22.04" ]; then
|
||||
# Backup the current sources.list
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
# Write the standard Ubuntu 22.04 apt sources list to sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu hirsute main restricted universe multiverse" | sudo tee /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu hirsute-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu hirsute-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu hirsute-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
else
|
||||
echo "The system is not Ubuntu 12/14/16/18/20/22 . No changes were made to the apt sources."
|
||||
if [ "$location" = "China" ]; then
|
||||
# IP is in China, update apt sources
|
||||
echo "IP is in China, updating apt sources."
|
||||
else:
|
||||
if [ "$ubuntu_version" = "12.04" ]; then
|
||||
# Backup the current sources.list
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
# Write the Ubuntu 12.04 apt sources list that can be used with apt to sources.list
|
||||
echo "deb http://old-releases.ubuntu.com/ubuntu precise main restricted universe multiverse" | sudo tee /etc/apt/sources.list
|
||||
echo "deb http://old-releases.ubuntu.com/ubuntu precise-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://old-releases.ubuntu.com/ubuntu precise-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
elif [ "$ubuntu_version" = "14.04" ]; then
|
||||
# Backup the current sources.list
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
# Write the standard Ubuntu 14.04 apt sources list to sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse" | sudo tee /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
elif [ "$ubuntu_version" = "16.04" ]; then
|
||||
# Backup the current sources.list
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
# Write the standard Ubuntu 16.04 apt sources list to sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse" | sudo tee /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu xenial-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu xenial-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
elif [ "$ubuntu_version" = "18.04" ]; then
|
||||
# Backup the current sources.list
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
# Write the standard Ubuntu 18.04 apt sources list to sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse" | sudo tee /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu bionic-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
elif [ "$ubuntu_version" = "20.04" ]; then
|
||||
# Backup the current sources.list
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
# Write the standard Ubuntu 20.04 apt sources list to sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse" | sudo tee /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu focal-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
elif [ "$ubuntu_version" = "22.04" ]; then
|
||||
# Backup the current sources.list
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
# Write the standard Ubuntu 22.04 apt sources list to sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu hirsute main restricted universe multiverse" | sudo tee /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu hirsute-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu hirsute-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
echo "deb http://archive.ubuntu.com/ubuntu hirsute-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
else
|
||||
echo "The system is not Ubuntu 12/14/16/18/20/22 . No changes were made to the apt sources."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user