LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-22-2009, 12:15 PM   #1
geomysterio
LQ Newbie
 
Registered: May 2009
Distribution: Fedora
Posts: 15

Rep: Reputation: 1
Startup script won't access configuration.


Hi all.
I'm setting up a simple fedora 10 file server, and I had some troubles with startup programs.

First of all, I installed screen so that I could run processes in the background. I need rtorrent to run at startup, but I also wanted it in a detachable screen, so I added the command

screen rtorrent

to my /etc/rc.local file. This almost does what I want it to do, except that it won't load the torrent files from the previous session. If I run this from the regular terminal, it does.

Since rtorrent's configuration is at ~/.rtorrent.rc, I figured that the startup script was just being run by some startup user or root, so I changed the command to

su geo -C `screen rtorrent`

== edit
by the way, my username is geo, in case you're wondering.
== done

There's no change whatsoever.

Any ideas?

Last edited by geomysterio; 05-22-2009 at 12:18 PM.
 
Old 05-22-2009, 01:20 PM   #2
soleilarw
Member
 
Registered: Apr 2009
Posts: 107

Rep: Reputation: 19
Your configuration file is ~/.rtorrent.rc, but boot scripts and cron jobs do not know of ~ because at that time no one is logged in. Specify a full pathname to the configuration file, and it should work.

Linux Archive

Last edited by soleilarw; 06-18-2009 at 04:07 AM.
 
Old 05-22-2009, 01:49 PM   #3
geomysterio
LQ Newbie
 
Registered: May 2009
Distribution: Fedora
Posts: 15

Original Poster
Rep: Reputation: 1
Well, there's really no way to alter the configuration script path that the program references. I think it works like vim or bash, where it just checks your home directory for the configuration file. That's where I got the idea for using su.
 
Old 05-22-2009, 02:58 PM   #4
geomysterio
LQ Newbie
 
Registered: May 2009
Distribution: Fedora
Posts: 15

Original Poster
Rep: Reputation: 1
I solved it!

I just needed to put this into the startup script rc.local:

su geo -c 'screen -d -m rtorrent'

This causes the startup user to launch a detatched screen as root, which sources the configuration.
Perfect!
 
Old 05-22-2009, 07:11 PM   #5
soleilarw
Member
 
Registered: Apr 2009
Posts: 107

Rep: Reputation: 19
In that case (when run as root) ~/.rtorrent.rc is actually /root/.rtorrent.rc - is it actually secure to run torrent tasks as root? I'm a bit paranoid about letting some tools run into the big wide open with root permissions...
 
Old 05-22-2009, 07:29 PM   #6
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS6
Posts: 267

Rep: Reputation: 58
Actually the su geo -c (Substitute User) runs the command with the uid and gid as specified - in this case as geo. So the torrent runs as geo, not root.

Dave
 
Old 05-22-2009, 11:41 PM   #7
geomysterio
LQ Newbie
 
Registered: May 2009
Distribution: Fedora
Posts: 15

Original Poster
Rep: Reputation: 1
Right. su stands for, "substitute user," not "super-user." Any username placed after the command will be subbed in. Using su with the -c argument basically makes it like sudo, for anyone.
 
Old 05-22-2009, 11:48 PM   #8
geomysterio
LQ Newbie
 
Registered: May 2009
Distribution: Fedora
Posts: 15

Original Poster
Rep: Reputation: 1
Everything works, but I noticed that when I actually reboot the server, rtorrent complains that it "can't resolve host" If I restart it, then it works fine.

I think there might be some issue with rtorrent coming up before networking does. The only thing I can think of is adding a time delay before utorrent boots, but it seems messy. Is there an easy way to test for network connectivity so I can wrap this in a bash script?
 
Old 05-23-2009, 09:10 AM   #9
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS6
Posts: 267

Rep: Reputation: 58
Geo, you could ping a host you know will be up such as your ISP's NS and look for a result code of 0 (a successful ping). I use that a lot with a construction like this:
Code:
ping -c 1 192.168.102.4 &>/dev/null && echo "ping worked to our ISP"
Here are some result codes from ping:
# 192.168.102.7 is a non-existent machine on my net and ping fails
[drf@maplepark bind-9.6.1rc1]$ ping -c 1 192.168.102.7 &>/dev/null ;echo $?
1

# 192.168.102.4 exists and ping succeeds.
[drf@maplepark bind-9.6.1rc1]$ ping -c 1 192.168.102.4 &>/dev/null ;echo $?
0

# lost.nowhere doesn't resolve
[drf@maplepark bind-9.6.1rc1]$ ping -c 1 lost.nowhere &>/dev/null ;echo $?
2

If ping succeeds to your ISP's DNS, then the network has to be up.

Dave
 
Old 05-23-2009, 09:49 PM   #10
geomysterio
LQ Newbie
 
Registered: May 2009
Distribution: Fedora
Posts: 15

Original Poster
Rep: Reputation: 1
That sounds just about perfect!
 
Old 05-24-2009, 12:16 AM   #11
geomysterio
LQ Newbie
 
Registered: May 2009
Distribution: Fedora
Posts: 15

Original Poster
Rep: Reputation: 1
I did it, and it worked!


I just defined a function 'waitnet.' It held at while loop that held until the connection was made. Then I stuck it in front.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Startup script access right error --- rc.local (freeze for long time) fhleung Debian 1 07-30-2007 11:35 PM
Startup script access right fhleung Debian 5 07-24-2007 08:03 PM
Lauching script at shell startup without having root access. begin55676 Linux - Newbie 2 12-10-2004 03:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration