Skip to content

Instantly share code, notes, and snippets.

@scicco
Last active August 24, 2020 12:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scicco/432ebe01ac0e7b371f3155839c85ecbc to your computer and use it in GitHub Desktop.
Save scicco/432ebe01ac0e7b371f3155839c85ecbc to your computer and use it in GitHub Desktop.
#!/bin/bash
for listfile in /var/lib/dpkg/info/*.list.broken; do
#echo ${listfile##*/}
listfilename=$(basename -- "$listfile")
listfilename="${listfilename%.*}"
echo "list file name: ${listfilename}"
if [ -f "/var/lib/dpkg/info/${listfilename}" ]; then
output=$(file "/var/lib/dpkg/info/${listfilename}" | awk '{print $2}')
echo $output
#break
if [[ $output == *"data"* ]]; then
echo "$(filename) is still DATA!!!"
#something is not working, let's stop
break
else
continue
fi
fi
listfilename="${listfilename%.*}"
#echo ${listfilename}
echo "program name: ${listfilename}"
#break
output=$(file ${listfile}| awk '{print $2}')
#echo "${output}"
if [[ $output == *"data"* ]]; then
echo "${listfile} is DATA!"
echo "${listfilename}"
#echo "apt-get install -y $listfilename --reinstall || exit $?"
apt-get install -y "${listfilename}" --reinstall || exit $?
#stop after one install, check that everything works then lauch this script again ;-)
break
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment