Added client work scripts
[clearscm.git] / clients / HP / bin / makehosts
1 #!/bin/ksh
2 ################################################################################
3 #
4 # File:         makehosts
5 # Description:  Makes an /etc/hosts file
6 # Author:       Andrew@DeFaria.com
7 # Created:      Thu Jun  3 17:21:24 PDT 1999
8 # Modified:
9 # Language:     Korn Shell
10 #
11 # (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved
12 #
13 ################################################################################
14 me=$(basename $0)
15
16 # Set adm_base
17 adm_base=${adm_base:-$HOME/adm}
18
19 # Set adm_fpath
20 adm_fpath=${adm_fpath:-$adm_base/functions}
21
22 # Source functions
23 . $adm_fpath/common
24
25 if [ $(/usr/xpg4/bin/id -u) -ne 0 ]; then
26   print -u2 "$me: Error: You must be root to use this command"
27   exit 1
28 fi
29
30 stdhosts=${stdhosts:-$adm_base/etc/stdhosts}
31 syshosts=${syshosts:-/etc/hosts}
32 localhosts=${localhosts:-/etc/hosts.local}
33
34 current_ip=$(nslookup $(hostname) | tail -2 | awk '{print $NF}')
35
36 cp $stdhosts $syshosts
37
38 if ! grep $(hostname) $syshosts > /dev/null; then
39   print "$current_ip\t$(hostname).cisco.com\t\t$(hostname)" >> $syshosts
40 fi
41
42 if [ -f $localhosts ]; then
43   cat $localhosts >> $syshosts
44 fi