Skip to content
Chris Montgomery edited this page Jun 2, 2017 · 43 revisions

This page will help you get started with WM core. What it will do after you complete these steps is:

  • Display information about free disk space, torrents, etc.
  • Synchronize its database with the torrent client instances. It will display torrent download progress, torrents with tracker or other errors and recently downloaded torrents.
  • Add torrents to best torrent client instance from the homepage. You can paste What permalinks and click Add.
  • Monitor your user profile on What and display graphs based on that.
  • Keep a log of the events that happen on the torrents.
  • Play and download files straight from the WM interface.

The required steps are:

  1. Clone the GitHub repo in a directory of your choice. I use /mnt/tank/lamp/django/, so if you ever see that you know what it is. Choose your install directory, go there cd /mnt/tank/lamp/django, then git clone https://github.com/karamanolev/WhatManager2.git. cd WhatManager2 inside.

  2. If you have transmission installed, skip this step. Run ./setup_transmission-2.92.sh. This will download and install a recent version of libevent needed by Transmission and Transmission 2.92. If you are asked something and you don't know what to answer, just press Enter.

  3. Run ./setup.sh. This will make sure the required system packages are installed, the required python packages are installed and the media directory has the correct rights.

  4. You have to create the SQL database. You can name it whatever you want, I use what_manager2. Make sure the collation is utf8_unicode_ci. A command that does that is mysql -u root -p -e 'CREATE DATABASE what_manager2 COLLATE utf8_unicode_ci;'

  5. Copy ./WhatManager2/settings.example.py to ./WhatManager2/settings.py and open the new file. You'll have to set up some main variables:

    1. WHAT_USER_ID should be set to the id of your user on What.
    2. WHAT_USERNAME should be your username on What.
    3. WHAT_PASSWORD should be your password on What.
    4. TRANSMISSION_PASSWORD should be the password that you want your Transmission instances to have. Pick anything you want. The configuration files for Transmission will be generated with that and you will use that if you want to manage your instances with a remote control app.
    5. TRANSMISSION_FILES_ROOT is the directory where Transmission's data files will go (settings, resume files, DHT cache, etc). Set this to something sensible.
    6. TRANSMISSION_USE_SYSTEMD tells the new transmission instance script to create a systemd file rather than an upstart file. (you will likely want to set this to 'True' if you are using a version of ubuntu newer than 14.04)
    7. In the DB configuration, which is where it says DATABASES = { enter the name of the database (what_manager2 by default), the user and the password for MySQL.
    8. TIME_ZONE is your local time zone. Look at Django docs if you don't know how to spell yours. A list of common timezones and their names can be obtained by running python -c "from pytz import common_timezones; print common_timezones;"
    9. Change SECRET_KEY to a random string.
    10. ALLOWED_HOSTS must be populated with any IPs or domains that you'll be hosting WhatManager under. For instance, if you're hosting it on a server with the IP address 1.2.3.4 and the domain whatmanager.com enter: ['whatmanager.com', '1.2.3.4']. Later versions of Django verify this even when Debug=True is set.
  6. Copy ./bibliotik/settings.example.py to ./bibliotik/settings.py. If you will be using Bibliotik, open the new file and fill it. If not, you can leave it as it is.

  7. Copy ./myanonamouse/settings.example.py to ./myanonamouse/settings.py. If you will be using MyAnonaMouse, open the new file and fill it. If not, you can leave it as it is.

  8. Copy ./qobuz2/settings.example.py to ./qobuz2/settings.py. If you will be using qobuz2, open the new file and fill it. If not, you can leave it as it is.

  9. Create the required tables and initialize the admin user account by running ./manage.py migrate. If you are asked to create a superuser, enter your desired credentials. If not, run ./manage.py createsuperuser and then enter your credentials.

  10. You have to setup Apache (or Nginx following these tentative instructions: Hosting WM using Nginx) to serve traffic from WhatManager2. You can either set it up at the root of your domain, in a subdomain or in a subfolder of an existing domain. If you host it at the root of a (sub)domain, then configuring Apache will be sufficient. If you want to host it in the subfolder, take a look here Hosting WM in a subfolder. By default the configuration file on Ubuntu is /etc/apache2/sites-available/000-default.conf. A sample configuration for it at the root is (put this inside your VirtualHost directive, right above at the end of the file):

    Alias /static/admin /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin
    <Directory /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin>
        Require all granted
    </Directory>
    Alias /static /mnt/tank/lamp/django/WhatManager2/static
    WSGIDaemonProcess whatmanager2 python-path=/mnt/tank/lamp/django/WhatManager2 processes=2 threads=4
    WSGIProcessGroup whatmanager2
    WSGIScriptAlias / /mnt/tank/lamp/django/WhatManager2/WhatManager2/wsgi.py
    WSGIPassAuthorization On
    <Directory /mnt/tank/lamp/django/WhatManager2>
        Require all granted
    </Directory>
    

    Note for Apache pre-2.4: If you have an Apache version below 2.4, replace Require all granted with Allow from all

  11. Reload the apache config by running sudo service apache2 restart.

  12. Fire up your browser and navigate to /admin on your Apache server. This is the admin panel. Go to Home -> Download locations. Create a download location. That's where your torrents will be downloaded. For zone enter redacted.ch, this is mandatory. For path enter anything you like, just make sure the Apache/WSGI process can write there AND Transmission can write there. You can just chmod it to 777 if you are unsure. Check the "preferred" option. If you have more than one download location, your downloads will go to the preferred one. Now go ahead and mkdir the directory then chmod it properly.

  13. Create your first Transmission instance. Actually, this is very easy. Just go to your git repo and run sudo ./manage.py transmission_new redacted.ch. You can accept all the defaults, they are standard for Transmission. The RPC port will be 9091 and the incoming peer port will be 51413. Any further instances will just increment these numbers. After you run this, you should have a running instance. You can connect to it with the above settings and any Transmission remote. Make sure to authenticate with username transmission and whatever password you entered in settings.py. By default Transmission won't auto start with the system. Configuring Transmission autostart

  14. Create a cron jobs to enable WM to sync with the Transmission instances periodically and update your user profile data from What. Make a standard cron file, I name mine /etc/cron.d/what_manager2. The basic sync is as follows (modify the URL if you installed WM in a subfolder):

    MAILTO=""
    */2 * * * * root curl --user <<your admin user username>>:<<password>> --connect-timeout 60 --max-time 120 
    http://localhost/json/sync
    

    The username and password here should be whatever you use to login to WM and admin (the user created by ./manage.py migrate). This basically imitates a browser opening a special WM page, which does the syncing. After you add this, if you go to WM and click Log then turn on "Info", you should see the sync running every 2 minutes. If you want, you can use edit your user's crontab with crontab -e, in which case the syntax is slightly different, like this:

    */2 * * * * curl --user <<your admin user username>>:<<password>> --connect-timeout 60 --max-time 120 
    http://localhost/json/sync
    
  15. Enjoy your WM 👍