Friday, August 2, 2013

Stand alone Utorrent Server x64 (64bit) on Linux without system dependecies

Utorrent has released a 64 bit build for Linux platforms (see details here). The release is built on Ubuntu 12.04 (LTS). The problem is that if you try to run it on a distribution like RHEL/CentOS or any older distribution with old libraries, it will fail because of the newer dependencies like glibc 2.14 and libssl 1.0.0 etc.
./utserver: /usr/lib64/libssl.so.1.0.0: no version information available (required by ./utserver)
./utserver: /usr/lib64/libcrypto.so.1.0.0: no version information available (required by ./utserver)
./utserver: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./utserver)
Here is a solution to run utorrent server standalone on any 64 bit distribution without using/touching the system's libraries (hence no dependencies). The trick is to collect all the required libraries separately and run utorrent using those in isolation from the system. Here are the steps:

First collect the required libraries, the list is not huge, utorrent binary (utserver) only has a few dependecies namely:
glibc, libgcc, libselinux, libkeyutils, libssl, libcomerr, libkrb5, zlib
So what we are going to do is to collect all these pre-compiled libraries from a newer distribution like Fedora-19-x64 or Ubuntu-12.04-x64 or any distribution that has the required newer libraries, you can collect them from the online software repositories or from where ever you feel comfortable.

I am going to use the safest (not the most convenient) option, get these libraries from Ubuntu server 12.04.2 (x64) distribution CD. I say it is the safest because the distributed utorrent package (Ubuntu 12.04 build x64 (27079)) is built on this version of Ubuntu, so one can be sure that libraries on this distro will meet the requirement (By the way, I tried this method using the packages from Fedora 19 and it worked perfectly fine).

Download the Ubuntu server 12.04.2 (x64) CD:
cd
wget http://releases.ubuntu.com/12.04.2/ubuntu-12.04.2-server-amd64.iso
Mount the CD:
mkdir /mnt/ubuntu12042
mount -o loop,ro /root/ubuntu-12.04.2-server-amd64.iso /mnt/ubuntu12042
Copy the required packages to the temporary location:
mkdir /tmp/debs
cp /mnt/ubuntu12042/pool/main/g/gcc-4.6/libgcc1_4.6.3-1ubuntu5_amd64.deb /tmp/debs/
cp /mnt/ubuntu12042/pool/main/k/krb5/libkrb5-3_1.10+dfsg~beta1-2ubuntu0.3_amd64.deb /tmp/debs/
cp /mnt/ubuntu12042/pool/main/e/e2fsprogs/libcomerr2_1.42-1ubuntu2_amd64.deb /tmp/debs/
cp /mnt/ubuntu12042/pool/main/z/zlib/zlib1g_1.2.3.4.dfsg-3ubuntu4_amd64.deb /tmp/debs/
cp /mnt/ubuntu12042/pool/main/k/keyutils/libkeyutils1_1.5.2-2_amd64.deb /tmp/debs/
cp /mnt/ubuntu12042/pool/main/libs/libselinux/libselinux1_2.1.0-4.1ubuntu1_amd64.deb /tmp/debs/
cp /mnt/ubuntu12042/pool/main/e/eglibc/libc6_2.15-0ubuntu10.3_amd64.deb /tmp/debs/
cp /mnt/ubuntu12042/pool/main/o/openssl/libssl1.0.0_1.0.1-4ubuntu5.5_amd64.deb /tmp/debs/

Extract the packages:
cd /tmp/debs/
for package in *.deb; do
ar p $package data.tar.gz | tar -zx
done
Download utorrent:
cd
wget 'http://download.utorrent.com/linux/utorrent-server-3.0-ubuntu-12.04-27079.x64.tar.gz'
tar -xzf utorrent-server-3.0-ubuntu-12.04-27079.x64.tar.gz
mv ./utorrent-server-v3_0 /opt/utorrent
Copy the libraries from the extracted packages:
mv /tmp/debs/lib /opt/utorrent/
#rm -rf /tmp/debs
That's it! Now you have the 64 bit utorrent in /opt/utorrent and all the required libraries in /opt/utorrent/lib. Now you can run utorrent using the following command:
/opt/utorrent/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 --library-path /opt/utorrent/lib/x86_64-linux-gnu /opt/utorrent/utserver

In the following steps I'll setup a secure, proper and clean environment for utorrent running it with a limited user and with proper configuration, log and pid files etc.

Make the required directories in utorrent:
cd /opt/utorrent
mkdir conf log pid settings webui data
mv webui.zip webui/
Get the default configuration file:
wget -O /opt/utorrent/conf/utserver.conf http://kxr.me/blog/uts/utserver.conf.customlibs.ubuntu64
Get the control script (to start/stop/reload utorrent)
wget -O /opt/utorrent/utsctl http://kxr.me/blog/uts/utsctl.customlibs.ubuntu64
chmod +x /opt/utorrent/utsctl
ln -s /opt/utorrent/utsctl /usr/local/bin/utsctl
Set the owner permissions:
 (note I am using the utorrent user, but you can use any user. If you use a different user, update the shell_user variable in /opt/utorrent/utsctl accordingly)
useradd -d /opt/utorrent
chown -R utorrent.utorrent /opt/utorrent
There you go, if you did all the steps correctly, you should now be able to start utorrent server by:
utsctl start
The configuration file is located in:
(Note: after changing the configuration file do a "utsctl reload" for the new changes to take effect. Stopping and starting will not load the new changes.)
/opt/utorrent/conf/utserver.conf
Don' forget to set the user name, password and directories in the configuration file. Right now the configuration file we downloaded is set to download every thing in /opt/utorrent/data/ and the login credentials are:
user: admin
pass:

You can use the same exact steps to setup a stand alone 32 bit utorrent server that will run on both 64bit and 32bit systems without requiring any system library/dependency. In order to do so use the 32 bit ubuntu server 12.04.2 CD for the 32 bit pacakges and use the 32 bit utorrent package: Ubuntu 10.10 x86 (27079). Don't forget to set the lib_path variable in /opt/utorrent/utsctl to "/opt/utorrent/lib/i386-linux-gnu"

Suggestions and Comments are welcomed :)

13 comments:

  1. I get the following error:

    root@KaliChad:/opt/utorrent# /opt/utorrent/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 --library-path /opt/utorrent/lib/x86_64-linux-gnu /opt/utorrent/utserver
    /opt/utorrent/utserver: error while loading shared libraries: /opt/utorrent/utserver: wrong ELF class: ELFCLASS32

    Why is that? I am running debian OS 64 bit..

    ReplyDelete
  2. Also when doing:

    root@KaliChad:/opt/utorrent# utsctl status
    Utorrent seems to be stopped, PID file /opt/utorrent/pid/utserver.pid not found or empty

    Where do i get the PID file from?

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Thanks so much for this! Using this I was finally able to get utorrent running on Centos 6.4. Anyways, the new version of utorrent is based on Ubuntu 13.04 so a few things have changed. Since I used your blog to figure out how to get it working, I figured I would post the changes in case you want to make a new blog post for the latest version.

    cd /tmp
    wget http://releases.ubuntu.com/13.04/ubuntu-13.04-server-amd64.iso

    ReplyDelete
  5. mkdir /mnt/ubuntu1304

    mount -o loop,ro /tmp/ubuntu-13.04-server-amd64.iso /mnt/ubuntu1304/


    mkdir /tmp/debs
    cp /mnt/ubuntu1304/pool/main/g/gcc-4.7/libgcc1_4.7.3-1ubuntu1_amd64.deb /tmp/debs
    cp /mnt/ubuntu1304/pool/main/k/krb5/libkrb5-3_1.10.1+dfsg-4+nmu1_amd64.deb /tmp/debs
    cp /mnt/ubuntu1304/pool/main/e/e2fsprogs/libcomerr2_1.42.5-1ubuntu4_amd64.deb /tmp/debs
    cp /mnt/ubuntu1304/pool/main/z/zlib/zlib1g_1.2.7.dfsg-13ubuntu2_amd64.deb /tmp/debs
    cp /mnt/ubuntu1304/pool/main/k/keyutils/libkeyutils1_1.5.5-4_amd64.deb /tmp/debs
    cp /mnt/ubuntu1304/pool/main/libs/libselinux/libselinux1_2.1.9-5ubuntu1_amd64.deb /tmp/debs
    cp /mnt/ubuntu1304/pool/main/e/eglibc/libc6_2.17-0ubuntu5_amd64.deb /tmp/debs
    cp /mnt/ubuntu1304/pool/main/o/openssl/libssl1.0.0_1.0.1c-4ubuntu8_amd64.deb /tmp/debs

    ReplyDelete
  6. I think this is the only good guide for Centos 6.5. Thank you!

    ReplyDelete
  7. Thank you so much for this, although with minor tweaks( ubuntu-12.04.2-server-amd64.iso is updated to ubuntu-12.04.4-server-amd64.iso on its servers, and few debs filenames changed too) everything else worked correctly.

    Also for those who can't mount iso (kernel doesn't support, etc...): you can use 7z.

    ReplyDelete
  8. Thanks for your guide, but when I run utserver this error appears: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory

    I do not know why this error occurs, please help me fix it, thank you :D

    ReplyDelete
  9. This comment has been removed by a blog administrator.

    ReplyDelete
  10. This comment has been removed by a blog administrator.

    ReplyDelete
  11. Welcome to https://www.btlcasino.com
    leading online entertainment betting site that presents you with different online betting experiences, including sports betting, online casinos, live casino games, online poker, slot machines and more. https://www.omgqq.com

    ReplyDelete
  12. 188bet.com Review 2021 (2021) - Topbet
    Our 188bet review offers クイーンカジノ a complete overview of 188bet 188bet.com, its welcome bonuses, betting options and much more. Rating: 5 · ‎Review 인카지노 by THTECH

    ReplyDelete
  13. Linux® is an open source operating system (OS). An operating system is the software that directly manages a system's hardware and resources, like CPU, memory, and storage. The OS sits between applications and hardware and makes the connections between all of your software and the physical resources that do the work.

    ReplyDelete