freebsd-dev/gnu/usr.sbin/ypserv/mknetid
Bill Paul 85e33f94dc Added Makefile.yp and mknetid, which are needed to rebuild NIS maps.
mknetid is a script. Both are installed by an afterinstall which as
been added to the main Makefile.
1995-02-01 02:00:03 +00:00

37 lines
875 B
Bash

#!/bin/sh
#
# Produce netid.byname map file
#
# Written by O.Kirch, 1994.
#
PASSWD=$1
GROUP=$2
DOMAIN=$3
tempsed=/tmp/pass.$$
# First, get all login/uid info from passwd file
grep -v '^+:' $PASSWD |
awk -F: '{ printf "s/^%s:/%s/\n", $1, $3; }' >$tempsed
# next one is a giant pipe:
grep -v '^+:' $GROUP |
grep -v ':[ ]*$' |
sed 's/^[^:]*:[^:]*:\([0-9]*\):\(.*\)/\1,\2/' |
awk -F, '{ for (n=2; n<=NF; n++)
if ($n != "") print $n":\t"$1;
}' |
sed -f $tempsed | sort | grep -v ':' |
awk 'BEGIN { uid=-1; }
{ if (uid == $1) {
groups=groups","$2;
} else {
if (uid != -1)
print uid":"groups;
uid=$1; groups=$2;
}
}
END { if (uid != -1) printf("%s:%s\n", uid, groups); }' |
sed "s/\(.*\):/unix.\1@$DOMAIN &/"
rm -f $tempsed
exit 0