5 # convert_bootptab Jeroen.Scheerder@let.ruu.nl 02/25/94
6 # This script can be used to convert bootptab files in old format
7 # to new (termcap-like) bootptab files
9 # The old format - real entries are commented out by '###'
11 # Old-style bootp files consist of two sections.
12 # The first section has two entries:
13 # First, a line that specifies the home directory
14 # (where boot file paths are relative to)
18 # The next non-empty non-comment line specifies the default bootfile
22 # End of first section - indicated by '%%' at the start of the line
26 # The remainder of this file contains one line per client
27 # interface with the information shown by the table headings
28 # below. The host name is also tried as a suffix for the
29 # bootfile when searching the home directory (that is,
32 # Note that htype is always 1, indicating the hardware type Ethernet.
33 # Conversion therefore always yields ':ha=ether:'.
35 # host htype haddr iaddr bootfile
38 ###somehost 1 00:0b:ad:01:de:ad 128.128.128.128 dummy
40 # That's all for the description of the old format.
41 # For the new-and-improved format, see bootptab(5).
46 in 2 ) OLDTAB
=$1 ; NEWTAB
=$2 ;;
47 * ) echo "Usage: `basename $0` <Input> <Output>"
53 echo "`basename $0`: $OLDTAB does not exist or is unreadable."
57 if touch $NEWTAB 2> /dev
/null
61 echo "`basename $0`: cannot write to $NEWTAB."
66 cat << END_OF_HEADER >> $NEWTAB
67 # /etc/bootptab: database for bootp server (/etc/bootpd)
68 # This file was generated automagically
70 # Blank lines and lines beginning with '#' are ignored.
72 # Legend: (see bootptab.5)
73 # first field -- hostname (not indented)
75 # bs -- bootfile size in 512-octet blocks
76 # cs -- cookie servers
77 # df -- dump file name
79 # ds -- domain name servers
80 # ef -- extension file
82 # ha -- hardware address
83 # hd -- home directory for bootfiles
84 # hn -- host name set for client
86 # im -- impress servers
87 # ip -- host IP address
90 # ns -- IEN-116 name servers
92 # rl -- resource location protocol servers
94 # sa -- boot server address
97 # tc -- template host (points to similar host entry)
98 # td -- TFTP directory
99 # to -- time offset (seconds)
101 # vm -- vendor magic number
102 # Tn -- generic option tag n
104 # Be careful about including backslashes where they're needed. Weird (bad)
105 # things can happen when a backslash is omitted where one is intended.
106 # Also, note that generic option data must be either a string or a
107 # sequence of bytes where each byte is a two-digit hex value.
109 # First, we define a global entry which specifies the stuff every host uses.
110 # (Host name lookups are relative to the domain: your.domain.name)
114 # Fix up HW addresses in aa:bb:cc:dd:ee:ff and aa-bb-cc-dd-ee-ff style first
115 # Then awk our stuff together
116 sed -e 's/[:-]//g' < $OLDTAB | \
117 nawk
'BEGIN { PART = 0 ; FIELD=0 ; BOOTPATH="unset" ; BOOTFILE="unset" }
120 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
126 if ( PART == 0 && FIELD < 2 )
128 if ( FIELD == 0 ) BOOTPATH=$1
129 if ( FIELD == 1 ) BOOTFILE=$1
140 printf "%s:\\\n\t:tc=.default:\\\n\t:ha=0x%s:\\\n\t:ip=%s:\\\n\t:bf=%s:\n", HOST, HA, IP, BF