You are not logged in.

#1 2006-10-23 10:14:18

fdrebin
Member
Registered: 2005-04-25
Posts: 152

where to start a program that doesn't quit when restarting X

i want to run amuled after boot, so that it is still running when i log out as user or restart the X server.
so i gave rc.local a try but it didn't work (do you need some kind of seperator when there are multiple commands in rc.local ???)
also for amuled it would be "enough" to be started as normal user (not root) - so is there a way to start it as normal user but not to quit even if the user logs out or restarts X?
(hope this was understandable)

Offline

#2 2006-10-23 10:47:55

zack
Member
From: Portsmouth, UK
Registered: 2006-09-11
Posts: 32

Re: where to start a program that doesn't quit when restarting X

Try adding it to the end of your DAEMONS array in /etc/rc.conf and see if that works.

Offline

#3 2006-10-23 10:57:42

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: where to start a program that doesn't quit when restarting X

/etc/rc.conf will only work if you write an init script for it - the package does not provide one. In the longer term, you could post a feature request for an init script and attach your own, if you decide to write one.

Re rc.local, just put each command on a separate line. Check the man pages to see if there's an option to start as user.

Offline

#4 2006-10-23 11:08:49

fdrebin
Member
Registered: 2005-04-25
Posts: 152

Re: where to start a program that doesn't quit when restarting X

tomk: i said i tried rc.local not rc.conf ! i can start amuled from a normal command line and it works... no
init script or something is required.

so you guys think it doesn't hurt to start amuled as root?

Offline

#5 2006-10-23 11:45:00

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: where to start a program that doesn't quit when restarting X

zack suggested rc.conf - I clarified how that could be done.

In general, it's considered a bad idea to run daemons as root. If they get compromised, the attacker could gain root access to your system.

Offline

#6 2006-10-23 11:50:50

fdrebin
Member
Registered: 2005-04-25
Posts: 152

Re: where to start a program that doesn't quit when restarting X

ok so isn't there a file wich starts the program as a normal user ???

i think it would be enough to start it on another terminal than #7 is this possible somehow?

Offline

#7 2006-10-23 12:51:34

PJ
Member
From: Sweden
Registered: 2005-10-11
Posts: 602

Re: where to start a program that doesn't quit when restarting X

Not sure if this a good solution but wouldn't it be possible to run it like this:

sudo -u [user name] [command]

Or in case you don't want sudo.

su [user name] -c [command]

Then it is just to put the line inside rc.local .

Offline

#8 2006-10-23 14:19:21

PJ
Member
From: Sweden
Registered: 2005-10-11
Posts: 602

Re: where to start a program that doesn't quit when restarting X

I have written an initscript for amuled, not sure if it really works, since I am not using amule. I have tried it with some other daemon. It is based on the "gpm initscript" and some info from this page:
http://www.amule.org/wiki/index.php/FAQ_amuled

Made it mostly because I was curious on how it could be written.

/etc/rc.d/amuled

#!/bin/bash

# source application-specific settings
USER=
[ -f /etc/conf.d/amuled ] && . /etc/conf.d/amuled

. /etc/rc.conf
. /etc/rc.d/functions

PID=`pidof -o %PPID /usr/bin/amuled`
case "$1" in
  start)
    stat_busy "Starting aMule Daemon"
    [ -z "$PID" ] && /bin/su ${USER} -c "/usr/bin/amuled -f >/dev/null"
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon amuled
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping aMule Daemon"
    [ ! -z "$PID" ]  && kill $PID &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon amuled
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
esac
exit 0

/etc/conf.d/amuled

#
# User which will run amuled
#
USER="user name"

<edit>
Change some stuff and tried it with amuled. Seems to work. 
</edit>

Offline

#9 2006-10-23 17:24:21

fdrebin
Member
Registered: 2005-04-25
Posts: 152

Re: where to start a program that doesn't quit when restarting X

this script make use of "su", too.
so wouldn't this work too:

startamuled.sh:

#!bin/bash

su myusername -c amuled

then make the file exectuable and put in my rc.local

Offline

#10 2006-10-23 20:30:43

PJ
Member
From: Sweden
Registered: 2005-10-11
Posts: 602

Re: where to start a program that doesn't quit when restarting X

fdrebin wrote:

this script make use of "su", too.
so wouldn't this work too:

startamuled.sh:

#!bin/bash

su myusername -c amuled

then make the file exectuable and put in my rc.local

Yes, I believe that will work too. Just a note on something I did find out about amuled, it somehow puts the boot up process in a wait condition because it doesn't fork in the background without '-f' or a '&' at the end of the line. It could be something preferable, if you like to see the status of amuled by pressing alt+ctrl+1 . A program or a script that is supposed to be started after this script will probably not run since it will be waiting on a exit condition for amuled.

Offline

#11 2006-10-23 22:40:29

fdrebin
Member
Registered: 2005-04-25
Posts: 152

Re: where to start a program that doesn't quit when restarting X

ok it works except that i can't pass the -f paramter to amuled like this:

su username -c amuled -f

so how can i fix this?

Offline

#12 2006-10-24 01:23:45

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Re: where to start a program that doesn't quit when restarting X

su username -c "amuled -f"

1000

Offline

#13 2006-10-24 07:54:42

fdrebin
Member
Registered: 2005-04-25
Posts: 152

Re: where to start a program that doesn't quit when restarting X

nice - works now!

Offline

#14 2006-10-24 21:10:18

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: where to start a program that doesn't quit when restarting X

screen is another solution...
but ofcause a rc script is more elegant


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#15 2006-10-25 08:10:41

fdrebin
Member
Registered: 2005-04-25
Posts: 152

Re: where to start a program that doesn't quit when restarting X

what do you mean with "screen"?

Offline

#16 2006-10-25 09:06:55

FUBAR
Member
From: Belgium
Registered: 2004-12-08
Posts: 1,029
Website

Re: where to start a program that doesn't quit when restarting X

pacman -S screen

It's a cool tool that allows you to "disconnect" ("detach") from your terminal but keep it running in the background so you can reconnect later. Obviously, this won't survive a reboot. A lot of people (including me) use irssi in screen to be online 24/7 on IRC and IM.


A bus station is where a bus stops.
A train station is where a train stops.
On my desk I have a workstation.

Offline

#17 2006-10-25 13:21:20

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: where to start a program that doesn't quit when restarting X

http://www.gnu.org/software/screen/

It's the best thing since zsh


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

Board footer

Powered by FluxBB