New /etc/services?

Jerry Lundström prox at lunar-linux.org
Thu May 6 10:41:20 GMT 2004


Auke Kok wrote:
> Jerry Lundström wrote:
> [snip]
> 
> Here's what lunar uses internally, should not be that hard to write into 
> a module's BUILD... note that on first installation it would add almost 
> the entire file as no entries match at all with the ISO's services.
> 
> sofar
> 
> install_services ()
> {
>    debug_msg "install_services ($@)";
>    if [ -f $SCRIPT_DIRECTORY/services ]; then
>        export IFS="$ENTER_IFS";
>        cat $SCRIPT_DIRECTORY/services | while read LINE; do
>            grep -q "$LINE" /etc/services || echo "$LINE" >>/etc/services;
>        done;
>    fi
> }

Well, I think we should really match a little more then just a plain grep.


grep -E '^[^#]+' services | while read line; do
   patt=`echo $line | sed -re 's%#.*%%' | sed -re 's%[ \t]+%\\s\+%' | 
sed -re 's%\+%\\\+%' `
   grep -i -q -E "$patt" /etc/services || echo "$line"
done


This will take all non-starting-with-# lines, make a pattern out of them 
  ("ftp 21/tcp # ftp" = "ftp\s+21/tcp") and match it in services.

I only see a + that will mess up the pattern and i dont think we will 
get alot of . * [] in the services.


More information about the Lunar-dev mailing list