-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Eric MSP Veith ha scritto:
> David,
>
> you're totally right with your asumptions. Gosh, two years of writing perl
> scripts and I cannot even say what a tiny AWK expression is going to do,
> shame on me! :-(
Lol, don't worry! :)
> Well, we could easily replace that with a bash script. Bash supports regular
> expressions since 3.0 (afaik), so it's easy to implement. It could go like
> this:
>
>
> if [[ -n "$DNSDOMAIN" ]] && [[ -f "/etc/resolv.conf" ]]
> then
> touch /tmp/resolv.conf.tmp
> while read line
> do
> if [[ "$line" =~ "domain.*" ]]
> then
> echo "domain $DNSDOMAIN" >> /tmp/resolv.conf.tmp
> else
> echo "$line" >> /tmp/resolv.conf.tmp
> fi
> done < "/etc/resolv.conf"
> mv /tmp/resolv.conf.tmp /etc/resolv.conf
> fi
>
>
> I don't know whether mv is stored in /usr/bin or in /bin, here, it's in /bin.
>
> Staying bash ver 2.05 conformant would be possible, too.
I think that would be even easier using cat and sed:
if [[ -n "$DNSDOMAIN" ]] && [[ -f "/etc/resolv.conf" ]]
then
touch /tmp/resolv.conf.tmp
sed -e 's/^domain .*$/domain $DNSDOMAIN/g' /etc/resolv.conf >
/tmp/resolv.conf.tmp
mv /tmp/resolv.conf.tmp /etc/resolv.conf
fi;
Haven't tried that though, it should print the right lines into the
temporary file.
On my Debian, here are the paths (you might need them, since you stated
you don't know where mv is):
/bin/mv
/bin/sed
/usr/bin/touch
> HTH,
> Eric
Cheers,
David
- --
Linux Registered User #334216
Get FireFox! >> http://snipurl.com/gofoxygo/ <<
Blog >> http://www.hanskalabs.net/ <<
Staff >> http://www.debianizzati.org/ <<
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.0 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFxRBz5qqQFxOSsXQRAmw2AJ4iEW9QYTYd/ehTXQIsQeYRIh74lgCgxZ0r
dKGF8CfW4qhASD803X1SYSo=
=9jqB
-----END PGP SIGNATURE-----
--
_______________________________________________
Initng mailing list
[email protected]
http://jw.dyndns.org/mailman/listinfo/initng