Check my upstart script code?

John Hupp ubuntu at
Sun May 10 17:35:24 UTC 2015

On 5/10/2015 3:39 AM, Nils Kassube wrote:
> John Hupp wrote:
>> On 5/9/2015 11:20 AM, John Hupp wrote:
>>> Here is the script code from an upstart job I'm trying to get
>>> working
>>> (but which doesn't work yet):
>>>      # test for a fat client:
>>>      if [[ $(hostname | grep 'ltsp') == ltsp* ]]; then
>>>          sed 's/mount_removable=0/mount_removable=1/'
>>> <~/.config/pcmanfm/lubuntu/pcmanfm.conf
>>>> ~/.config/pcmanfm/lubuntu/pcmanfm.conf
> I suppose those last three lines should be a single line. Then it would
> be better to use the -i option for sed.
>> Here is an improved upstart job (/etc/init/pcmanfm-ltsp.conf).  The
>> script code is tested as working when run manually as a script, but it
>> was not effective as an upstart job.  Perhaps environment variables
>> like $HOME are not available to upstart jobs even though this one
>> doesn't run until after the desktop session has started and $HOME
>> should be defined at that point.
> Like I wrote in my previous reply: You should use absolute paths instead
> of "~/" or "$HOME/" because $HOME isn't set according to [1]. Well,
> yesterday evening I didn't search for it and it was only an assumption,
> but it seems like guessing is enough sometimes. However it isn't always
> enough, because I was wrong about upstart being for system jobs only.
> Anyway, I think your assumption about $HOME is also flawed in another
> way. If you put an upstart configuration file in "/etc/init/", it is a
> system job. Then it is run by root and the "$HOME/" would be "/root/"
> (if it was set). It has nothing to do with the time when the job starts,
> so if the desktop session has started already, $HOME may be set for the
> session user. However the system job is independent from the user
> starting the session.
>> But given that the code works as a script, I can probably get what I
>> want by setting that up with a desktop shortcut in an autostarting
>> location.
> IMHO that would be the right approach, after all you want to do
> something for each individual user. Of course you could also use an
> upstart session job [2], but considering that *Ubuntu is moving from
> upstart to systemd, it is probably not a good idea to write things
> depending on upstart if you want it to work even after the next version
> upgrade.
> Nils
> [1] <>
> [2] <>

When the upstart job wouldn't work for me, I went ahead with the script 
+ autostart shortcut.

But I didn't know why the upstart job wouldn't work.  Now I know why -- 
thanks for digging up the relevant details!

More information about the ubuntu-users mailing list