If Debian is to migrate to upstart on Linux, I expect some init.d +scripts to migrate (some of) their operations to upstart job while +keeping the init.d for hurd and kfreebsd. The packages with such +needs will need a way to get their init.d scripts to behave +differently when used with sysvinit and with upstart. Because of +this, I had a look at the environment variables set when a init.d +script is running under upstart, and when it is not.
+ +With upstart, I notice these environment variables are set when a +script is started from rcS.d/ (ignoring some irrelevant ones like +COLUMNS):
+ ++ ++DEFAULT_RUNLEVEL=2 +previous=N +PREVLEVEL= +RUNLEVEL= +runlevel=S +UPSTART_EVENTS=startup +UPSTART_INSTANCE= +UPSTART_JOB=rc-sysinit +
With sysvinit, these environment variables are set for the same +script.
+ ++ ++INIT_VERSION=sysvinit-2.88 +previous=N +PREVLEVEL=N +RUNLEVEL=S +runlevel=S +
The RUNLEVEL and PREVLEVEL environment variables passed on from +sysvinit is not set by upstart. Not sure if it is intentional or not +to not be compatible with sysvinit in this regard.
+ +For scripts needing to behave differently when upstart is used, +looking for the UPSTART_JOB environment variable seem to be a good +choice.
+