New /etc/services?
Auke Kok
sofar at lunar-linux.org
Thu May 6 15:40:30 GMT 2004
Jerry Lundström wrote:
> 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
even more simple would be to test for 'grep -q [portnumber]/[protocol]'
on the old file something like this:
cat newservices | while read LINE ; do
SERVICE=#(echo $LINE | awk '{print $2}')
if ! grep -qw $SERVICE /etc/services ; then
echo "$LINE" >> /etc/services
fi
done
it would also make it readable for other developers ;^)
sofar
More information about the Lunar-dev
mailing list