OpenVZ Forum


Home » Mailing lists » Devel » [WISH] exec early script at start
Re: [vzctl] exec early script at start [message #26031 is a reply to message #26027] Mon, 14 January 2008 16:38 Go to previous messageGo to previous message
kir is currently offline  kir
Messages: 1645
Registered: August 2005
Location: Moscow, Russia
Senior Member

Technically, if you want to do something before vzctl start executes, 
the way to go would be to write a simple shell wrapper which will do 
what's needed and then run vzctl. Something like this:

#!/bin/sh
ACTION=$1
VEID=$2

start_actions() {
    # put here all you need to do before vzctl start
}

stop_actions() {
    # same for stop
}

case $ACTION in
    start)
       start_actions $*
       ;;
    stop)
       stop_actions $*
       ;;
    # anything else you need here
esac

# Finally, exec vzctl
exec /usr/sbin/vzctl $*

Now, you just call the above script instead of calling vzctl directly. 
You can even call the script 'vzctl', if you either put it into a 
directory which is before /usr/sbin in your $PATH, or rename "real" 
vzctl into something like vzctl.real.

Yoann Moulin wrote:
> Hi,
>
>>> I didn't do C for a while, so I'm not sure I'll be able to do 
>>> something simple and safe.
>>>
>>> I'm available to compile and test this until the openvz server 
>>> should be production at the end of next week... but I'll take the 
>>> time to do all the test we need before.
>>>
>>> If some can help me on this issue.
>>
>> I have patched env.c to be able to execute a script before starting a VE
>>
>> I don't know if it is the best way to do that, but it work for what I 
>> need
>
> I had no feed back on this patch, is it will be applied ? or maybe nobody
> need this but me ?
>
> I don't know if it'is possible to do this better, or add a better 
> security
> check, but as I said in my first mail, I don't developed in C for a while
>
> thanks
>
> Yoann
> ------------------------------------------------------------------------
>
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [RFC][-mm] Memory controller hierarchy support (v1)
Next Topic: To install OpenVZ in an Oracle installed system
Goto Forum:
  


Current Time: Tue Oct 07 08:27:58 GMT 2025

Total time taken to generate the page: 0.30249 seconds