C    NIS ypservers Update Scripts

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

C.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. Where method appears, specify the format in which the map is to be stored:

    #!/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 -a method tmpmap
    mv tmpmap.dir $DOMAIN/ypservers.dir
    mv tmpmap.pag $DOMAIN/ypservers.pag
    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 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 8.4.1 for more information.

C.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. Where method appears, specify the format in which the map is to be stored:

    #!/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 -a method tmpmap
    mv tmpmap.dir $DOMAIN/ypservers.dir
    mv tmpmap.pag $DOMAIN/ypservers.pag
    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