#!/bin/bash

if [ "$1" = "del" ]; then
  exit
fi

isnew_mac=$(cat /etc/dnsmasq.hostsfile|grep -v "^#"|grep "$2")

generatedhostname=$(echo "$2"| tr -d ':')

if [ -z "$isnew_mac" ]; then
  echo $2 PC$generatedhostname >> /etc/dnsmasq.hostsfile
  pid=`pidof dnsmasq`
  kill -HUP $pid 2> /dev/null
fi
