#!/bin/sh
apt-get -f dselect-upgrade
RES=$?

# 1 means the user choose no at the prompt
if [ $RES -eq 1 ]; then
  exit 0
fi

if [ $RES -eq 0 ]; then
   apt-get clean && echo "Press enter to continue." && read && exit 0;
else
   echo "Some errors occured while unpacking. I'm going to configure the"
   echo "packages that were installed. This may result in duplicate errors"
   echo "or errors caused by missing dependencies. This is OK, only the errors"
   echo "above this message are important. Please fix them and run [I]nstall again"
   echo "Press enter to contiune."
   read && dpkg --configure -a
   exit 100
fi

exit $?
