Ubuntu – Lost SSH during ‘apt upgrade’ – stuck at configuration screen

aptsshUbuntu

While doing a run of the mill apt upgrade, a Tomcat 7 post install script ran with the common A new version of configuration file /etc/default/tomcat7 is available.... Unfortunately, I didn't attend to it quickly enough and the SSH connection was reset. How do I recover from this? Can I reattach to the post install screen? Is it safe to kill it? If I kill it, is there a script somewhere I should be manually executing?

I saw this question about doing an upgrade of OS versions, but either the solution (screen -r) isn't relevant or I'm not using it correctly.

$ screen -r
There is no screen to be resumed.

I can see the process running:

$ ps -a
  PID TTY          TIME CMD
  416 pts/2    00:00:00 frontend
  423 pts/2    00:00:00 tomcat7.postins
  430 pts/2    00:00:00 ucf
  475 pts/2    00:00:00 whiptail
  634 pts/1    00:00:00 ps

As suggested by Dmitry Zayats I've looked at the Tomcat 7 post install script. In my installation of Ubuntu 14.04, it's found here: /var/lib/dpkg/info/tomcat7.postinst

Opening that up, I believe I see the relevant line where I initially lost my connection:

ucf --debconf-ok --sum-file /usr/share/tomcat7/defaults.md5sum $tmpfile $CONFFILE

Best Answer

Kill the dpkg/apt session and re-issue the command. It will re-deploy in-progress packages. With most pre/post install scripts it will work out okay. In the few cases where the upgrades packages don't work as expected, reinstall the packages.

And, as the others said: tmux/screen.