Showing posts with label NIM. Show all posts
Showing posts with label NIM. Show all posts

Thursday, 23 January 2014

" $0" Parameter Shell Scripting

$0 is one of the Bash special parameters. It can only be referenced as follows (just an example as there are various ways to reference and use $0 while scripting) :
echo "$0"
echo "Usage: $0 fileName"
However, assignment to it is not allowed:


$0 expands to the name of the shell or shell script. This is set at shell initialization. If bash is invoked with a file of commands, $0 is set to the name of that file. It is often used to display script usage message:
 # if filename not supplied at the command prompt
# display usae message and die
[ $# -eq 0 ] && { echo "Usage: $0 filename"; exit 1; }
echo "Script name: $0"
echo "\$1 = $1, so \$_file set to $1"
# if file not found, display an error and die
[ ! -f "$_file" ] && { echo "$0: $_file file not found."; exit 2; }
# if we are here, means everything is okay
echo "Processing $_file..."
Save and close the file. You can run it as follows:
chmod +x 
Sample outputs:
Usage: ./ filename 
Now, try to pass /etc/passwd filename :
./ /etc/passwd
Sample outputs:
./ /etc/passwd
Script name: ./
$1 = /etc/passwd, so $_file set to /etc/passwd
Processing /etc/passwd...
Finally, try to pass any /nonexistencefile.txt filename :
./ /nonexistencefile.txt
Sample outputs:
Script name: ./
$1 = /nonexistencefile.txt, so $_file set to /nonexistencefile.txt
./ /nonexistencefile.txt file not found.
If bash is started with the -c option, then $0 is set to the first argument after the string to be executed, if one is present. Otherwise, it is set to the file name used to invoke bash, as given by argument zero.

Friday, 17 May 2013

Adding a fileset to a SPOT

For example, if you wish to add the bos.alt_disk_install.rte fileset to a SPOT:

List the available spots:
# lsnim -t spot | grep 61
SPOTaix61tl05sp03     resources       spot
SPOTaix61tl03sp07     resources       spot
List the available lpp sources:
# lsnim -t lpp_source | grep 61
LPPaix61tl05sp03       resources       lpp_source
LPPaix61tl03sp07       resources       lpp_source
Check if the SPOT already has this file set:
# nim -o showres SPOTaix61tl05sp03 | grep -i bos.alt
No output is shown. The fileset is not part of the SPOT. Check if the LPP Source has the file set:
# nim -o showres LPPaix61tl05sp03 | grep -i bos.alt
  bos.alt_disk_install.boot_images                    I  N usr
  bos.alt_disk_install.rte                    I  N usr,root
Install the first fileset (bos.alt_disk_install.boot_images) in the SPOT. The other fileset is a prerequisite of the first fileset and will be automatically installed as well.
# nim -o cust -a filesets=bos.alt_disk_install.boot_images
-a lpp_source=LPPaix61tl05sp03 SPOTaix61tl05sp03
Note: Use the -F option to force a fileset into the SPOT, if needed (e.g. when the SPOT is in use for a client). 

Check if the SPOT now has the fileset installed:

# nim -o showres SPOTaix61tl05sp03 | grep -i bos.alt
  bos.alt_disk_install.rte C F Alternate Disk Installation

Monday, 22 April 2013

NIM Commands

Initialize nim master server:
   nimconfig -a pif_name=en0 -a master_port=1058 -a netname = net2 -a cable_type=tp
To list all the mksysb resources
 # lsnim -t mksysb
 # lsnim -t spot
To list all the machines
 # lsnim -t standalone 
 # lsnim -c machines
To reset the NIM status of system host-10
 # nim -o reset -a force=yes host-10
 # nim -Fo reset host10
To Force Deallocate all the resources from system host-01
 # nim -Fo deallocate -a subclass=all host-01
To rebuild the /etc/niminfo file in the master
 # nimconfig -r
To rebuild the /etc/niminof file in the NIM client
 # niminit -a master=<master_name> -a name=<client_machine_name>
To remove a machine from the NIM environment
 # nim -o remove <machine_name>
To define a mksysb resource
 # nim -o define -t mksysb -a server=master -a location=<location_of_mksysb_file>   <mksysb_name>
To define a postinstall script
# nim -o define -t script -a server=master -a location=/export/nim/postscripts/  postinstall-script
To define a new Network called ent-192-168-1 with network address and mask
# nim -o define -n ent-192-168-1 -t ent -a -s -g
To define a new system called "server1'
 # nim -o define -t standalone -a platform=chrp -a netboot_kernel=64 -a cable_type1=tp -a if1="network_name server1 0"  server1
To enable Base OS install in a client using mksysb resource
 # nim -o bos_inst -a source=mksysb -a spot=spot_53ML4 -a accept_licenses=yes 
   -a mksysb=<location_of_mksysb_file> <system_name>
To add additional software to lppsource1
 # nim -o update -a packages=all source=/dev/cd0 lppsource1
To update the spot and lppsource to the latest level
 # nim_update_all -l <lpp_sourcename> -s <spot_name> -d <localtion_of_filesets> -u -B

Some useful NIM SMIT Fast paths

 smit nim_mkmac         # Adding new machines
 smit nim_bosinst       # For doing BOS install operation on a machine

Common NIM Error codes

608 - tftp retrieve of client info file failure
Action If a 608 hang is encountered, verify that the file exists in the /tftpboot directory. If it does not exist, retry the NIM operation to create it. If it does exist, verify that tftp access to the /tftpboot directory is not restricted in the /etc/tftpaccess.ctl file. is also possible that the network adapter was not configured properly in the boot environment

611 - Remote mount of NFS file system failure
Action 611 hangs occur when the client machine is unable to mount a resource from a server. Ensure that NFS is running on the resource server. Verify that the resources specified for the operation are exported properly by checking the /etc/exports and /etc/xtab files on the server. Also, confirm that the resources have permissions set correctly for reading.

613 - Failure setting up route tables
Action 613 hangs usually occur because a route is incorrectly defined for a network in the NIM database. Verify that the correct gateways are specified between networks, and all gateways are functional. Use debug-enabled network boot images to determine which routes could not be defined.

Migrating AIX to new versions USING NIM LIVE alt_disk_install

It can be done using nimadm command.

Updating NIM lppsource and SPOT

If your NIM environment has a mixture of TL levels, then in order to have some NIM clients at the original level, you need to keep a copy of the original lpp_source and SPOT level. These clients will still need the original level of lpp_source and SPOT.

01. Create a new lppsource directory. In this example, we will update AIX 6.1 TL 6 to TL 7
#mkdir /export/nim/lppsource/6107
02. Copy the TL6 lopsource to TL 7 directory
#cp -rp /export/nim/lppsource/6106/* /export/nim/lppsource/6107
03. Create a new lppsource for TL7 using the copied files
#nim -o define -t lpp_source -a server=master -l /export/nim/lppsource/6107 6107-lppsource
04. Update the lppsource to the latest level. If the updates of are stored in the /updates directory, then
#nim -o update -a packages=all -a source=/updates 6107-lppsource
05. After lpp_source is updated, there might be some duplicate updates. You can perform the NIM lppmgr operation to remove them. This operation enables you remove any duplicate software, superseded updates, unnecessary languages, and non-simage software.
#nim -o lppmgr -a lppmgr_flags="-bu -x -r -e" 6107-lppsource
06. Create a new SPOT using the updated lppsource