Environment Variables passed to init?

Rob Ubuntu Linux rob.ubuntu.linux at googlemail.com
Tue Oct 30 15:06:10 GMT 2007


On 10/30/07, Scott James Remnant <scott at netsplit.com> wrote:
> On Tue, 2007-10-30 at 13:37 +0100, Wolf Paul wrote:

> > In the past, on SysV-Init based Linux distros I managed to set up my
> > notebook to boot into different networking and other environments by
> > setting up multiple entries in Grub for the various locations, with
> > LOCATION=xxxx appended to the kernel parameter line.

> > It seems to me that the Upstart "init" does not pass such environment
> > variables to the scripts it calls, and thus this method of setting up
> > a location-dependent boot environment no longer works.
> >
> > Is this observation correct?
> >
> It is correct; though it should be possible to specify in a job's
> definition which environment variables you *do* what passed through.
> This is to allow jobs to ensure consistent environments to run in.

Or more simply work round the problem with a teeny hack, so you can
modify the scripts in a small way to run on Ubuntu.

Write a script to chain load init(8) on boot, with same params and environment :

$ cat > /sbin/hackinit
#!/bin/dash

echo "LOCATION=$LOCATION" > /etc/LOCATION
exec /sbin/init "$@"
$ chmod +x !$

Then when you boot use : init=/sbin/hackinit LOCATION=HOME

Now in your rc.d scripts, ". /etc/LOCATION" like the /etc/init.d
scripts source files in /etc/default to set the value of LOCATION.

[ -r "/etc/default/LOCATION" ] && . "/etc/LOCATION"


I'm writing this on a system I just rebooted with this method, it
seems OK; but try at own risk!



More information about the upstart-devel mailing list