#!/bin/bash
#
# updates - perform one time updates at boot time using files in /etc/postplug/updates.d
#
# Copyright (c) 2010-2011 by Silvan Calarco <silvan.calarco@mambasoft.it>
#

me="updates"

. /etc/postplug/postplug.defs

for u in `ls /etc/postplug/updates.d/*.upd 2>/dev/null`; do
   f=`basename $u`
   grep $f $postpluglibdir/updates.cache 2>/dev/null >/dev/null || {
      if [ ! -e $postpluglibdir/firsttime ]; then
         logmsg "$me" "running updates script $u"
         sh $u
         [ $? -ne 0 ] && {
            logmsg "$me" "error: $f update script failed with exit code $?"
            continue
         }
      fi
      echo "$f" >> $postpluglibdir/updates.cache
   }
done
