Unix Technical Forum

Script for NIS update while using DHCP

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 ...


Go Back   Unix Technical Forum > Unix Operating Systems > Solaris Operating System > Sun Solaris Administration

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-28-2008, 05:31 AM
H4mm3r
 
Posts: n/a
Default Script for NIS update while using DHCP

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-28-2008, 05:31 AM
Richard B. Gilbert
 
Posts: n/a
Default Re: Script for NIS update while using DHCP

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?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-28-2008, 05:31 AM
H4mm3r
 
Posts: n/a
Default Re: Script for NIS update while using DHCP

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-28-2008, 05:31 AM
Richard B. Gilbert
 
Posts: n/a
Default Re: Script for NIS update while using DHCP

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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-28-2008, 05:31 AM
H4mm3r
 
Posts: n/a
Default Re: Script for NIS update while using DHCP

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:11 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com