2014-02-02 Bruce Dubbs <bruce.du...@gmail.com>:

> Bruce Dubbs wrote:
>
> 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
>

Last string may be replaced by
gawk -v strip=yes -- "$SERVICES" service-names-port-numbers.xml | sed
"s/sunrpc/rpcbind/" >
/etc/services
or like, because rpcbind in /etc/services is crucial for working rpcbind
portmapper and nfs server.
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to