OpenVZ Forum


Home » General » Support » How to run a script on HN after VPS start
How to run a script on HN after VPS start [message #8380] Sat, 18 November 2006 06:21 Go to next message
duswil is currently offline  duswil
Messages: 77
Registered: January 2006
Member
I am needing to run some commands automatically on the HN after a specific VPS has started. Using 123.mount doesn't work because it is run too early. 123.start doesn't work because it is run inside the VPS instead of on the HN. Is there a way to do something similar to 123.start, but have it run on the HN? It needs to run after all the network devices for the VPS have been initialized.
Re: How to run a script on HN after VPS start [message #8382 is a reply to message #8380] Sat, 18 November 2006 10:44 Go to previous messageGo to next message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
What do you need such script for?

Now the only one script is runed on HN after VE start on HN:
/usr/sbin/vznetcfg. It is needed to perform appropriate configuration of veth device on HN...
Re: How to run a script on HN after VPS start [message #8396 is a reply to message #8382] Sat, 18 November 2006 18:46 Go to previous messageGo to next message
duswil is currently offline  duswil
Messages: 77
Registered: January 2006
Member
Right now, I'm trying to be able to set my routing for veth for the VPS that is starting up. It can only be done after the veth device is created, which is after the 123.mount has already been run.

I don't want to use the /etc/network/interfaces file or the like, because they can't follow the VPS if I move it between HNs on the network, which I do and will do. I really want to be able to run a script like 123.start, but have it run on the HN.
Re: How to run a script on HN after VPS start [message #8397 is a reply to message #8396] Sat, 18 November 2006 18:48 Go to previous messageGo to next message
duswil is currently offline  duswil
Messages: 77
Registered: January 2006
Member
I really don't want to, but I could alter the vznetcfg script to run 123.netcfg (a custom script), which would pretty much do the job. I just don't really want to alter OpenVZ-provided scripts that might be upgraded in the future, which would overwrite my changes.

I'm hoping there is a "good" way to do this.
Re: How to run a script on HN after VPS start [message #8398 is a reply to message #8380] Sat, 18 November 2006 20:40 Go to previous messageGo to next message
rickb is currently offline  rickb
Messages: 368
Registered: October 2006
Senior Member
I have wanted to do this as well. Unfortunately I couldn't find a clean way to run a command in the HN context after a VE starts. What I did was use cron, running a script each minute to accomplish whatever commands you need run. ie, after you run whatever command you are referring to, something probably changes. "check" to see if that change was made with the cron script, if it wasn't, run the command. In my case, it was adding some --devnodes to the started VPS, but I didn't want to maintain a mount-script file for each VE. Hope this helps.

-------------
Common Terms I post with: http://wiki.openvz.org/Category:Definitions

UBC. Learn it, love it, live it: http://wiki.openvz.org/Proc/user_beancounters

[Updated on: Sat, 18 November 2006 20:45]

Report message to a moderator

Re: How to run a script on HN after VPS start [message #8399 is a reply to message #8398] Sat, 18 November 2006 21:38 Go to previous messageGo to next message
duswil is currently offline  duswil
Messages: 77
Registered: January 2006
Member
One thing I was considering was to have the 123.mount script create an "at" job for now+2 minutes and run the 123.netcfg script. It seems dirty, so I'd like to not have to do that.

But whatever I do, it has to be portable to run on all our other servers because we do and will move a VPS around on a regular basis and I do not want to have to reconfigure or hand-edit a config file each time.
Re: How to run a script on HN after VPS start [message #8400 is a reply to message #8397] Sat, 18 November 2006 22:50 Go to previous messageGo to next message
duswil is currently offline  duswil
Messages: 77
Registered: January 2006
Member
Well, I did it anyway. Here is a patch. I'd love to know of a better way to do this, but here's what I have right now (attachment).

I have a feeling I should make a new bug entry for this. Let me know if this is the case.
Re: How to run a script on HN after VPS start [message #8404 is a reply to message #8380] Sun, 19 November 2006 11:07 Go to previous message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
In fact I agree with you that such script should be availabe, hence I filled a bug: http://bugzilla.openvz.org/show_bug.cgi?id=355
Previous Topic: *SOLVED* 2.6.16 kernel compilation fails
Next Topic: Confixx on openvz VPS
Goto Forum:
  


Current Time: Sat Jun 01 08:25:21 GMT 2024

Total time taken to generate the page: 0.00471 seconds