Last active
April 28, 2023 10:21
-
-
Save matteocostantini/b05fa822f499324973a35166384ff091 to your computer and use it in GitHub Desktop.
Link your Debian Source Lists with Debian World Snapshot Time Machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# PAY ATTENTION!!!!! YOUR RISK!!!!! | |
# Inizializza la variabile con il valore di "lsb_release -sc" | |
distro=$(lsb_release -sc) | |
# Se è stato passato un argomento, sovrascrivi la variabile | |
if [ $# -eq 1 ]; then | |
distro=$1 | |
fi | |
# Verifica se il file /etc/apt/sources.list esiste | |
if [ ! -f "/etc/apt/sources.list.d/snapshot.list" ]; then | |
touch /etc/apt/sources.list.d/snapshot.list | |
fi | |
# Rimuove le righe che contengono "http://snapshot.debian.org/archive/debian" | |
sudo sed -i '/http:\/\/snapshot.debian.org\/archive\/debian/d' /etc/apt/sources.list.d/snapshot.list | |
echo "Le righe contenenti 'http://snapshot.debian.org/archive/debian' sono state rimosse da /etc/apt/sources.list.d/snapshot.list" | |
datetime=$(date +"%Y%m%dT%H%M%SZ") | |
url=http://snapshot.debian.org/archive/debian/${datetime}/ | |
effective_url=$(curl -o /dev/null -s -L -w "%{url_effective}\n" "$url") | |
# echo $effective_url | |
if [[ $effective_url =~ [0-9]{8}T[0-9]{6}Z ]]; then | |
echo "Scrivo i riferimenti di $effective_url nel file /etc/apt/sources.list.d/snapshot.list" | |
echo "deb [check-valid-until=no] $effective_url $distro main" > /etc/apt/sources.list.d/snapshot.list | |
echo "deb-src [check-valid-until=no] $effective_url $distro main" >> /etc/apt/sources.list.d/snapshot.list | |
apt update | |
else | |
echo "La stringa non contiene una data nel formato %Y%m%dT%H%M%SZ" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment