SecPod Community › Forums › SanerScript › Script to Update Devices Apt Repos
Tagged: SanerScripts
- This topic has 0 replies, 1 voice, and was last updated by
Community Manager.
-
AuthorPosts
-
-
March 3, 2025 at 8:04 am #6360
#!/bin/sh
# Backup the original sources.list
mv /etc/apt/sources.list /etc/apt/sources.list.bak
# Create a new sources.list file in the sources.list.d directory
touch /etc/apt/sources.list.d/sources.list
# Get the OS version
os_version=$(lsb_release -sr)
echo “OS version is $os_version”
# Populate the sources.list.d/sources.list based on OS version
if [ “$os_version” = “20.04” ]; then
cat <<EOL >> /etc/apt/sources.list.d/sources.list
deb http://in.archive.ubuntu.com/ubuntu/ focal main restricted
deb http://in.archive.ubuntu.com/ubuntu/ focal-updates main restricted
deb http://in.archive.ubuntu.com/ubuntu/ focal universe
deb http://in.archive.ubuntu.com/ubuntu/ focal-updates universe
deb http://in.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://in.archive.ubuntu.com/ubuntu/ focal-updates multiverse
deb http://in.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://security.ubuntu.com/ubuntu focal-security universe
deb http://security.ubuntu.com/ubuntu focal-security multiverse
EOL
#elif [ “$os_version” = “22.04” ]; then
else
cat <<EOL >> /etc/apt/sources.list.d/sources.list
deb http://in.archive.ubuntu.com/ubuntu/ jammy main restricted
deb http://in.archive.ubuntu.com/ubuntu/ jammy-updates main restricted
deb http://in.archive.ubuntu.com/ubuntu/ jammy universe
deb http://in.archive.ubuntu.com/ubuntu/ jammy-updates universe
deb http://in.archive.ubuntu.com/ubuntu/ jammy multiverse
deb http://in.archive.ubuntu.com/ubuntu/ jammy-updates multiverse
deb http://in.archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu jammy-security main restricted
deb http://security.ubuntu.com/ubuntu jammy-security universe
deb http://security.ubuntu.com/ubuntu jammy-security multiverse
EOL
#elif [ “$os_version” = “18.04” ]; then
# cat <<EOL >> /etc/apt/sources.list.d/sources.list
#deb http://in.archive.ubuntu.com/ubuntu/ bionic main restricted
#deb http://in.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
#deb http://in.archive.ubuntu.com/ubuntu/ bionic universe
#deb http://in.archive.ubuntu.com/ubuntu/ bionic-updates universe
#deb http://in.archive.ubuntu.com/ubuntu/ bionic multiverse
#deb http://in.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
#deb http://in.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
#deb http://security.ubuntu.com/ubuntu bionic-security main restricted
#deb http://security.ubuntu.com/ubuntu bionic-security universe
#deb http://security.ubuntu.com/ubuntu bionic-security multiverse
#EOL
#else
# echo “Expected OS not found”
# exit 1
fi
# Checking the apt-get update
#update_output=$(sudo apt-get update 2>&1)
-
-
AuthorPosts
- You must be logged in to reply to this topic.