The officially official Devuan Forum!

You are not logged in.

#1 2019-03-09 13:31:27

kuleszdl
Member
Registered: 2018-11-03
Posts: 107  

[solved] sysvinit: Most simple way to start command as user

Hi,

I am looking for a way to run a command as (regular) user at bootup. It's a "fire-and-forget" command and not a daemon (lxc-autostart, starts unprivileged containers). I wonder what the best approach would be to accomplish this and considered the following:

- write a minimal init.d script? (If yes: Is there a good template?)
- run it from rc.local (not what I actually want)

It would be great if the proposed solution would work for at least sysvinit and openrc without modifications.

Thank you in advance.

Last edited by kuleszdl (2019-03-16 14:35:00)

Offline

#2 2019-03-09 14:01:48

KatolaZ
Member
Registered: 2017-03-11
Posts: 79  

Re: [solved] sysvinit: Most simple way to start command as user

You can use init-d-script (man init-d-script) which encapsulates most of the complexity of dealing with writing an init-script. This is an almost unknown piece of the sysvinit package, that is not as widely used as it probably should be.

HTH

KatolaZ

Edit: actually, if what you need to run is not properly a daemon, rc.local might be the best solution.

Last edited by KatolaZ (2019-03-09 14:03:13)

Offline

#3 2019-03-09 14:31:39

dxrobertson
Member
Registered: 2017-05-04
Posts: 232  

Re: [solved] sysvinit: Most simple way to start command as user

kuleszdl wrote:

It would be great if the proposed solution would work for at least sysvinit and openrc without modifications.

If you do write a script in init.d, making it LSB compliant (the ### BEGIN INIT INFO....### END INIT INFO stuff at the top) will ensure it runs properly in openrc.

Offline

#4 2019-03-09 15:16:49

yeti
Member
From: I'm not here: U R halucinating
Registered: 2017-02-23
Posts: 304  

Re: [solved] sysvinit: Most simple way to start command as user

Look for @reboot in man 5 crontab.
You can hook up auto-start jobs there without ever needing root's superpowers.
So it's somehow simpler than with sysvinit.

If you want to start a job logging to stdout or somewhen needing input (I use that for e.g. syncthing), start screen with @reboot and wire the desired job(s) into ~/.screenrc (similarly with tmux).

Last edited by yeti (2019-03-16 14:49:20)


<πš‹πš˜πšπš’ πš˜πš—πš•πš˜πšŠπš='πšπš˜πšŒπšžπš–πšŽπš—πš.πš‹πš˜πšπš’.πš’πš—πš—πšŽπš›π™·πšƒπ™Όπ™»="π™³πš’πšœπšŠπš‹πš•πšŽ π™Ήπš‚!";'>
π”“π”©π”’π”žπ”°π”’ π”©π”’π”žπ”³π”’ 𝔢𝔬𝔲𝔯 π”£π”žπ”²π”©π”±π”° 𝔦𝔫 𝔱π”₯𝔒 𝔰𝔒𝔠𝔱𝔦𝔬𝔫 π”Ÿπ”’π”©π”¬π”΄ π”žπ”«π”‘ 𝔑𝔬𝔫'𝔱 𝔣𝔬𝔯𝔀𝔒𝔱 𝔱𝔬 π”²π”«π”°π”²π”Ÿπ”°π” π”―π”¦π”Ÿπ”’!

Offline

#5 2019-03-16 14:38:00

kuleszdl
Member
Registered: 2018-11-03
Posts: 107  

Re: [solved] sysvinit: Most simple way to start command as user

Many thanks for all those hints. I didn't know about init-d-script and it looked promising, however, I didn't find a way to start the program as user with this mechanism.

Offline

Board footer