rtorrent restart script through webpage

jith45

Member
May 25, 2018
960
0
16
Hello everyone,
I'm sharing a server with friends, 3 virtual servers with ubuntu and rtorrent+rutorrent installed.

I was thinking of giving to my friends the ability to easily restart rtorrent with a script which can be executed through a webpage (php script?), instead of logging every time via SSH and using the /etc/init.d/rtorrent stop - start command.

I know is it possibile because on a seedbox reseller I used before this was possibile, but I really need help because I don't know where to start. cheesy.gif

any help will be appreciated!
thanks and regards.
 

das329717

Member
May 25, 2018
928
0
16
The plugin developed for a seedbox provider was paid for by them and done on an exclusive basis, at least until october.

Of course, you're free to develop your own solution.
 

jith45

Member
May 25, 2018
960
0
16
I don't think it was a plugin, because it was just a php link in their "server info page", not in rutorrent.
 

somus1735

Member
May 25, 2018
833
0
16
I don't think it was a plugin, because it was just a php link in their "server info page", not in rutorrent.
At first this is easy, if rTorrent client work on Web Server context, and all folders which use rtorrent configured for WebServer user.

Another think: Write simple crontab task, which will do some actions if some "flag" is exists. Flag - can be a file with some custom name.
This flag can created by php script, also php can read last status of operation from pre-defined status file (which can be writed by crontab script).
 

das329717

Member
May 25, 2018
928
0
16
I have come up with a solution not the best solution but it works

first logon to ssh
then run visudo to edit your sudo users list

find
Code:
# User privilege specification
In that section add
Code
%www-data ALL=NOPASSWD: /etc/init.d/rtorrent startSave the file

Now create a php file name it what you like
Code:
<?ph
$output = shell_exec(&#39;sudo /etc/init.d/rtorrent start&#39;);
echo "<pre>$output</pre>";
?>
Save that php code in your web directory

execute the php script to restart rtorrent

This method relies on the tutorial being followed in this link http://forums.rutorrent.org/index.php?topic=256.0 in particular apache being your webserver and rtorrent startup script being created

Hope this helps and as always would like feedback of any issue or problems using this method
 

shwetha17

Member
May 24, 2018
785
0
16
instead, you could make it slightly safer like this:


www-data ALL=(rtorrentuser1) NOPASSWD: /some/command, /some/command2



and really, all you need to actually START rtorrent would be a script like this:

Code: [Select]
!#/bin/sh
PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin

rm -f /home/$USER/.session/rtorrent.lock
screen -dms ${USER}seed rtorrent


also, keep in mind you can STOP rtorrent with pkill

something like:

Code:
sudo -H -u $USER pkill -u $USER rtorrent


again, you'd want to add this to your list of allowable sudo commands, and you can also add multiple users and multiple commands to sudo like so:


Code:
www-data ALL=(rtuser1, rtuser2, rtuser3) NOPASSWD: /bin/rm, /usr/bin/pkill, /bin/sh, /usr/bin/screen, /usr/local/bin/rtorrent, /usr/local/bin/starterscript.sh



take this for what it is worth