[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Can not start a script with systemd



On Sun, 2022-03-13 at 16:46 -0400, Greg Wooledge wrote:
> If it requires environment variables like HOME to be defined, then
> you
> might need to add those.  Either in the unit file, or in the wrapper
> script.
> 
> Looks like the systemd version uses an "Environment=" directive, from
> systemd.exec(5).  (The hardest part of all this is guessing which man
> page each thing is in, because there are at least three separate man
> pages -- systemd.unit, systemd.service, systemd.exec.)


 I got it working, but not how I would rather like it. But I will post
my solution just in case anyone benefits from it. It seems that the
User= directive does not load the user's environment, so I ommited that
directive. From the unit file I call a script that does 'su -c
aaserver' and everything after runs as the aaserver user.


 aas.service
===========
  [Unit]
  Description=Alien Arena Dedicated Server
  
  [Service]
  Type=forking
  WorkingDirectory=/home/aaserver
  ExecStart=/home/aaserver/saas.sh

  [Install]
  WantedBy=multi-user.target
===========

 saas.sh
===========
  #!/bin.sh
  su -c aaserver '/home/aaserver/aas.sh' > /dev/null &
===========

aas.sh
===========
  #!/bin/sh
  screen -S cir -d -m rlwrap -A /home/aaserver/aa/alienarena-ded +set \
game arena +exec ctfir.cfg
===========

 In my 1st post I ommited the screen command to keep things simple.
 
 And thanks again for your help and time, much appreciated



Reply to: