2023-05-29 13:32:19 +02:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
################################################################################
|
2023-11-22 21:49:23 +01:00
|
|
|
## File: configure-apt-sources.sh
|
|
|
|
|
## Desc: Configure apt sources with failover from Azure to Ubuntu archives.
|
2023-05-29 13:32:19 +02:00
|
|
|
################################################################################
|
|
|
|
|
|
2024-11-04 15:28:58 +01:00
|
|
|
source $HELPER_SCRIPTS/os.sh
|
|
|
|
|
|
2023-08-11 14:30:33 +02:00
|
|
|
touch /etc/apt/apt-mirrors.txt
|
2023-05-29 13:32:19 +02:00
|
|
|
|
2023-08-11 14:30:33 +02:00
|
|
|
printf "http://azure.archive.ubuntu.com/ubuntu/\tpriority:1\n" | tee -a /etc/apt/apt-mirrors.txt
|
2025-04-11 11:53:08 -06:00
|
|
|
printf "https://archive.ubuntu.com/ubuntu/\tpriority:2\n" | tee -a /etc/apt/apt-mirrors.txt
|
|
|
|
|
printf "https://security.ubuntu.com/ubuntu/\tpriority:3\n" | tee -a /etc/apt/apt-mirrors.txt
|
2023-08-11 14:30:33 +02:00
|
|
|
|
2024-11-04 15:28:58 +01:00
|
|
|
if is_ubuntu24; then
|
2025-06-12 21:17:41 +05:30
|
|
|
sed -i 's|http://azure\.archive\.ubuntu\.com/ubuntu/|mirror+file:/etc/apt/apt-mirrors.txt|' /etc/apt/sources.list.d/ubuntu.sources
|
2023-08-11 14:30:33 +02:00
|
|
|
|
2024-11-04 15:28:58 +01:00
|
|
|
# Apt changes to survive Cloud Init
|
|
|
|
|
cp -f /etc/apt/sources.list.d/ubuntu.sources /etc/cloud/templates/sources.list.ubuntu.deb822.tmpl
|
|
|
|
|
else
|
2025-06-12 21:17:41 +05:30
|
|
|
sed -i 's|http://azure\.archive\.ubuntu\.com/ubuntu/|mirror+file:/etc/apt/apt-mirrors.txt|' /etc/apt/sources.list
|
2024-11-04 15:28:58 +01:00
|
|
|
|
|
|
|
|
# Apt changes to survive Cloud Init
|
|
|
|
|
cp -f /etc/apt/sources.list /etc/cloud/templates/sources.list.ubuntu.tmpl
|
|
|
|
|
fi
|