Jump to content

Installing uTorrent for Debian 7 - systemd integration


codycook

Recommended Posts

I am running a NAS storage box.

On this storage, it runs Debian 7.

This NAS web interface works with systemd to start 'add-ons'

I am building the add-on from latest version of uTorrent Server for Debian 7.

 

If I was to extract the files to /apps/utorrent/ and start /apps/utorrent/utserver through bash, utserver takes over port 8080 as expected. Accessing the GUI is a breeze. I can configure and have it add the configuration files. I can ctrl+c and reopen /apps/utorrent/utserver with ease and no problem with retaining settings.

 

Now, in order for me to integrate it into the GUI so I don't have to SSH every time to restart uTorrent (if necessary), I am working on the systemd configuration file.

 

My utorrent.service file is as below

 

 

root@expectrn:/apps/utorrent# cat fvapp-utorrent.service
[unit]
Description=uTorrent
After=apache2.target
 
[service]
EnvironmentFile=/apps/utorrent/utorrent_environment
ExecStart=/bin/sh -c '/apps/utorrent/utserver $UTORRENT_CONFIG'
Type=simple
TimeoutSec=200
KillMode=process
Restart=on-failure
 
[install]
WantedBy=multi-user.target
root@expectrn:/apps/utorrent# cat utorrent_environment
# uTorrent Config Starts
UTORRENT_CONFIG=-settingspath /apps/utorrent/config/

 

 

Afterwards, I double check to verify I see that the service is indeed running...

 

 

root@expectrn:/apps/utorrent# systemctl status fvapp-utorrent.service
fvapp-utorrent.service - uTorrent
          Loaded: loaded (/apps/utorrent/fvapp-utorrent.service; enabled)
          Active: active (running) since Wed, 09 Jul 2014 23:50:31 -0700; 30s ago
        Main PID: 342 (sh)
          CGroup: name=systemd:/system/fvapp-utorrent.service
                  ├ 342 /bin/sh -c /apps/utorrent/utserver $UTORRENT_CONFIG
                  └ 343 /apps/utorrent/utserver -settingspath /apps/utorrent/config/
 
I then try to access the web interface now that it says it is started. If I was to access http://expectrn:8080/, I receive the invalid request error from utserver as I normally would.
http://expectrn:8080/gui will prompt for credentials for uTorrent server. I enter default credentials to access GUI and the page returns blank in a browser. 
Using cURL, I investigated further.

 

root@expectrn:/apps/utorrent# curl -v http://admin@localhost:8080/

* Hostname was NOT found in DNS cache
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
* Server auth using Basic with user 'admin'
> GET / HTTP/1.1
> Authorization: Basic YWRtaW46
> User-Agent: curl/7.35.0
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 400 ERROR
< Connection: keep-alive
< Content-Length: 17
< Content-Type: text/html
<
 
* Connection #0 to host localhost left intact
invalid request
root@expectrn:/apps/utorrent# curl -v http://admin@localhost:8080/gui
* Hostname was NOT found in DNS cache
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
* Server auth using Basic with user 'admin'
> GET /gui HTTP/1.1
> Authorization: Basic YWRtaW46
> User-Agent: curl/7.35.0
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Connection: close
< Location: /gui/
<
* Closing connection 0
root@expectrn:/apps/utorrent# curl -v http://admin@localhost:8080/gui/web
* Hostname was NOT found in DNS cache
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
* Server auth using Basic with user 'admin'
> GET /gui/web HTTP/1.1
> Authorization: Basic YWRtaW46
> User-Agent: curl/7.35.0
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Content-Length: 0
<
* Connection #0 to host localhost left intact
root@expectrn:/apps/utorrent# curl -v http://admin@localhost:8080/gui/web/index.html
* Hostname was NOT found in DNS cache
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
* Server auth using Basic with user 'admin'
> GET /gui/web/index.html HTTP/1.1
> Authorization: Basic YWRtaW46
> User-Agent: curl/7.35.0
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Content-Length: 0
<
* Connection #0 to host localhost left intact
 
404 error? That doesn't seem quite right.
Does anyone have any suggestions as to what is going on and what I could try?
Help appreciated in advance.

 

Link to comment
Share on other sites

  • 3 weeks later...

Where are you locating the file webui.zip?  By default, it should be in your settings directory, which you have as /apps/utorrent/config/ - if you don't want it there, you can modify utserver.conf to set a value of the ut_webui_dir parameter to point to the directory containing webui.zip.  Read the documentation about ut_webui_dir for more information.

 

I would expect that you would not be able to access the web UI via a simple curl command.  You would first need to obtain a cross-site scripting defense token, and then include that token into the parameter list of the request.

 

Sorry for the delayed response - I took some time off.

Link to comment
Share on other sites

  • 3 weeks later...

Hi mcdonald,

Thanks for the reply. I have taken some time off as well.

 

By default, the webui.zip file exists in the root directory of the extracted file, so I had not moved it from there and it exists alongside utserver.

 

I have config files everywhere... In /, in /apps/utserver... in /apps/utserver/config/... 

I just deleted all configs I saw and going to try running again. I moved webui into the config folder.

root@expectrn:/apps/utorrent# tree.├── config│   └── webui.zip├── config.xml├── fvapp-utorrent.service├── logo.png└── utserver1 directory, 5 filesroot@expectrn:/apps/utorrent#

Started the server manually...
root@expectrn:/apps/utorrent# ./utserver
 
I tried accessing the IP and it asked for credentials, but it didn't show me the webui like it would normally do. 
I then ctrl+c the utserver to exit out.
 
root@expectrn:/apps/utorrent# ./utserver^Croot@expectrn:/apps/utorrent# tree.├── config│   └── webui.zip├── config.xml├── dht.dat├── dht_feed.dat├── fvapp-utorrent.service├── logo.png├── resume.dat├── rss.dat├── settings.dat├── share└── utserver2 directories, 10 filesroot@expectrn:/apps/utorrent#

If I move back the webui file from the config folder to the root directory of the utorrent folder...

 

root@expectrn:/apps/utorrent# mv config/webui.zip ./root@expectrn:/apps/utorrent# lsconfig  config.xml  dht.dat  dht_feed.dat  fvapp-utorrent.service  logo.png  resume.dat  rss.dat  settings.dat  share  utserver  webui.zip
vavBQha.jpg

Works fine...
 
Is that contradictory to you saying it needs to be in the config folder?
 

By the way, I wasn't expecting to see the GUI specifically, but something other than 404. This is what curl outputs when I access the GUI when it is up and running.

root@expectrn:/apps/utorrent# curl -v http://admin@localhost:8080/gui/web/index.html* Hostname was NOT found in DNS cache*   Trying ::1...* Connected to localhost (::1) port 8080 (#0)* Server auth using Basic with user 'admin'> GET /gui/web/index.html HTTP/1.1> Authorization: Basic YWRtaW46> User-Agent: curl/7.35.0> Host: localhost:8080> Accept: */*>< HTTP/1.1 200 OK< Connection: keep-alive< Content-Length: 53146< Content-Type: text/html< ETag: "52D6673F00000000"< Set-Cookie: GUID=Ez1Y4nQdNsU8SOXzrDch; path=/<<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><!--Copyright (c) 2013 BitTorrent, Inc. All rights reserved.Use of this source code is governed by a BSD-style license that can befound in the LICENSE file.--><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">        <head>                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />                <title>µTorrent Server</title>                <link href="./images/ut_small.png" rel="icon" type="image/png" />                <link href="./css/main.css" rel="stylesheet" type="text/css" />                <link href="./css/dialogs.css" rel="stylesheet" type="text/css" />                <link href="./css/stable.css" rel="stylesheet" type="text/css" />    <link type="text/css" rel="stylesheet" href="css/header_webui.css" />                <!--[if IE]>                <script type="text/javascript" src="./ie.js"></script>                <script type="text/javascript" src="./excanvas.js"></script>                <![endif]--><style type="text/css"><!-- Overrides entry in header_new.css that uses uTorrent remote background -->#header #flag {    background: url("images/utorrent.png") no-repeat;/*     width: 200px;    height: 58px;    position: relative;    top: 15px;    float: left; */}    div .active_tab {      background: #fff;      border-radius: 4px;      border: 1px solid #444;      border-bottom: 0;    }</style><script>        if (!window.console) {            window.console = {                log: function() {},                error: function() {},                warn: function() {},                warning: function() {},                debug: function() {}            }        }</script><script src="./tags.js" type="text/javascript"></script>    <script>  var agent=navigator.userAgent.toLowerCase();  var is_iphone = (agent.indexOf('iphone')!=-1);  var is_ipad = (agent.indexOf('ipad')!=-1);  var is_android = (agent.indexOf('android')!=-1);  function detect_new_blackberry() {    return (agent.indexOf('blackberry')!=-1 && agent.indexOf('mobile safari')!=-1);  }  function wants_mobile_ui() {    return (is_iphone || is_android || detect_new_blackberry());  }var config = {  cookies: {    web_seed_link: false  },  webui: true,  cache_bust: false,  static_prefix: '/gui/web',  path_gui: '/gui/web',  proxy_prefix: '/proxy',  path_mobile: '/gui/mobile',  product: 'server',  name: 'µTorrent'};    </script><script src="./js/jsloadv2.js" type="text/javascript"></script><script>  var tags = [];for (var i=0; i<_bt_scripts.length-1; i++) {  var name = _bt_scripts[i];  tags.push( { name: name } );}tags.push( { name: _bt_scripts[_bt_scripts.length-1], requires: _bt_scripts.slice(0, _bt_scripts.length-1) } );(new JSLoad(tags)).load( [_bt_scripts[_bt_scripts.length-1]], function() {  webui_main();});</script>        </head>        <body>    <div id="header-wrap">                <div id="header" class="bittorrent">                        <a href="#" id="flag" class="bittorrent"></a>                        <ul id="header_menu">                                <li><a href="#" id="show_about">About</a></li>                        </ul>                </div>    </div>                <div id="cover">                        <div id="msgout"><div id="msgmid"><div id="msg">                                <img src="./images/snake.gif" alt="Loading..." />                                Loading...                        </div></div></div>                </div>                <div id="modalbg"></div>                <!-- /* About Dialog -->                <div id="dlgAbout" class="dlg-window" style="height:300px; width: 350px;">                        <a href="#" class="dlg-close"></a>                        <div id="dlgAbout-head" class="dlg-head">About</div>                        <div class="content" style="margin-top:30px">                                <div style="text-align:center">                                  <img src="./images/ut.png" alt="µTorrent" /><br />                                  <span id="about_product_title">µTorrent Server</span>                                </div>                        </div>                        <div class="content" style="margin-top:15px;margin-bottom:2px">Copyright © 2013 BitTorrent, Inc.</div>                        <div class="content">All Rights Reserved.</div>                        <fieldset id="client_version_set" style="display:none">                                <legend id="DLG_ABOUT_VERSION_LEGEND"></legend>                                <div class="hcontcv">                                        <span id="DLG_ABOUT_VERSION_VERSION"></span>                                        <span id="client_version" class="flrcv"></span>                                </div>                                <div class="hcontcv">                                        <span id="DLG_ABOUT_VERSION_REVISION"></span>                                        <span id="client_revision" class="flrcv"></span>                                </div>                                <div class="hcontcv">                                        <span id="DLG_ABOUT_VERSION_BUILD_DATE"></span>                                        <span id="client_build_date" class="flrcv"></span>                                </div>                                <div class="hcontcv">                                        <span id="DLG_ABOUT_UI_REVISION"></span>                                        <span id="ui_revision" class="flrcv"></span>                                </div>                                <div class="hcontcv">                                        <span id="DLG_ABOUT_VERSION_PEER_ID"></span>                                        <span id="client_peer_id" class="flrcv"></span>                                </div>                                <div class="hcontcv">                                        <span id="DLG_ABOUT_VERSION_USER_AGENT"></span>                                        <span id="client_user_agent" class="flrcv"></span>                                </div>                                <div class="hcontcv">                                        <span id="DLG_ABOUT_UPNP_EXTERNAL_ADDRESS"></span>                                        <span id="upnp_external_address" class="flrcv"></span>                                </div>                        </fieldset>                </div>                <!-- About Dialog */ -->                <!-- /* Torrent Delete Dialog -->                <div id="dlgDelete" class="dlg-window">                        <a href="#" class="dlg-close"></a>                        <div id="dlgDelete-head" class="dlg-head">Delete Torrents</div>                        <form id="dlgDelete-form" action="">                                <div class="dlg-body">                                        <h4 id="dlgDelete-caption">Are you sure you want to remove <span class="count">1</span> torrent<span class="plural">s</span>?</h4>                                        <div class="line-cont">                                                <input type="radio" name="dlgDelete-torrent" id="dlgDelete-no-data" value="torrent" checked="checked" />                                                <label for="dlgDelete-no-data">Just delete torrent</label>                                        </div># I DELETED MANY LINES OF CODE FROM THIS WINDOW.                <div id="mainVDivider"></div>                <div id="mainHDivider"></div>        <iframe id="hidden_upload_iframe" style="display:none"></iframe>        <iframe id="download_iframe" style="display:none"></iframe>        </body></html>* Connection #0 to host localhost left intact

 

Link to comment
Share on other sites

Actually, I get what you were saying now. 
I had manually set that with the environments file. I had changed my config and was thinking based on my most recent config.  Sorry.
 
Based on what you provided me, I decided to make this change to the systemd file.
 
root@expectrn:/apps/utorrent# cat fvapp-utorrent.service[Unit]Description=uTorrentAfter=apache2.target[Service]ExecStart=/bin/bash -c '/apps/utorrent/utserver -settingspath /apps/utorrent/ -logfile /apps/utorrent/utserver.log''Type=simpleTimeoutSec=200KillMode=processRestart=on-failure[Install]WantedBy=multi-user.target
 
Once I did that, I started utserver via systemctl.
 
root@expectrn:/apps/utorrent# systemctl start fvapp-utorrent.serviceroot@expectrn:/apps/utorrent# systemctl status fvapp-utorrent.servicefvapp-utorrent.service - uTorrent          Loaded: loaded (/lib/systemd/system/fvapp-utorrent.service; enabled)          Active: active (running) since Wed, 13 Aug 2014 19:48:46 -0700; 6s ago        Main PID: 6879 (utserver)          CGroup: name=systemd:/system/fvapp-utorrent.service                  └ 6879 /apps/utorrent/utserver -settingspath /apps/utorrent/ -logfile /apps/utorrent/utserver.logroot@expectrn:/apps/utorrent# ps aux | grep utserverroot      6879  0.1  0.0 166336  3168 ?        Ssl  19:48   0:00 /apps/utorrent/utserver -settingspath /apps/utorrent/ -logfile /apps/utorrent/utserver.logroot      6902  0.0  0.0  13012   864 pts/1    S+   19:49   0:00 grep utserverroot@expectrn:/apps/utorrent# curl -v http://admin@localhost:8080/gui/web/index.html | head -n 30* Hostname was NOT found in DNS cache  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                 Dload  Upload   Total   Spent    Left  Speed  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying ::1...* Connected to localhost (::1) port 8080 (#0)* Server auth using Basic with user 'admin'> GET /gui/web/index.html HTTP/1.1> Authorization: Basic YWRtaW46> User-Agent: curl/7.35.0> Host: localhost:8080> Accept: */*>< HTTP/1.1 200 OK< Connection: keep-alive< Content-Length: 53146< Content-Type: text/html< ETag: "52D6673F00000000"< Set-Cookie: GUID=omlSyKGOaonJehRuHhx4; path=/<{ [data not shown]100 53146  100 53146    0     0  31.5M      0 --:--:-- --:--:-- --:--:-- 50.6M* Connection #0 to host localhost left intact<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><!--Copyright (c) 2013 BitTorrent, Inc. All rights reserved.Use of this source code is governed by a BSD-style license that can befound in the LICENSE file.--><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">        <head>                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />                <title>µTorrent Server</title>                <link href="./images/ut_small.png" rel="icon" type="image/png" />                <link href="./css/main.css" rel="stylesheet" type="text/css" />                <link href="./css/dialogs.css" rel="stylesheet" type="text/css" />                <link href="./css/stable.css" rel="stylesheet" type="text/css" />    <link type="text/css" rel="stylesheet" href="css/header_webui.css" />                <!--[if IE]>                <script type="text/javascript" src="./ie.js"></script>                <script type="text/javascript" src="./excanvas.js"></script>                <![endif]--><style type="text/css"><!-- Overrides entry in header_new.css that uses uTorrent remote background -->#header #flag {    background: url("images/utorrent.png") no-repeat;/*     width: 200px;    height: 58px;    position: relative;    top: 15px;    float: left; */

Looks like I was just selecting the wrong information. 

Thank you very much for the help.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...