X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=clients%2FHP%2Fbin%2Fmakehosts;fp=clients%2FHP%2Fbin%2Fmakehosts;h=f100c9ca805a3313287a18c643d29574e74b51c7;hb=a8c84d2892f07a6863b68a11eb0a4a79ffd71fb5;hp=0000000000000000000000000000000000000000;hpb=95384f94f88aceeb5eef2d322210ba4a438b6512;p=clearscm.git diff --git a/clients/HP/bin/makehosts b/clients/HP/bin/makehosts new file mode 100644 index 0000000..f100c9c --- /dev/null +++ b/clients/HP/bin/makehosts @@ -0,0 +1,44 @@ +#!/bin/ksh +################################################################################ +# +# File: makehosts +# Description: Makes an /etc/hosts file +# Author: Andrew@DeFaria.com +# Created: Thu Jun 3 17:21:24 PDT 1999 +# Modified: +# Language: Korn Shell +# +# (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved +# +################################################################################ +me=$(basename $0) + +# Set adm_base +adm_base=${adm_base:-$HOME/adm} + +# Set adm_fpath +adm_fpath=${adm_fpath:-$adm_base/functions} + +# Source functions +. $adm_fpath/common + +if [ $(/usr/xpg4/bin/id -u) -ne 0 ]; then + print -u2 "$me: Error: You must be root to use this command" + exit 1 +fi + +stdhosts=${stdhosts:-$adm_base/etc/stdhosts} +syshosts=${syshosts:-/etc/hosts} +localhosts=${localhosts:-/etc/hosts.local} + +current_ip=$(nslookup $(hostname) | tail -2 | awk '{print $NF}') + +cp $stdhosts $syshosts + +if ! grep $(hostname) $syshosts > /dev/null; then + print "$current_ip\t$(hostname).cisco.com\t\t$(hostname)" >> $syshosts +fi + +if [ -f $localhosts ]; then + cat $localhosts >> $syshosts +fi