[systemd-devel] Problem converting an rc script

John Lane systemd at jelmail.com
Sun Apr 7 12:21:12 PDT 2013


I have been trying to replace an rc script with a systemd unit file. It 
is for an rvm (ruby version manager) environment and it starts a 
documentation web server. I tried to create a service unit thus:

[Service]
Type=forking
User=rvm
ExecStartPre=/bin/bash --login /etc/profile.d/rvm.sh
ExecStartPre=/usr/local/rvm/bin/rvm use %i
ExecStart=/${GEM_HOME}/bin/gem server --daemon --port 8808

The rvm environment needs to be initialised (by running 
/etc/profile.d/rvm.sh) and this needs to happen in a bash login shell 
(this is due to the design of rvm).

I think the ExecStart* lines in the above example are each invoked in a 
separate environment (so the initialisation performed by the first is 
lost before the second and third items are processed). Is this right or 
do I misunderstand?

My question is to ask how would I create a unit that starts a service in 
an properly initialised environment when the only way to initialise that 
environment is to run a bash setup script that requires it to be run in 
a login shell ?

My solution that works is to use a unit to invoke a bash script that 
performs the initialisation and then starts the service. But I feel this 
somewhat negates the benefits of systemd not being based on shell 
scripts. I'd like to try and get it to work with a unit file and no 
supporting scripts, if this is possible.

thanks.





More information about the systemd-devel mailing list