Bruce Dubbs wrote:

> What I'm thinking about is to create our own tarball with current data
> files and also install a couple of custom programs similar to
> update-usbids and update-pciids.

OK, I have been playing with this.  If we create a tarball with the up 
to date services and protocols files along with the following script 
named update-iana-files, the install procedure would be merely:

install -m644 -o root -g root services protocols /etc
install -m744 -o root -g root update-iana-files /usr/sbin

The update-iana-files is below.  Comments?

   -- Bruce

========================
#! /bin/bash

if [ $(id -u) -ne 0 ]; then
   echo "$0: You must be root to run this script"
   exit 1
fi

IANA_DIR=/usr/share/iana-etc

mkdir -p $IANA_DIR
cd       $IANA_DIR
rm *.xml

wget http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml

wget 
http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml


PROTOCOLS='BEGIN {
  print "# See the full IANA XML file at: 
/usr/share/iana-etc/protocol-numbers.xml\n"
  FS="[<>]"
}

{
  if (/<record/) { v=n=0; d="" }
  if (/<value/) v=$3
  if (/<description/) d=$3
  if (/<name/ && !($3~/ /)) n=$3
  if (/<\/record/ && (v || n=="HOPOPT") && n) printf "%-15s %3i %-15s # 
%s\n", tolower(n),v,n,d
}'

gawk --re-interval -v strip=yes -- "$PROTOCOLS" protocol-numbers.xml > 
/etc/protocols

SERVICES='BEGIN {
  print "# See the full IANA XML file at: 
/usr/share/iana-etc/service-names-port-numbers.xml\n"
  FS="[<>]"
}

{
  if (/<record/) { n=u=p=c=0; d="" }
  if (/<name/ && !/\(/) n=$3
  if (/<number/) u=$3
  if (/<protocol/) p=$3
  if (/<description/) d=$3
  if (/Unassigned/ || /Reserved/ || /historic/) c=1
  if (/<\/record/ && n && u && p && !c) printf "%-15s %5i/%-5s # %s\n", 
n,u,p,d # services
}'

gawk -v strip=yes -- "$SERVICES" service-names-port-numbers.xml > 
/etc/services
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to