VectorLinux
July 28, 2014, 10:23:40 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Visit our home page for VL info. To search the old message board go to http://vectorlinux.com/forum1. The first VL forum is temporarily offline until we can find a host for it. Thanks for your patience.
 
Now powered by KnowledgeDex.
   Home   Help Search Login Register  
Please support VectorLinux!
Pages: [1]
  Print  
Author Topic: [SOLVED] How to autostart a daemon before login?  (Read 2594 times)
wcs
Packager
Vectorian
****
Posts: 1144


« on: August 08, 2007, 05:54:00 pm »

Hello, all.

I'm trying to autostart this music server when I boot the computer.

It works fine when I put it in "Autostarted Applications" in xfce.
However, I would like this to start automatically for all users, and preferably before a user even logs in, so that nothing is required for the server to run except pressing the power button.

I tried putting the executable at the end of /etc/rc.d/rc.local but the process does not start. I think the reason is that the daemon doesn't allow me to run it as root.

Is there a way out of this? Some way of running it as a normal user, but before any user logs in?  Huh
« Last Edit: August 09, 2007, 06:56:09 am by wcs » Logged
lagagnon
Global Moderator
Vectorian
*****
Posts: 1922



WWW
« Reply #1 on: August 08, 2007, 06:41:51 pm »

Can you launch the daemon as root in a terminal? If not, what error messages do you get?
Does the daemon require X? If so, then it can't be launched from /etc/rc.d/rc.local but would have to be launched from the appropriate xinitrc file.
Logged

"As people become more intelligent they care less for preachers and more for teachers". Robert G. Ingersoll
wcs
Packager
Vectorian
****
Posts: 1144


« Reply #2 on: August 09, 2007, 04:03:18 am »

Quote
Can you launch the daemon as root in a terminal? If not, what error messages do you get?

It actually launches and gives me the appropriate output, but the process dies a few seconds later with the following message:
Code:
* Error: SlimServer must not be run as root! Exiting! *

Quote
Does the daemon require X? If so, then it can't be launched from /etc/rc.d/rc.local but would have to be launched from the appropriate xinitrc file.

Good point. But it doesn't require X.

I think I'm looking for a way to launch the daemon before login "as if" it was initiated by a non-root user.
Interesting conundrum...

Thanks for the answer.
Logged
rbistolfi
Packager
Vectorian
****
Posts: 2276


« Reply #3 on: August 09, 2007, 04:28:13 am »

hi wcs, I think you can use:

Code:
#sudo -u <username> </path/.../your_bin>

to run a bin as another user. Try it as root and if it works you can add it to the rc.local
Logged

"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!
retired1af
Packager
Vectorian
****
Posts: 1252



« Reply #4 on: August 09, 2007, 04:32:22 am »

I think he wants the username passed to the command. I just don't know the variable name to use that would do that. And that defeats the purpose of starting the daemon prior to login.

However, I would imagine that a script could be created that is part of the startup after login while the system is finalizing the bootup process.
« Last Edit: August 09, 2007, 04:34:50 am by retired1af » Logged

ASUS K73 Intel i3 Dual Core 2.3GHz
rbistolfi
Packager
Vectorian
****
Posts: 2276


« Reply #5 on: August 09, 2007, 04:55:28 am »

je je, that sounds probably, I am not at my linux box to test it. I thought since sudo -u is issued by root a password will not requested, it has the permissions anyway.

Anyway, I went to the slim devices site and the command has an option to run as user, ./slimserver.pl -user <username> will do it, the complete usage appears with ./slimserver.pl --help.

Quote
--user => Specify the user that server should run as.
                        Only usable if server is started as root.
                        This may only work on Unix-like systems.

There is also some init scripts for debian if you want to check here. May be they can be adapted to VL.
BTW, Nice stuff, enjoy the music   Tongue (hey, there is no rock n´roll smiley!)
« Last Edit: August 09, 2007, 04:59:19 am by rbistolfi » Logged

"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!
wcs
Packager
Vectorian
****
Posts: 1144


« Reply #6 on: August 09, 2007, 06:55:38 am »

Quote
Anyway, I went to the slim devices site and the command has an option to run as user, ./slimserver.pl -user <username> will do it, the complete usage appears with ./slimserver.pl --help.

Of course! First thing to do should be checking the command options.  Roll Eyes

That did it, although because the daemon was still looking for the preferences file inside /root, it required an additional option:
Code:
/opt/SlimServer_6.5_v2007-07-11/slimserver.pl --user <username> --prefsfile /home/<username>/slimserver.pref --daemon

I put that at the end of /etc/rc.d/rc.local and it works like a charm... Now I can simply press the power button and while going downstairs to brew some coffee I'm ready to enjoy some music. Doesn't sound like much, but it saves me about a minute each day.  Wink

Thank you all for the replies.
Logged
MikeCindi
Tester
Vectorian
****
Posts: 1071


« Reply #7 on: August 09, 2007, 09:33:18 am »

Doesn't sound like much, but it saves me about a minute each day.  Wink

That minute spent watching your PC boot up then inputing some commands every time that you KNOW can be automated can be some of the worst time spent. Especially when you could be getting coffee!  Shocked
Logged

The plans of the diligent lead to profit...Pro. 21:5
VL64 7.1b3                                     RLU 486143
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!