Visitors: 14823822

Latest Articles

HOWTO: NIM server first boot example PDF Print E-mail
User Rating: / 2
Written by Michael Felt   

NIM and firstboot

One of my favorite NIM resources is the firstboot resource. I use it to setup many things and thought I would show you how I add nim to my /etc/hosts and also configure ntp (contents of /etc/ntp.conf and autostart xntpd service) - to name a few!

An excerpt from my NIM firstboot script

# NIM firstboot - author: Michael Felt, and
# released to public domain - March 2016

# Always have hostname in short form
hname=`hostname -s`
chdev -l inet0 -a hostname=${hname}

# create alias for nim
master=`grep NIM_MASTER_HOSTNAME /etc/niminfo | awk -F= ' { print $2 } '`
sed -e "s/${hname}.*/${hname} &/" </etc/hosts \
        | sed -e "s/${master}/& nim/" >/tmp/hosts
cat /tmp/hosts >/etc/hosts
rm /tmp/hosts

# add ntp.conf config and start xntpd
cat - >/etc/ntp.conf <<EOF
# Default NTP configuration file.
#   Broadcast client, no authentication.
# broadcastclient
driftfile /etc/ntp.drift
tracefile /etc/ntp.trace
# add whenevre possible - a local ntp server
server ntp.home.local

# external ntp servers - useful when you have direct (outgoing) access
# or, for configuring your local ntp server

# now -S, nextboot only without -S, i.e. -a is autostart (after reboot)
chrctcp -S -a xntpd
# get the clock close - within offset abs(1000)
setclock nim

# make sure root is 'unlimited'
chuser fsize=-1 cpu=-1 data=-1 stack=-1 core=-1 rss=-1 root

# set hostname lookup to local,bind - unless something already in image
grep hosts= /etc/netsvc.conf >/dev/null
[[ $? -ne 0 ]] && echo "hosts=local,bind" >> /etc/netsvc.conf

# some useful environment settings
print EDITOR=/usr/bin/vi >>/etc/environment
print 'RES_RETRY=2' >>/etc/environment
print 'RES_TIMEOUT=5' >>/etc/environment

# PS1 incudes loginName, hostname and current working directory
print 'PS1=$LOGNAME@`hostname`:\[\$PWD\]' >>/etc/profile
print 'export PS1' >>/etc/profile

# consider making PS1 readonly
print '# readonly PS1' >>/etc/profile


< Prev   Next >

Legacy PDFs

AIX 5.2
AIX 5.1