[Devel] [vzctl] exec early script at start

Kir Kolyshkin kir at openvz.org
Wed Jan 16 02:22:55 PST 2008


Yoann Moulin wrote:
> 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:
>> <....skipped....>
> 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).
In this case, rename vzctl to vzctl.real and put your wrapper script in
place of 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 .
Right, here comes the problem.
>
> 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.
Yeah, now I understand.

Have you tried using /etc/vz/conf/$VEID.start script? There are also
.stop, .mount and .umount. I'm sorry if it is not documented; will fix that.

Note that mount/umount scripts are both per-VE and global (global one is
called vps.mount/vps.umount), while start/stop are only per-VE. This can
easily be fixed: look at  src/lib/env.c, functions vps_start_custom()
and vps_stop() to see how start/stop scripts is called, then look at
src/lib/fs.c, functions vps_mount() and vps_umount() to see how both
global and per-VE mount/umount scripts are called. Now you can modify
code in env.c to have global start/stop scripts as well. Patches are
welcome.

PS the best way to do patches is to use git.




More information about the Devel mailing list