#!/bin/sh ######################################################################## ## ## This script will read /etc/hosts and create an ## equivalent registry tree under $ROOT. ## ## The correct way to run it is: ## ## # ./hosts-convert | sh -e ## ## ## To make tests you can do: ## ## $ ROOT=user/test ./hosts-convert | sh -e ## ## Vladimir Shabanov ## June 2004 ## ## $Id$ ## ######################################################################## [ -z "$RG" ] && RG="kdb" [ -z "$ROOT" ] && ROOT="system/network/hosts" cat /etc/hosts | sed /"#"/d | while read -a hosts; do echo $RG set -c \"Hostname\" $ROOT/${hosts[0]}/hostname \'${hosts[1]}\' total_words=`echo ${hosts[*]} | wc -w` for (( i=2; $((i < $total_words)); i++ )); do num=$((i-2)) echo $RG set -c \"Hostname alias\" $ROOT/${hosts[0]}/host_alias$num \'${hosts[$i]}\' done done