description "Update notification regarding a disk with packages"
author "Brian Murray <brian@ubuntu.com>"

start on (
    :sys:block-device-changed ID_FS_TYPE=iso9660 or
    :sys:block-device-added ID_FS_TYPE=iso9660 or
    block-device-changed ID_FS_TYPE=iso9660 or
    block-device-added ID_FS_TYPE=iso9660
)


script
DATE=$(date)
echo "$DATE CD found at $DEVNAME"
sleep 10
MOUNTPOINT=$(printf $(awk "{if (\$1 == \"$DEVNAME\") {print \$2}}" /proc/mounts ))
echo "CD mounted at $MOUNTPOINT"
if [ -L "$MOUNTPOINT/ubuntu" ] || [ -e "$MOUNTPOINT/cdromupgrade" ]
then
  echo "$DATE CD contains ubuntu data"
  /usr/lib/update-notifier/apt-cdrom-check "$MOUNTPOINT" || CDTYPE=$?
  if [ $CDTYPE -gt 0 ]
  then
    echo "$DATE CD type of $CDTYPE found"
    /usr/lib/update-notifier/distro-cd-updater $CDTYPE "$MOUNTPOINT"
  fi
fi
end script
