#!/bin/bash
# Filename:      ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/94-update-smart-drivedb
# Purpose:       update pciids
# Authors:       (c) Michael Prokop <mika@grml.org>
# Bug-Reports:   see http://grml.org/bugs/
# License:       This file is licensed under the GPL v2.
################################################################################

if ifclass NO_ONLINE ; then
  echo "Ignoring script 94-update-smart-drivedb as NO_ONLINE is set."
  exit 0
fi

set -u
set -e

[ -x $target/usr/bin/timeout ] && TIMEOUT="10" || TIMEOUT=""

if ! [ -x ${target}/usr/sbin/update-smart-drivedb ] ; then
  echo "NOTE: update-smart-drivedb not present (possibly smartmontools >=6.4+svn4214-1 present)"
  exit 0
fi

echo "Updating smartmontool drivedb"
if [ -n "$TIMEOUT" ] ; then
   if ! $ROOTCMD timeout $TIMEOUT update-smart-drivedb ; then
     echo "Warning: failed to update smartmontool drivedb, ignoring failure"
   fi
else
   if ! $ROOTCMD update-smart-drivedb ; then
     echo "Warning: failed to update smartmontool drivedb, ignoring failure"
   fi
fi

## END OF FILE #################################################################
# vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2
