summaryrefslogtreecommitdiffstats
path: root/contrib/amd/scripts/amd2ldif.in
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>1998-08-23 22:07:21 +0000
committerobrien <obrien@FreeBSD.org>1998-08-23 22:07:21 +0000
commit663d5a0f32ed8dfc091ffb6153161591ac6ba563 (patch)
tree60b090a6cbdb64326bb128ea49a231d08eb2680e /contrib/amd/scripts/amd2ldif.in
downloadFreeBSD-src-663d5a0f32ed8dfc091ffb6153161591ac6ba563.zip
FreeBSD-src-663d5a0f32ed8dfc091ffb6153161591ac6ba563.tar.gz
Virgin import of AMD (am-utils) v6.0a16
Diffstat (limited to 'contrib/amd/scripts/amd2ldif.in')
-rwxr-xr-xcontrib/amd/scripts/amd2ldif.in58
1 files changed, 58 insertions, 0 deletions
diff --git a/contrib/amd/scripts/amd2ldif.in b/contrib/amd/scripts/amd2ldif.in
new file mode 100755
index 0000000..6d3c28a
--- /dev/null
+++ b/contrib/amd/scripts/amd2ldif.in
@@ -0,0 +1,58 @@
+#!@PERL@
+
+$usage=<<EOU;
+Usage $0 mapname base < mapfile >mapfile.ldif
+
+mapname: name of the amd map beeing converted to ldif
+base : The LDAP search base. Do not forget the quotes!
+
+This script should/could be used in a Makefile together
+with ldif2ldbm(8C) to automagically update the ldap
+databases and restart slapd whenever a master copy of
+the maps have changed. Remember "cd /var/yp; make" ?
+EOU
+
+my $fmt = "%-12s: %s\n";
+my $tfmt = "%-15s: %s\n";
+my $mapname = $ARGV[0] or die $usage;
+my $base = $ARGV[1] or die $usage;
+$time = time();
+
+print "dn: cn=amdmap timestamp, $base\n";
+printf "$tfmt", "cn", "amdmap timestamp";
+printf "$tfmt", "objectClass", "amdmapTimestamp";
+printf "$tfmt", "amdmapTimestamp", $time;
+print "\n";
+
+my $line = "";
+my $done = 0;
+
+while (<STDIN>) {
+ chomp;
+ if (/\s*(.+)\\\s*/) {
+ if ($line) {
+ $line .= " ".$1;
+ } else {
+ $line = $1;
+ }
+ $done = 0;
+ } else {
+ s/^\s+//g;
+ $line .= $_;
+ $done = 1;
+ }
+ if ($done) {
+ my @vals = split(/\s+/,$line);
+ my $key = shift @vals;
+ my $entry;
+
+ print "dn: cn=amdmap $mapname\[$key\], $base\n";
+ printf "$fmt","cn","amdmap $mapname\[$key\]";
+ printf "$fmt","objectClass", "amdmap";
+ printf "$fmt","amdmapName", $mapname;
+ printf "$fmt","amdmapKey", $key;
+ printf "$fmt","amdmapValue", join(' ',@vals);
+ print "\n";
+ $line = ""; $done = 0;
+ }
+}
OpenPOWER on IntegriCloud