5

I have a Linux version of my application built with install4j and I do not know how to make the service run under a user account. Is there a recommended way to do so?

Ingo Kegel
  • 46,523
  • 10
  • 71
  • 102

1 Answers1

3

You can start a service as a different user by editing the launcher, going to the "Executable info->Unix options" step and setting the "custom script fragment" to

if [ ! $USER = "userName" ]; then
     exec su - userName $prg_dir/$progname $@
fi 

where "userName" should be replaced with the desired user name. It's not possible to use installer variables here as the change will be made to the start script at compile time.

Ingo Kegel
  • 46,523
  • 10
  • 71
  • 102
  • So, the installation process needs a hook to create the user account if it doesn't exist, right? I'm guessing this isn't implemented via install4j, because I can't find it. – Tristan Juricek Feb 03 '16 at 22:14
  • 1
    That is correct, creating user accounts on Linux/Unix is not available in install4j. – Ingo Kegel Feb 04 '16 at 07:13