Add dkpg option to overwrite conf files

This commit is contained in:
Shivam Mathur 2024-06-16 03:18:27 +05:30
parent fc14643b0a
commit 4b56933e00
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -23,6 +23,10 @@ fix_broken_packages() {
# Function to install a package
install_packages() {
packages=("$@")
if ! [ -e /etc/dpkg/dpkg.cfg.d/force-confnew ]; then
echo "force-confnew" | sudo tee /etc/dpkg/dpkg.cfg.d/force-confnew >/dev/null 2>&1
trap "sudo rm -f /etc/dpkg/dpkg.cfg.d/force-confnew 2>/dev/null" exit
fi
$apt_install "${packages[@]}" >/dev/null 2>&1 || (update_lists && fix_broken_packages && $apt_install "${packages[@]}" >/dev/null 2>&1)
}