Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a daemon user account with install4j in Linux?

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?

like image 491
Chara Paschalidi Avatar asked Oct 19 '22 04:10

Chara Paschalidi


1 Answers

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.

like image 52
Ingo Kegel Avatar answered Nov 01 '22 09:11

Ingo Kegel