#!/bin/sh
# Copyright (c) 1997-2009, NeoNova BV, The Netherlands. All rights Reserved.
#
# This software is the copyrighted work of NeoNova BV.
# Use of the software is subject to the general business terms and conditions of NeoNova BV
# and its related transaction documents like license sheets or other written notices.
#
# Any reproduction or redistribution of the software not in accordance with the license terms
# is expressly prohibited by law, and may result in severe civil and criminally penalties.
# Violators will be prosecuted to the maximum extent possible.
#
# activate iaxy.
# but only if the config file changed
#

if [ $# -ne 2 ]
then
  echo usage: $0 tmpdir filename
  exit 1
fi

if [ ! -d $1 ]
then
  logger -i -t activate_iaxy "$1 is not a directory - quitting"
  exit 1;
fi

if [ ! -f $1/$2 ]
then
  logger -i -t activate_iaxy "$1/$2 not found - quitting"
  exit 1;
fi

# check to see if there have been changes.
diff -q $1/$2 $2  > /dev/null 2>&1
if [ $? -gt 0 ]
then
  IP=`grep host $1/$2 | cut -f2 -d' '` > /dev/null 2>&1
  /usr/local/astium/sbin/iaxyprov $IP $1/$2 > /dev/null
  logger -i -t activate_iaxy Provisioned $IP $1/$2
  cp $1/$2 /usr/local/astium/var/tftpboot
fi

exit 0

