[Return to Library] [Contents] [Previous Chapter] [Next Section] [Next Chapter] [Index] [Help]


D    NIS ypservers Update Scripts

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


[Return to Library] [Contents] [Previous Chapter] [Next Section] [Next Chapter] [Index] [Help]


D.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 type the following lines exactly as shown:

    #!/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
    

  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 7.4.1 for more information.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Chapter] [Index] [Help]


D.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 type the following lines exactly as shown:

    #!/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
    

  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