Headless uTorrent Linux server in OpenVZ

By , 2010-06-13 21:10

Yes, I know, another Linux post. What can I say, this is what I do these days.

I’ve been running a Windows server in a kvm VM just to be able to run uTorrent. This was overkill, had a crazy amount of overhead, and was unstable (downloading to a share on my Samba server). Today I decided to attempt a more efficient solution: uTorrent in Wine. (Yes, there are other BitTorrent clients, and even… NATIVE Linux clients, but I’ve found none of them match the speed of uTorrent for my connection except for kTorrent. However, I don’t have an Android and/or iPhone app to remote control kTorrent.) Wine is a supported platform, according to the uTorrent website, however I wanted to run it on a headless OpenVZ container, and not on a standard desktop Linux distro. Should still be pretty simple, but knowing me, I might forget something next time I try and set this up, so I’ll document it here.

  1. Create a fresh VZ container. I used the Proxmox Debian 6.0 (squeeze) – standard i386 template.
  2. Edit /etc/apt/sources.list to point to a fast mirror in Canada (iweb!)
    deb http://debian.mirror.iweb.ca/debian squeeze main contrib non-free
    deb http://debian.mirror.iweb.ca/debian-security squeeze/updates main contrib non-free
  3. run an apt-get update && apt-get upgrade
  4. apt-get install wine sudo xterm openbox tightvncserver
  5. adduser matt
  6. add google repo: http://www.google.com/linuxrepositories/apt.html
  7. install Google Chrome
  8. wget http://download.utorrent.com/2.0.2/utorrent.exe
  9. From another PC: ssh -Y matt@openvz-container
  10. wine winecfg
  11. run vncserver and set a password.
  12. run wine utorrent.exe
  13. Enable Web UI

Next steps:

  1. Set up Dropbox for easy adding of torrents: http://wiki.dropbox.com/TipsAndTricks/TextBasedLinuxInstall
  2. Make uTorrent and VNC server run on container startup*
  3. Create a VZ mount script so that torrents download outside of /vz area.

* For this I used a cool script obtained from http://www.abdevelopment.ca/blog/start-vnc-server-ubuntu-boot :

  1. Modify your ~/.vnc/xstartup to start the programs you want (gnome-session, lxde-session, utorrent, etc.)
  2. Save the following script as /etc/init.d/vncserver. Change
    export USER="mythtv"

    to the user you want to run the VNC session for.

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          vncserver
# Required-Start:    networking
# Default-Start:     3 4 5
# Default-Stop:      0 6
### END INIT INFO
 
PATH="$PATH:/usr/X11R6/bin/"
 
# The Username:Group that will run VNC
export USER="mythtv"
#${RUNAS}
 
# The display that VNC will use
DISPLAY="1"
 
# Color depth (between 8 and 32)
DEPTH="16"
 
# The Desktop geometry to use.
#GEOMETRY="x"
#GEOMETRY="800x600"
GEOMETRY="1024x768"
#GEOMETRY="1280x1024"
 
# The name that the VNC Desktop will have.
NAME="my-vnc-server"
 
OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"
 
. /lib/lsb/init-functions
 
case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;
 
stop)
log_action_begin_msg "Stopping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;
 
restart)
$0 stop
$0 start
;;
esac
 
exit 0

For more info, see the source link.

Custom theme by me. Based on Panorama by Themocracy