Use rtorrent as daemon

peshua19

Member
May 25, 2018
897
0
16
Hello, i post before, but i think mods erase my topic

im using opnewrt in router and im very interested to use rtorrent with rutorrent.

I have setup lighttpd server with rutorrent and everything runs good but i like to run my rtorrent in daemon mode.

I have used different scripts but is impossible to autoboot rtorrent at startup of router.

The best i did is this script

Now im using this script in /etc/init.d/rtorrent

#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org

START=99

start() {
start-stop-daemon -S -u root -n rtorrent -x /usr/bin/dtach -- -n /tmp/rtorrent.dtach rtorrent
}

stop() {
killall rtorrent
}


it boot in startup, i see tmp "ls /tmp" and dtach file is ok but if i run dtach -a /tmp/rtorrent.dtach the rtorrent do not have anything on it and rutorrent do not recognize the open rtorrent... but if i kill it and command /etc/init.d/rtorrent without reboot it runs fine

The process is in LUCI startup web page but i can not start them. i click on start, or stop but nothing happens, enable is ok

Can you help me please?
 

peshua19

Member
May 25, 2018
897
0
16
Thx sroos1 for answer, can you help me to use the crontab? I dont know where i need to put this script in

Thx a lot
 

peshua19

Member
May 25, 2018
897
0
16
I think my unix skills are very poor...

Im trying to do the crontab script but if i do logread "cron ignoring rtorrent file"

Im triying to do a simple init script with:

/usr/sbin/screen -fa -d -m -S rtorrent /usr/bin/rtorrent

runs well but it create a empty sesion of rtorrent (see atached images)

when i run /etc/init.d/rtorrent start in prompt command, everything runs like a charm...with normal session with my torrents



If you see, in top of rtorrent i get OpenWrt:Number --> when i put the before command

But when i boot the script it creates a screen with an empty rtorrent session



You can see NONE: number... i think is a user problems? or is a .rtorrent.rc?? (screen do not charge rtorrent.rc)

If i start the init script by Luci i get OpenWrt ok in top but problem to .rtorrent.rc




You know how can i solve it?

thx!
 

randac56

Member
May 25, 2018
915
0
16
Is your init script running this as the user account or root?
try prepending: sudo -H -u <username>
 

peshua19

Member
May 25, 2018
897
0
16
Im using openwrt (is a rtorrent installed in router)... init script is running as root

i do not have any other user created in.
 

simur612

Member
May 25, 2018
879
0
16
Quote :
Im using openwrt (is a rtorrent installed in router)... init script is running as root


1) This is a bad practice.
2) Check order. May be, rtorrent service started before partition mounting or something else?
 

peshua19

Member
May 25, 2018
897
0
16
Quote:
Quote:
Im using openwrt (is a rtorrent installed in router)... init script is running as root

1) This is a bad practice.
2) Check order. May be, rtorrent service started before partition mounting or something else?


fstab starts at 20 and rtorrent script starts at 100

can you explain why is a bad practice?? sorry im noob
 

randac56

Member
May 25, 2018
915
0
16
Quote :
can you explain why is a bad practice?? sorry im noob


For example, you use ruTorrent from WAN with access to RPC mount point. If someone steal login/password from your ruTorrent session, then he will can execute *any* command on your system from the root user.
If you use "ordinal" user for rtorrent, then in this case hacker may run command from this user only.
 

peshua19

Member
May 25, 2018
897
0
16
im using rutorrent only in LAN smiley.gif

im getting crazy... i dont know why if i exec manually the init script it runs perfect but in boot, it creates an screen with empty session of rtorrent which is different than normal session

sad.gif
 

peshua19

Member
May 25, 2018
897
0
16
I see Top text indicates the hostname where rtorrent is running...

so when my router boot and startup the init script it not runs in this hostname (none is in top text)

If i start up by Luci web interface, it creates a correct session with correct host name but do not find the rtorrent.rc
 

peshua19

Member
May 25, 2018
897
0
16
im using that script

Code:
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org

START=100

boot() {
/usr/sbin/screen -fa -d -m -S rtorrent /usr/bin/rtorrent
}

start() {
/usr/sbin/screen -fa -d -m -S rtorrent /usr/bin/rtorrent
}

stop() {

killall rtorrent
}
crontabs not run, all script with sudo commands not run... and in openwrt forum nobody helps cry.gif