man 5 init:
Each job is run with the environment from the events or commands that started it. In addition, you may define defaults in the
job which may be overridden later and specify which environment variables are exported into the events generated for the job.
The special UPSTART_EVENTS environment variable contains the list of events that started the job, it will not be present if the
job was started manually.
In addition, the pre-stop and post-stop scripts are run with the environment of the events or commands that stopped the job.
The UPSTART_STOP_EVENTS environment variable contains the list of events that stopped the job, it will not be present if the job
was stopped manually.
All jobs also contain the UPSTART_JOB and UPSTART_INSTANCE environment variables, containing the name of the job and instance.
These are mostly used by the initctl(8) utility to default to acting on the job the commands are called from.
Defines a default environment variable, the value of which may be overriden by the event or command that starts the job.
If ´KEY=VALUE´ is specified, the variable KEY is given the value VALUE. If only ´KEY´ is given, then the value is taken
from the init(8) daemon's own environment.
Exports the value of an environment variable into the starting(7), started(7), stopping(7) and stopped(7) events for this
job and to all resultant events (not just those relating to the current job).
Additionaly you can do
grep env /etc/init/* to see how is used
This is my output:
/etc/init/container-detect.conf: # is to check for "container" in init's environment.
/etc/init/container-detect.conf: [ -d /proc/vz ] && [ ! -d /proc/bc ] && container=openvz
And for a exhaustive example see some of that scripts. Here nginx.conf:
description "nginx http daemon"
author "Philipp Klose "
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
respawn limit 10 5
if [ $? -ne 0 ]
then exit $?