
Reference 90
Action scripts are located in the same directory as VPS configuration files and have names like
vpsid
.
action
. The global scripts are named
vps.mount
and
vps.umount
, and the other
scripts have the corresponding VPS ID as part of their name. As the names of the global scripts
are fixed, they are called when any VPS is started or stopped. That is why, in these scripts you
should perform those commands that are common for all VPSs, and leave VPS-specific
commands for the scripts belonging to a particular VPS. Thus, for example, for VPS 101 the
action scripts will have names:
/etc/sysconfig/vz-scripts/vps.mount
/etc/sysconfig/vz-scripts/101.mount
/etc/sysconfig/vz-scripts/101.start
/etc/sysconfig/vz-scripts/101.stop
/etc/sysconfig/vz-scripts/101.umount
/etc/sysconfig/vz-scripts/vps.umount
For the
mount
and
umount
scripts, the environment passed is the standard environment of the
parent (i.e.
vzctl
) with two additional variables:
$VEID
and
$VE_CONFFILE
. The first one
holds the ID of the Virtual Private Server being mounted (started, stopped, dismounted), and the
second one holds the full path to the VPS configuration file. It is probably a bit redundant.
SWsoft introduced both variables for convenience. You can use the following fragment of the
code in bash scripts to get access to additional VPS information like
$VE_PRIVATE
or
$VE_ROOT
locations:
#!/bin/bash
#
# This script source VPS configuration files in the same
# order as vzctl does
# if one of these files does not exist then something is
# really broken
[ -f /etc/sysconfig/vz ] || exit 1
[ -f $VE_CONFFILE ] || exit 1
# source both files. Note the order, it is important
. /etc/sysconfig/vz
. $VE_CONFFILE
The
start
and
stop
scripts are performed in the VPS context. If these scripts call any
external commands, these commands are taken from VPS itself. Also note that the
start
script
runs before any VPS tasks (including
init
), thus the
/proc
file system is not mounted in
VPS at this moment – therefore, applications using an information from
/proc
may be not
functional.