3 ########################################################################
5 ## This script will read /etc/hosts and create an
6 ## equivalent registry tree under $ROOT.
8 ## The correct way to run it is:
10 ## # ./hosts-convert | sh -e
13 ## To make tests you can do:
15 ## $ ROOT=user/test ./hosts-convert | sh -e
17 ## Vladimir Shabanov <virl@mail.ru>
22 ########################################################################
25 [ -z "$RG" ] && RG="kdb"
26 [ -z "$ROOT" ] && ROOT="system/network/hosts"
29 cat /etc/hosts | sed /"#"/d | while read -a hosts; do
31 echo $RG set -c \"Hostname\" $ROOT/${hosts[0]}/hostname \'${hosts[1]}\'
33 total_words=`echo ${hosts[*]} | wc -w`
34 for (( i=2; $((i < $total_words)); i++ )); do
36 echo $RG set -c \"Hostname alias\" $ROOT/${hosts[0]}/host_alias$num \'${hosts[$i]}\'