xref: /freebsd/crypto/krb5/src/kprop/replica_update (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy Schubert#!/bin/sh
2*7f2fe78bSCy Schubert#
3*7f2fe78bSCy Schubert# Propagate if database (principal.db) has been modified since last dump
4*7f2fe78bSCy Schubert# (dumpfile.dump_ok) or if database has been dumped since last successful
5*7f2fe78bSCy Schubert# propagation (dumpfile.<replica machine>.last_prop)
6*7f2fe78bSCy Schubert
7*7f2fe78bSCy SchubertKDB_DIR=/usr/local/var/krb5kdc
8*7f2fe78bSCy Schubert
9*7f2fe78bSCy SchubertKDB_FILE=$KDB_DIR/principal.db
10*7f2fe78bSCy SchubertDUMPFILE=$KDB_DIR/replica_datatrans
11*7f2fe78bSCy SchubertKDB5_UTIL=/usr/local/sbin/kdb5_util
12*7f2fe78bSCy SchubertKPROP=/usr/local/sbin/kprop
13*7f2fe78bSCy Schubert
14*7f2fe78bSCy SchubertREPLICA=$1
15*7f2fe78bSCy Schubertif [ -z "${REPLICA}" ]
16*7f2fe78bSCy Schubertthen
17*7f2fe78bSCy Schubert  echo "Usage $0 replica_server"
18*7f2fe78bSCy Schubertfi
19*7f2fe78bSCy Schubert
20*7f2fe78bSCy Schubertif [ "`ls -t $DUMPFILE.dump_ok $KDB_FILE | sed -n 1p`"  = "$KDB_FILE" -o \
21*7f2fe78bSCy Schubert     "`ls -t $DUMPFILE.${REPLICA}.last_prop $DUMPFILE.dump_ok | \
22*7f2fe78bSCy Schubert		sed -n 1p`"  = "$DUMPFILE.dump_ok" ]
23*7f2fe78bSCy Schubertthen
24*7f2fe78bSCy Schubert
25*7f2fe78bSCy Schubert	date
26*7f2fe78bSCy Schubert	$KDB5_UTIL dump $DUMPFILE > /dev/null
27*7f2fe78bSCy Schubert
28*7f2fe78bSCy Schubert	$KPROP -d -f $DUMPFILE ${REPLICA}
29*7f2fe78bSCy Schubert	rm $DUMPFILE
30*7f2fe78bSCy Schubertfi
31