--- /dev/null
+Title: Upstart or sysvinit - as init.d scripts see it
+Tags: english, debian, debian edu
+Date: 2010-06-06 23:55
+
+<p>If Debian is to migrate to upstart on Linux, I expect some init.d
+scripts to migrate (some of) their operations to upstart, and will
+need a way 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.</p>
+
+<p>With upstart, I notice these environment variables are set like
+this for a script started from rcS.d/ (ignoring some irrelevant
+ones):</p>
+
+<blockquote><pre>
+DEFAULT_RUNLEVEL=2
+previous=N
+PREVLEVEL=
+RUNLEVEL=
+runlevel=S
+UPSTART_EVENTS=startup
+UPSTART_INSTANCE=
+UPSTART_JOB=rc-sysinit
+</pre></blockquote>
+
+<p>With sysvinit, these environment variables are set for the same
+script.</p>
+
+<blockquote><pre>
+INIT_VERSION=sysvinit-2.88
+previous=N
+PREVLEVEL=N
+RUNLEVEL=S
+runlevel=S
+</pre></blockquote>
+
+<p>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.</p>
+
+<p>For scripts needing to behave differently when upstart is used,
+looking for the UPSTART_JOB environment variable seem to be a good
+choice.</p>