[Devel] [vzctl] exec early script at start

Yoann Moulin ymo at adviseo.fr
Mon Jan 14 13:29:05 PST 2008


Kir Kolyshkin a écrit :
> 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.

it was my first id, but I thought it wasn't compatible with reboot 
action (I saw today that reboot is done by cron which call vzctl).

So it's necessary to call that script vzctl or change the script call by 
  cron when a reboot is ask from a VE.

But; is that compatible with "vzctl restart" ? I meant 'restart' can't 
be call, script must do a stop, execute some action, then do a start, so 
with that script 'restart' option for vzctl will be deprecated .

that's why I've decided to patch env.c because it's was the most 
transparency way to do what I want, without change anything in how vzctl 
works if the 'early_script.sh' doesn't exist.

Yoann




More information about the Devel mailing list