[Devel] [vzctl] exec early script at start

Kir Kolyshkin kir at openvz.org
Mon Jan 14 08:38:11 PST 2008


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
> ------------------------------------------------------------------------
>
> _______________________________________________
> Devel mailing list
> Devel at openvz.org
> https://openvz.org/mailman/listinfo/devel




More information about the Devel mailing list