B    NIS ypservers Update Scripts

This appendix provides the following scripts for updating the ypservers map:

B.1    Add Slave Server Script

Use the following procedure to create the addypserver script on an NIS master server:

  1. Create an addypserver file in the /var/yp directory and insert the following lines:

    #!/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`
    METHOD=`/usr/sbin/rcmgr get NIS_SERVERARGS d`
    cd /var/yp
    echo "
    Adding $1 to ypservers map for domain DOMAIN ..."
    (/var/yp/makedbm -a $METHOD -u $DOMAIN/ypservers;\
    echo $1 $1) | /var/yp/makedbm -a $METHOD $DOMAIN/ypservers
    /var/yp/yppush ypservers
    

  2. Set the permissions to 700, using the chmod command as follows:

    # 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 hosts source file and add an entry for the slave server, if it is not already in the hosts file. Then, update and distribute the hosts map by entering the make command. See Section 3.4.1 for more information.

B.2    Remove Slave Server Script

Use the following procedure to create the rmypserver script on an NIS master server:

  1. Create a rmypserver file in the /var/yp directory and insert the following lines:

    #!/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`
    METHOD=`/usr/sbin/rcmgr get NIS_SERVERARGS d`
    cd /var/yp
    echo "
    Removing $1 from ypservers map for domain DOMAIN ..."
    /var/yp/makedbm -a $METHOD -u $DOMAIN/ypservers | grep -v "^$1 " \
    | /var/yp/makedbm -a $METHOD $DOMAIN/ypservers
    /var/yp/yppush ypservers
    

  2. Set the permissions to 700, using the chmod command as follows:

    # chmod 700 /var/yp/rmypserver
    

To remove host1 from the ypservers map, enter the following command:

# /var/yp/rmypserver host1

You still need to edit the NIS master server's hosts source file and remove the entry for the slave server. Then, update and distribute the hosts map by entering the make command. See Section 3.4.2 for more information.