public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] Starting a daemon automatically without rc-update
@ 2009-08-12 21:40 Grant
  2009-08-12 22:02 ` Neil Bothwick
  0 siblings, 1 reply; 10+ messages in thread
From: Grant @ 2009-08-12 21:40 UTC (permalink / raw
  To: Gentoo mailing list

I run one program which needs to be started as a particular user
whenever the system comes up, but there is no ebuild.  Is this the
Gentoo way?

# cat /etc/init.d/rc.local
#!/sbin/runscript

start() {
su user
/path/to/program/binary
}

- Grant



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-user] Starting a daemon automatically without rc-update
  2009-08-12 21:40 [gentoo-user] Starting a daemon automatically without rc-update Grant
@ 2009-08-12 22:02 ` Neil Bothwick
  2009-08-12 22:50   ` [OT] " Peter Humphrey
                     ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Neil Bothwick @ 2009-08-12 22:02 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 638 bytes --]

On Wed, 12 Aug 2009 14:40:49 -0700, Grant wrote:

> I run one program which needs to be started as a particular user
> whenever the system comes up, but there is no ebuild.  Is this the
> Gentoo way?
> 
> # cat /etc/init.d/rc.local
> #!/sbin/runscript
> 
> start() {
> su user
> /path/to/program/binary
> }

Yes, or you could use

start() {
  su - user -c /path/to/program/binary
}

which runs the program with the user's full environment instead of
inheriting root's.


-- 
Neil Bothwick

C: (n.) the language following A and B. The world still awaits D and
   E. By Z, it may be acceptable for general use.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [OT] Re: [gentoo-user] Starting a daemon automatically without rc-update
  2009-08-12 22:02 ` Neil Bothwick
@ 2009-08-12 22:50   ` Peter Humphrey
  2009-08-12 23:53   ` Grant
  2009-08-13  1:18   ` [gentoo-user] " Keith Dart
  2 siblings, 0 replies; 10+ messages in thread
From: Peter Humphrey @ 2009-08-12 22:50 UTC (permalink / raw
  To: gentoo-user

On Wednesday 12 August 2009 23:02:58 Neil Bothwick wrote:
> C: (n.) the language following A and B. The world still awaits D and
>    E. By Z, it may be acceptable for general use.

I sympathise with that. Nearly 30 years ago I found it easier to write in 
assembler than C. Nowadays I don't program any more - I leave it to the 
young whipper-snappers and complain when they get it wrong.

[/OT - sorry]

-- 
Rgds
Peter



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-user] Starting a daemon automatically without rc-update
  2009-08-12 22:02 ` Neil Bothwick
  2009-08-12 22:50   ` [OT] " Peter Humphrey
@ 2009-08-12 23:53   ` Grant
  2009-08-13  0:55     ` Neil Bothwick
  2009-08-13  1:30     ` [gentoo-user] " Nikos Chantziaras
  2009-08-13  1:18   ` [gentoo-user] " Keith Dart
  2 siblings, 2 replies; 10+ messages in thread
From: Grant @ 2009-08-12 23:53 UTC (permalink / raw
  To: gentoo-user

>> I run one program which needs to be started as a particular user
>> whenever the system comes up, but there is no ebuild.  Is this the
>> Gentoo way?
>>
>> # cat /etc/init.d/rc.local
>> #!/sbin/runscript
>>
>> start() {
>> su user
>> /path/to/program/binary
>> }
>
> Yes, or you could use
>
> start() {
>  su - user -c /path/to/program/binary
> }
>
> which runs the program with the user's full environment instead of
> inheriting root's.
>
>
> --
> Neil Bothwick

Hmmm, it didn't come back up with the server.  I have this in
/etc/init.d/rc.local:

#!/sbin/runscript
depend() {
}
start() {
su - user -c /path/to/binary
}
stop() {
}
restart() {
}

I had to start it like I normally do instead:

# su - user
$ /path/to/binary

What could I be missing?

- Grant



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-user] Starting a daemon automatically without rc-update
  2009-08-12 23:53   ` Grant
@ 2009-08-13  0:55     ` Neil Bothwick
  2009-08-13  5:12       ` Grant
  2009-08-13 14:53       ` Dale
  2009-08-13  1:30     ` [gentoo-user] " Nikos Chantziaras
  1 sibling, 2 replies; 10+ messages in thread
From: Neil Bothwick @ 2009-08-13  0:55 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 500 bytes --]

On Wed, 12 Aug 2009 16:53:28 -0700, Grant wrote:

> Hmmm, it didn't come back up with the server.  I have this in
> /etc/init.d/rc.local:

My mistake, I misread the path you were using. You shouldn't
change /etc/init.d/rc.local, you put your commands in
the start or stop functions in /etc/conf.d/local.

If you use baselayout-1, the commands go in /etc/conf.d/local.start
and /etc/conf.d/local.stop.


-- 
Neil Bothwick

Middle-age - because your age starts to show at your middle.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-user] Starting a daemon automatically without rc-update
  2009-08-12 22:02 ` Neil Bothwick
  2009-08-12 22:50   ` [OT] " Peter Humphrey
  2009-08-12 23:53   ` Grant
@ 2009-08-13  1:18   ` Keith Dart
  2 siblings, 0 replies; 10+ messages in thread
From: Keith Dart @ 2009-08-13  1:18 UTC (permalink / raw
  To: gentoo-user

=== On Wed, 08/12, Neil Bothwick wrote: ===
> start() {
>   su - user -c /path/to/program/binary
> }

===

That works as long as the binary forks and runs as a daemon. If not,
you will probably have to use the start-stop-daemon helper program.



-- Keith Dart

-- 
-- --------------------
Keith Dart
<keith@dartworks.biz>
=======================



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [gentoo-user]  Re: Starting a daemon automatically without rc-update
  2009-08-12 23:53   ` Grant
  2009-08-13  0:55     ` Neil Bothwick
@ 2009-08-13  1:30     ` Nikos Chantziaras
  1 sibling, 0 replies; 10+ messages in thread
From: Nikos Chantziaras @ 2009-08-13  1:30 UTC (permalink / raw
  To: gentoo-user

On 08/13/2009 02:53 AM, Grant wrote:
> Hmmm, it didn't come back up with the server.  I have this in
> /etc/init.d/rc.local:
>
> #!/sbin/runscript
> depend() {
> }
> start() {
> su - user -c /path/to/binary
> }
> stop() {
> }
> restart() {
> }
>
> I had to start it like I normally do instead:
>
> # su - user
> $ /path/to/binary
>
> What could I be missing?

You forgot to start it in the background.  Try:

   su - user -c /path/to/binary &

If you also want to log its output to a file (say, 
/home/user/binary.log) try:

   su - user -c /path/to/binary >> /home/user/binary.log 2>&1 &




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-user] Starting a daemon automatically without rc-update
  2009-08-13  0:55     ` Neil Bothwick
@ 2009-08-13  5:12       ` Grant
  2009-08-13 14:53       ` Dale
  1 sibling, 0 replies; 10+ messages in thread
From: Grant @ 2009-08-13  5:12 UTC (permalink / raw
  To: gentoo-user

>> Hmmm, it didn't come back up with the server.  I have this in
>> /etc/init.d/rc.local:
>
> My mistake, I misread the path you were using. You shouldn't
> change /etc/init.d/rc.local, you put your commands in
> the start or stop functions in /etc/conf.d/local.
>
> If you use baselayout-1, the commands go in /etc/conf.d/local.start
> and /etc/conf.d/local.stop.
>
>
> --
> Neil Bothwick

Works great, thanks everyone.

- Grant



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-user] Starting a daemon automatically without rc-update
  2009-08-13  0:55     ` Neil Bothwick
  2009-08-13  5:12       ` Grant
@ 2009-08-13 14:53       ` Dale
  2009-08-13 20:17         ` Neil Bothwick
  1 sibling, 1 reply; 10+ messages in thread
From: Dale @ 2009-08-13 14:53 UTC (permalink / raw
  To: gentoo-user

Neil Bothwick wrote:
> On Wed, 12 Aug 2009 16:53:28 -0700, Grant wrote:
>
>   
>> Hmmm, it didn't come back up with the server.  I have this in
>> /etc/init.d/rc.local:
>>     
>
> My mistake, I misread the path you were using. You shouldn't
> change /etc/init.d/rc.local, you put your commands in
> the start or stop functions in /etc/conf.d/local.
>
> If you use baselayout-1, the commands go in /etc/conf.d/local.start
> and /etc/conf.d/local.stop.
>
>
>   

Question.  Could I put a command that changes the divisor for my fan
speeds here?  It would look something like this:

echo 8 > /sys/devices/platform/w83627hf.656/fan1_div

Would that work or does it have to be a service?

Dale

:-)  :-)



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-user] Starting a daemon automatically without rc-update
  2009-08-13 14:53       ` Dale
@ 2009-08-13 20:17         ` Neil Bothwick
  0 siblings, 0 replies; 10+ messages in thread
From: Neil Bothwick @ 2009-08-13 20:17 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 579 bytes --]

On Thu, 13 Aug 2009 09:53:18 -0500, Dale wrote:

> Question.  Could I put a command that changes the divisor for my fan
> speeds here?  It would look something like this:
> 
> echo 8 > /sys/devices/platform/w83627hf.656/fan1_div
> 
> Would that work or does it have to be a service?

It's just a shell script, or shell function in the case of 
/etc/conf.d/local, that is executed at the end of the boot sequence.

You can have it pick lottery numbers if you like :)


-- 
Neil Bothwick

If you think that there is good in everybody, you haven't met everybody.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-08-13 20:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-12 21:40 [gentoo-user] Starting a daemon automatically without rc-update Grant
2009-08-12 22:02 ` Neil Bothwick
2009-08-12 22:50   ` [OT] " Peter Humphrey
2009-08-12 23:53   ` Grant
2009-08-13  0:55     ` Neil Bothwick
2009-08-13  5:12       ` Grant
2009-08-13 14:53       ` Dale
2009-08-13 20:17         ` Neil Bothwick
2009-08-13  1:30     ` [gentoo-user] " Nikos Chantziaras
2009-08-13  1:18   ` [gentoo-user] " Keith Dart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox