#!/bin/bash
dnsgit='https://infrastructure.fedoraproject.org/infra/dns.git'
destdir='/var/named/master/'

if [ ! -d $destdir ];
then
  git clone $dnsgit $destdir
fi

cd $destdir
git fetch origin

if [ "`git diff origin/master`" != "" ];
then
  git pull -X theirs
  # change context so the chroot can cope
  chown -R named.named $destdir
  chcon -u system_u $destdir/* $destdir/*/*
  # reload named
  /sbin/service named start >>/dev/null 2>&1
  /sbin/service named reload >>/dev/null 2>&1
fi
