This appendix provides the following scripts for updating the ypservers map:
Use the following procedure to create the addypserver script on an NIS master server:
#!/bin/sh PATH="/usr/bin:/var/yp:$PATH" if [ $# != 1 ]; then echo "usage: $0 server"; exit 1 fi DOMAIN=`/usr/sbin/rcmgr get NIS_DOMAIN` cd /var/yp echo " Adding $1 to ypservers map for domain DOMAIN ..." (/var/yp/makedbm -u $DOMAIN/ypservers;\ echo $1 $1) | /var/yp/makedbm - tmpmap mv tmpmap.dir $DOMAIN/ypservers.dir mv tmpmap.pag $DOMAIN/ypservers.pag yppush ypservers
#
chmod 700 /var/yp/addypserver
To add host1 to the ypservers map, enter the following command:
#
/var/yp/addypserver host1
You still need to edit the NIS master server's master hosts file and add an entry for the slave server, if it is not already in the hosts file. Then, update and distribute the map by entering the make command. See Section 7.4.1 for more information.
Use the following procedure to create the rmypserver script on an NIS master server:
#!/bin/sh PATH="/usr/bin:/var/yp:$PATH" if [ $# != 1 ]; then echo "usage: $0 server"; exit 1 fi DOMAIN=`/usr/sbin/rcmgr get NIS_DOMAIN` cd /var/yp echo " Removing $1 from ypservers map for domain DOMAIN ..." /var/yp/makedbm -u $DOMAIN/ypservers | grep -v $1 \ | /var/yp/makedbm - tmpmap mv tmpmap.dir $DOMAIN/ypservers.dir mv tmpmap.pag $DOMAIN/ypservers.pag yppush ypservers
#
chmod 700 /var/yp/rmypserver
To remove host1 from the ypservers map, enter the following command:
#
/var/yp/rmypserver host1