Improve markup in some manual pages.
[dragonfly.git] / libexec / bootpd / ConvOldTab.sh
blobe4dd034cc8b8c766dcae82de3db8fc317a3d48a8
1 #!/bin/sh
2 # $DragonFly: src/libexec/bootpd/ConvOldTab.sh,v 1.2 2004/04/09 13:06:15 joerg Exp $
3 # convert_bootptab Jeroen.Scheerder@let.ruu.nl 02/25/94
4 # This script can be used to convert bootptab files in old format
5 # to new (termcap-like) bootptab files
7 # The old format - real entries are commented out by '###'
9 # Old-style bootp files consist of two sections.
10 # The first section has two entries:
11 # First, a line that specifies the home directory
12 # (where boot file paths are relative to)
14 ###/tftpboot
16 # The next non-empty non-comment line specifies the default bootfile
18 ###no-file
20 # End of first section - indicated by '%%' at the start of the line
22 ###%%
24 # The remainder of this file contains one line per client
25 # interface with the information shown by the table headings
26 # below. The host name is also tried as a suffix for the
27 # bootfile when searching the home directory (that is,
28 # bootfile.host)
30 # Note that htype is always 1, indicating the hardware type Ethernet.
31 # Conversion therefore always yields ':ha=ether:'.
33 # host htype haddr iaddr bootfile
36 ###somehost 1 00:0b:ad:01:de:ad 128.128.128.128 dummy
38 # That's all for the description of the old format.
39 # For the new-and-improved format, see bootptab(5).
41 set -u$DX
43 case $#
44 in 2 ) OLDTAB=$1 ; NEWTAB=$2 ;;
45 * ) echo "Usage: `basename $0` <Input> <Output>"
46 exit 1
47 esac
49 if [ ! -r $OLDTAB ]
50 then
51 echo "`basename $0`: $OLDTAB does not exist or is unreadable."
52 exit 1
55 if touch $NEWTAB 2> /dev/null
56 then
58 else
59 echo "`basename $0`: cannot write to $NEWTAB."
60 exit 1
64 cat << END_OF_HEADER >> $NEWTAB
65 # /etc/bootptab: database for bootp server (/etc/bootpd)
66 # This file was generated automagically
68 # Blank lines and lines beginning with '#' are ignored.
70 # Legend: (see bootptab.5)
71 # first field -- hostname (not indented)
72 # bf -- bootfile
73 # bs -- bootfile size in 512-octet blocks
74 # cs -- cookie servers
75 # df -- dump file name
76 # dn -- domain name
77 # ds -- domain name servers
78 # ef -- extension file
79 # gw -- gateways
80 # ha -- hardware address
81 # hd -- home directory for bootfiles
82 # hn -- host name set for client
83 # ht -- hardware type
84 # im -- impress servers
85 # ip -- host IP address
86 # lg -- log servers
87 # lp -- LPR servers
88 # ns -- IEN-116 name servers
89 # ra -- reply address
90 # rl -- resource location protocol servers
91 # rp -- root path
92 # sa -- boot server address
93 # sm -- subnet mask
94 # sw -- swap server
95 # tc -- template host (points to similar host entry)
96 # td -- TFTP directory
97 # to -- time offset (seconds)
98 # ts -- time servers
99 # vm -- vendor magic number
100 # Tn -- generic option tag n
102 # Be careful about including backslashes where they're needed. Weird (bad)
103 # things can happen when a backslash is omitted where one is intended.
104 # Also, note that generic option data must be either a string or a
105 # sequence of bytes where each byte is a two-digit hex value.
107 # First, we define a global entry which specifies the stuff every host uses.
108 # (Host name lookups are relative to the domain: your.domain.name)
110 END_OF_HEADER
112 # Fix up HW addresses in aa:bb:cc:dd:ee:ff and aa-bb-cc-dd-ee-ff style first
113 # Then awk our stuff together
114 sed -e 's/[:-]//g' < $OLDTAB | \
115 awk 'BEGIN { PART = 0 ; FIELD=0 ; BOOTPATH="unset" ; BOOTFILE="unset" }
116 /^%%/ {
117 PART = 1
118 printf ".default:\\\n\t:ht=ether:\\\n\t:hn:\\\n\t:dn=your.domain.name:\\\n\t:ds=your,dns,servers:\\\n\t:sm=255.255.0.0:\\\n\t:hd=%s:\\\n\t:rp=%s:\\\n\t:td=%s:\\\n\t:bf=%s:\\\n\t:to=auto:\n\n", BOOTPATH, BOOTPATH, BOOTPATH, BOOTFILE
119 next
121 /^$/ { next }
122 /^#/ { next }
124 if ( PART == 0 && FIELD < 2 )
126 if ( FIELD == 0 ) BOOTPATH=$1
127 if ( FIELD == 1 ) BOOTFILE=$1
128 FIELD++
132 if ( PART == 1 )
134 HOST=$1
135 HA=$3
136 IP=$4
137 BF=$5
138 printf "%s:\\\n\t:tc=.default:\\\n\t:ha=0x%s:\\\n\t:ip=%s:\\\n\t:bf=%s:\n", HOST, HA, IP, BF
140 }' >> $NEWTAB
142 exit 0