Skip to content

Instantly share code, notes, and snippets.

@flying-sausages
Created May 3, 2020 04:23
Show Gist options
  • Save flying-sausages/a77c871952ece23fe58fb48bbb6f9a95 to your computer and use it in GitHub Desktop.
Save flying-sausages/a77c871952ece23fe58fb48bbb6f9a95 to your computer and use it in GitHub Desktop.
Making apt installs safe in non-interactive scripts
#!/bin/bash
packages="zsh htop"
logfile="~/apt.log"
touch "$logfile"
for package in packages; do
DEBIAN_FRONTEND=noninteractive apt-get install -qy -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" "$package" >>"${logfile}" 2>&1
done
@flying-sausages
Copy link
Author

make sure to check the logfile in case new config versions were installed on the side, and alert user about this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment