#!/bin/bash
set -e

UPDATENOTIFIERDIR=/var/lib/update-notifier/user.d

echo "Please restart all running instances of Nautilus, or you will experience problems. i.e. nautilus --quit"

if [ -d $UPDATENOTIFIERDIR ] ; then
  # pgrep matches application names from /proc/<pid>/status which is
  # truncated according to sys/procfs.h definition. Problem is it's
  # platform dependent. Either 15 or 16 chars.
  if [ `pgrep -x -c nautilus` -ne 0 ];  then
    cp -f /usr/share/groundcontrol/groundcontrol-restart-required.update-notifier \
        $UPDATENOTIFIERDIR/groundcontrol-restart-required
        # sometimes this doesn't happen:
    touch /var/lib/update-notifier/dpkg-run-stamp
  else
    rm -f $UPDATENOTIFIERDIR/groundcontrol-restart-required
  fi
fi

#DEBHELPER#

exit 0
