This is a discussion on Script for NIS update while using DHCP within the Sun Solaris Administration forums, part of the Solaris Operating System category; --> Hi all, I have read that we need a script in order to set up correctly NIS environment while ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| H4mm3r wrote: > Hi all, > > I have read that we need a script in order to set up correctly NIS > environment while using DHCP client on Solaris. > Any has a running script already available ? > > Thanks in advance. Where did you read that? |
| |||
| On 17 mar, 16:23, "Richard B. Gilbert" <rgilber...@comcast.net> wrote: > H4mm3r wrote: > > Hi all, > > > I have read that we need a script in order to set up correctly NIS > > environment while using DHCP client on Solaris. > > Any has a running script already available ? > > > Thanks in advance. > > Where did you read that? You can go to Solaris 10 documentation : http://docs.sun.com/app/docs/doc/816...min-570?a=view You'll read : If a DHCP client system is already running the Solaris OS, the NIS client is not automatically configured on that system when the DHCP server sends NIS information to the client. Tip - You can write a script that uses dhcpinfo and ypinit to automate NIS client configuration on DHCP client systems. It sounds weird to me especially considering that SUN is responsible for NIS. |
| |||
| H4mm3r wrote: > On 17 mar, 16:23, "Richard B. Gilbert" <rgilber...@comcast.net> wrote: > >>H4mm3r wrote: >> >>>Hi all, >> >>>I have read that we need a script in order to set up correctly NIS >>>environment while using DHCP client on Solaris. >>>Any has a running script already available ? >> >>>Thanks in advance. >> >>Where did you read that? > > > You can go to Solaris 10 documentation : > http://docs.sun.com/app/docs/doc/816...min-570?a=view > You'll read : > If a DHCP client system is already running the Solaris OS, the NIS > client is not automatically configured on that system when the DHCP > server sends NIS information to the client. > Tip - > > You can write a script that uses dhcpinfo and ypinit to automate NIS > client configuration on DHCP client systems. > > It sounds weird to me especially considering that SUN is responsible > for NIS. As I read it, DHCP will send NIS server addresses but this is not sufficient to configure NIS on the client. Here's a script I have used in the past to setup NIS clients. #! /bin/sh -v # # Set up an NIS client system. The domainname and the server's name and # IP address are passed as parameters. # # We use a modified version of /etc/nsswitch.files for nsswitch.conf. # The passwd and group lines have been modified by appending " nis" and # the hosts line has been modified by appending " dns". We copy the # desired nsswitch.conf file from floppy disk. # domainname {$1} echo `domainname` > /etc/defaultdomain echo {$2} >> /etc/inet/hosts cp /floppy/noname/nsswitch.conf /etc/nsswitch.conf # # This bit matches the string contained in the second argument to this # script in /etc/inet/hosts, extracts the second field, the hostname, # and passes it via a pipe to ypinit. # nawk "/$2/ {print \$2}" /etc/inet/hosts | /usr/sbin/ypinit -c # Start the yp daemon. /usr/lib/netsvc/yp/ypstart # # Done! Now verify that it works. This should output a list of # all the NIS maps together with the name of the server each came # from; e.g. # mail.aliases thcmp01 # netid.byname thcmp01 # mail.byaddr thcmp01 # . . . # ypwhich -m |
| ||||
| Thanks for the proposal. I had to write my own script : #!/bin/sh HOST_FIC="/etc/hosts" TEMP_FIC="/tmp/hosts" NIS_DIR="/var/yp/binding/" NIS_FIC="/ypservers" NIS_STR="nis_server" [ `ifconfig -a | grep -ic dhcp ` -eq 0 ] && exit 0 /sbin/dhcpinfo NISdmain > /etc/defaultdomain domain=`/sbin/dhcpinfo NISdmain` echo $domain > /etc/defaultdomain domainname $domain mkdir -p $NIS_DIR$domain cptr=1 cat /dev/null > $NIS_DIR$domain$NIS_FIC cat $HOST_FIC | grep -v $NIS_STR > $TEMP_FIC$$ cat $TEMP_FIC$$ > $HOST_FIC for i in `/sbin/dhcpinfo NISservs` ; do cat $HOST_FIC | grep -v $i > $TEMP_FIC$$ cat $TEMP_FIC$$ > $HOST_FIC echo $i" "$NIS_STR$cptr" # Added for NIS binding" >> $HOST_FIC echo $NIS_STR$cptr >> $NIS_DIR$domain$NIS_FIC cptr=`expr $cptr + 1` done rm -f $TEMP_FIC$$ exit 0 Of course, ypwhich has not a sexy output. So, once NIs is up, you can redo it in order to have the good hostname for each NIS server. |