Skip to content

Instantly share code, notes, and snippets.

@jaka
Created August 6, 2023 13:33
Show Gist options
  • Save jaka/70c835ff6f48b642dfefe62ed40a935c to your computer and use it in GitHub Desktop.
Save jaka/70c835ff6f48b642dfefe62ed40a935c to your computer and use it in GitHub Desktop.
Upgrade to Debian Bookworm
find /var/lib/apt/lists/ -mindepth 1 -maxdepth 1 -type f -size +0 -print -delete
file=/etc/apt/sources.list
if [ -f "$file" ]; then
owner=$(stat -c %U:%G "$file")
perms=$(stat -c %a "$file")
mv -v "$file" "$file.$(date +%y%m%d%H%M%S)"
fi
[ -z "$owner" ] || owner="root:root"
[ -z "$perms" ] || perms=644
cat <<EOF >"$file"
deb http://deb.debian.org/debian/ bookworm main
deb http://security.debian.org/debian-security bookworm-security main
deb http://deb.debian.org/debian/ bookworm-updates main
EOF
chown $owner "$file"
chmod $perms "$file"
apt-get update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment