#!/bin/bash
#
# pts-db-entry  This shell script makes sure the pts databse contains an
#               entry for the IP address of this host.
#
# chkconfig: 345 60 20
# description: This shell script makes sure the pts databse contains an
#               entry for the IP address of this host.

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

start() {
        #/bin/hostname -i | /usr/bin/xargs --no-run-if-empty /usr/bin/pts examine 2>/dev/null | /usr/bin/logger -t pts-db-entry
        /bin/hostname -i | /usr/bin/xargs --no-run-if-empty /usr/bin/pts examine 1>/dev/null 2>/dev/null
        RETVAL=$?
        if [ $RETVAL -ne 0 ]
        then
            /usr/bin/logger -t pts-db-entry Create PTS identity
            /usr/bin/cern-config-keytab -I -v 1>/dev/null 2>/dev/null
            RETVAL=$?
        else
            /usr/bin/logger -t pts-db-entry PTS identity already exists
        fi
        return $RETVAL
}

stop() {
        # nothing to do
        return 0
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status $prog
        ;;
  restart|force-reload)
        stop
        start
        ;;
  try-restart|condrestart)
        if status $prog > /dev/null; then
            stop
            start
        fi
        ;;
  reload)
        exit 3
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
        exit 2
esac

