[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SLUG] Re: Re: Virtual hosts on a dynamic IP
On Mon, Jun 12, 2000 at 12:42:07PM +1000, Paul Robinson wrote:
> I had to modify what you wrote below slightly as for some reason sed didn't
> like using a variable as the replacement expression..
?? you didn't use single quotes instead, did you?
(and its the shell, not sed that does the variable substitution - the
shell should expand the line before giving it to sed)
> #Insert new IP in all required places.
> /usr/bin/sed "s/@nospam.MYIP@nospam./`/sbin/ifconfig ppp0|grep inet|cut -c 21-33`/g" \
> < /www/conf/httpd.conf.orig > /www/conf/httpd.conf
> #Restart httpd
> kill `ps -ax |grep /usr/sbin/httpd | cut -c 0-5`
> /usr/sbin/httpd
the "cut -c"s make me nervous .. a new version of some tool will come
out that adds a little whitespace and suddenly your script is off
killing the wrong processes
try:
myip=`/sbin/ifconfig ppp0 | sed -n 's/^.* addr:\([0-9.]\+\) .*$/\1/p'`
sed "s/@nospam.MYIP@nospam./$myip/" < httpd.conf.orig > httpd.conf
kill `ps -ax | grep '[/]usr/sbin/httpd' | cut -d' ' -f 1`
/usr/sbin/httpd
(the square brackets on the grep regex is an amusing trick i once saw
to avoid matching the grep process itself - better would be to use
pidof(8) or similar)
> nb I use this method below for restarting httpd because there is no rc
> files for apache in the distro of slakware that I have and because kill
> -HUP isn't too reliable as I've found with my testing of the script above
> (like it doesn't always restart it).
apache has a nice "graceful" reload (triggered by SIGUSR1) - where it
won't interrupt any current requests. you might want to consider using
that if you have other users who might be using apache while you
change IPs..
my apache (debian) comes with a script "apachectl", which sends
signals, etc to the right apache process. if you have such a script i
suggest using it (its much cleaner).
--
- Gus
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to slug-request@nospam.slug.org.au with
unsubscribe in the text