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