setting environment variables in bootup action command?

I have these two lines in a bootup command window prior to commands to start a Thin server. (I want to add them because without them the server command is accessing the wrong (shared) version of Rubygems on a shared host, which causes problems)).

GEM_HOME=/users/home/dquirk/gems

export GEM_HOME

When I try saving and starting the action, I’m getting the following error:

/sbin/sh: GEM_HOME=/users/home/dquirk/gems: not found

It looks as though this is a Bourne shell error, but I don’t see what’s wrong.

I am able to run the command to start the server without any problem via PuTTY/bash.

Where exactly did you try to add those commands? In “Webmin / Bootup and Shutdown”?

That’s more meant for startup scripts in init.d or upstart format. I’d say the recommended place to put such commands is in /etc/rc.local, that’s a script that gets executed upon each runlevel change when it is finished.

I go to “Services” then “Bootup Actions” then select the “Action Name,” which brings up “Bootup script details.” I’m putting the commands in the “Commands to run at startup” text input box there.

After troubleshooting this some more, it appears that I can’t change environment variables in this setting/that I’m stuck with the PATH, etc. that the system has defined. (I’m on a shared server.)

Thanks for any ideas.

Ah, that Bootup Actions you mean. Okay that’s a plugin which I never used in a production environment. :slight_smile:

What kind of access do you have to this shared server? Is it just a shared hosting server where you have your webspace? I don’t think you’ll be able to set persistent environment variables in that case.

Yup, shared server . . . the commands run fine when I execute them via PuTTY/bash (i.e., where I have access to my environment variables). No such luck with trying to execute via bootup action, which seems to be connected with sh and not allow setting variables.

Figured it out . . . the Virtualmin interface for adding bootup action commands is in the context of a Bourne shell where the user cannot change any environment variables. I created a bash script that changed the needed variables and executed the Thin start command, and then put a bash command to load that script as the bootup action command and that worked.