OK, I've decided to follow Jim's preferred approach of re-writing
i.services using nawk to get the merge right.

I'll file a separate CR for the i.services work and put the two back
together.

I'm not sure how I'll manage to preserve comments though.  Here's the
rough algorithm:

 - Read in the source and destination files.  For each file fill in
   several associative arrays indexed by name/proto and port/proto,
   tacking port/proto, cname and aliases.


 - Iterate over those arrays to compute the merged entries for each
   service.


 - Read in the source file (the one delivered by ON) and:

    - pass through any comment lines

    - replace all entries with the merged ones and preserve any comments
      from the source file, adding a comment if the entry changed

    - save the result in a temp file

    - include a comment in the beginning and end of the file about
      merged entries


 - Read in the destination file (what was on the system) and:

    - drop all comment lines (the script could check whether these are
      dups of comments in the source, but, how do we know if it's
      appropriate to keep any other comment lines, and where should they
      be inserted??)

    - skip any entries that were merged and output earlier

    - append all other entries, including comments, to the above temp
      file


 - Install the temp file as /etc/services
_______________________________________________
networking-discuss mailing list
[email protected]

Reply via email to