3
# ypinit - set up the YP directory on a master server or a slave server.
15
### some functions, which make the life easier
19
if [ $HOST = $MASTER ]
21
echo "The host specified should be a running master NIS server, not this machine."
24
# maps=`ypwhich -m | egrep $MASTER$| awk '{ printf("%s ",$1) }' -`
25
maps=`$YPBINDIR/yphelper --maps $MASTER`
29
echo "Can't enumerate maps from $MASTER. Please check that it is running."
33
mkdir -p $YPMAPDIR/$DOMAIN
35
echo "We will need a few minutes to copy the data from $MASTER."
39
echo "Transferring $map..."
40
$YPBINDIR/ypxfr -f -h $MASTER -c -d $DOMAIN $map
44
echo "YPINIT: WARNING: Couldn't exec $YPBINDIR/ypxfr -f -h $MASTER -c -d $DOMAIN $map"
49
echo "${HOST}'s NIS data base has been set up."
50
echo "If there were warnings, please figure out what went wrong, and fix it."
52
echo "At this point, make sure that /etc/passwd and /etc/group have"
53
echo "been edited so that when the NIS is activated, the data bases you"
54
echo "have just created will be used, instead of the /etc ASCII files."
62
mkdir -p $YPMAPDIR/$DOMAIN
64
rm -f $YPMAPDIR/$DOMAIN/*
66
while [ $is_correct = F ]; do
67
echo $HOST >$YPMAPDIR/ypservers
69
echo "At this point, we have to construct a list of the hosts which will run NIS"
70
echo "servers. $HOST is in the list of NIS server hosts. Please continue to add"
71
echo "the names for the other hosts, one per line. When you are done with the"
72
echo "list, type a <control D>."
73
echo " next host to add: $HOST"
74
echo -n " next host to add: "
78
echo -n " next host to add: "
79
echo $h >>$YPMAPDIR/ypservers
83
echo "The current list of NIS servers looks like this:"
86
cat $YPMAPDIR/ypservers
88
echo -n "Is this correct? [y/n: y] "
92
N) echo "Let's try again...";;
93
n) echo "Let's try again...";;
98
echo "We need a few minutes to build the databases..."
99
echo "Building $YPMAPDIR/$DOMAIN/ypservers..."
100
cat $YPMAPDIR/ypservers | awk '{print $$0, $$0}' | $YPBINDIR/makedbm - $YPMAPDIR/$DOMAIN/ypservers
104
echo "Couldn't build yp data base $YPMAPDIR/$DOMAIN/ypservers."
105
echo "Please fix it."
108
echo "Running $YPMAPDIR/Makefile..."
109
cd $YPMAPDIR && make NOPUSH=true
113
echo "Error running Makefile."
114
echo "Please try it by hand."
117
echo "$HOST has been set up as a NIS master server."
119
echo "Now you can run ypinit -s $HOST on all slave server."
127
echo " ypinit -s master"
129
echo "where -m is used to build the data bases on a master NIS server,"
130
echo "and -s is used for a slave data base. master must be an existing"
131
echo "reachable NIS server."
137
### Begin of the shell script
139
HOST=`$YPBINDIR/yphelper --hostname`
142
echo "Can't get local host's name. Please check your path."
148
echo "The local host's name hasn't been set. Please set it."
155
echo "Can't find domainname. Please fix your PATH"
161
echo "The local host's domain name hasn't been set. Please set it."
165
if [ ! -d $YPMAPDIR -o -f $YPMAPDIR ]
167
echo "The directory $YPMAPDIR doesn't exist."
168
echo "Create it or run make install-* from the sourcen."