pyLoad in a Debian chroot on the DS215j

Introduction

During my last post about the DS215j from Sinology i introduced the DiskStation and provided a way to bootstrap the NAS. Lately i found myself in the situation that it was not enough to be able to install packages using bootstrap and ipkg. I’d like to have a working pyLoad installation to be able to handle all of my downloading belongings. The provided DownloadStation was not capable of handling so called OneClickHoster especially the captcha request.

Because of this reason i needed an alternative. It was very easy to find some, pyLoad. It was not that easy to get it running on my DS215j. There are precompiled .ipk packages of pyLoad on their homepage but they are not working because of an issue with python.

I will provide the instructions to install pyLoad from ipkg even if it is not runnable. Because if someone has the same problems, he will find this article and sees the better solution.

Install pyLoad

From ipkg sources

This part of the article won’t provide you a running pyLoad instance by now. Maybe there will be a python2.7 fix for the following issues.

Needed packages

First we need a list of packages to be able to run pyLoad. The following command will install them. You have to log-in into your DiskStation using root or a user able to use sudo.

Download the pyLoad package

The precompiled package will be downloaded directly from the homepage of pyLoad and installed afterwards.

Running pyLoadCore

During the first start, pyLoad should place its default configuration under ~/.pyLoad, which it does, but nothing more. The -s parameter starts the initial setup process.

The command finished exactly after it was started. This couldn’t be the way it should work. I dug a little bit deeper and ran the following command to be able to see a few debug messages.

This provided me with this truncated output.

That message indicates a problem with some module. Some googling showed me, there is a problem with pyLoad an python2.5, which is default, running the python command. Knowing about this i tried python2.6, getting the same result. Only python2.7 gave me another result. But not the one i was expecting.

The needed pycurl is currently not available for python2.7 on arm architecture.

Now it was time to give up this way and switch to a more powerful but advanced solution.

Using a Debian chroot environment

What is chroot

Chroot is short for change root and means to change the root directory of a process running on a linux system. The process is encapsulated inside this environment and can’t access files and folders outside of it. With a few device mount-points we are able to run a whole linux system inside of this sandbox and can use all of the benefits of it without changing the host operating system. Chroot is a simple sandboxing and virtualization approach.

Remove pyLoad ipkg installation

Before we are getting started with our chroot installation, we will clean the mess we did earlier.

Chroot package from SynoCommunity

The guys over at SynoCommunity are providing a fully functional debian wheezy chroot environment. If you have added their repository into your DSM Package Center, simply install the debian-chroot package that can be found under the community tab.

This will take a few minutes install because of its size. After the installation is finished, click the action dropdown and select run. The next steps will be performed via ssh on your DiskStation.

Set up your chroot environment

The first things we have to do, is to mount your Volume and to add all of your users. The last step is needed to prevent file-mode issues between the host system and your chroot.

Mount your volume

To enter your new environment, the package provides a simple script that could be called with some params. We will run the following commands to enter the chroot as root user and create a folder to mount your volume.

Now we have to edit the script we called seconds ago and add a few lines to handle the mounting of our volume. I will post the whole modified script with adding descriptions in just before the lines i added.

Now we can stop and restart the environment to be able to use our mounted volume.

Generate locales and set timezone

By default Debian has no configured locale packages. We have to install them and set them up according to our needs.

Add the users and groups

To be able to write and read onto your data you have to set up a group inside your DSM that has full access to your volume and contains all of the users that should have access from inside your chroot.

Adding a new group is quiet simple. Open your DSM, start the Control Panel, click on groups and create a new one. Mine is called chroot and has access to all of my shared folders.

chroot group on dsm

chroot group on dsm

For the next step we have to leave the DSM because there is no way to get the needed data from there. On your DiskStation shell, type the following commands and note the user id of your user added to the chroot-group and the id of the group itself.

My user id is 1026 and the group id of chroot is 65536. With this information we can log into our debian environment.

Now we are adding the user, in my case it is andre, and the group to the chroot environment. The home folder of the user is my DSM home folder. This is very convenient because now i’m able to share files and configurations that are stored inside of it between the host and the sandboxed system. Another benefit of it is, if you plan to remove the debian-chroot, all files will be kept inside of this folder even after removing the package.

If everything went fine you can check the following command and compare the output.

Install pyLoad in chroot

The installation is simple, paste the following commands and you are ready to go.

You can now run the pyLoad setup process. But for me it was not suitable to run it as root, so i decided to change it to my local user andre. The following steps will show how to do it.

This starts the configuration wizard that will guide you through all necessary parts with ease.

After the config part you can run it directly with removing the -s part from the command. We will start it inside of a screen, to be able to detach the session and keep it up and running.

Autostart pyLoad on DiskStation boot

Because of your chroot-environment not being able to start and stop services by its own during boot-up or shutdown, we have to provide a little script that works from the inside of your DiskStation and is able to do this task.

Log in via ssh as root on your DiskStation and create a file using the following command.

Paste these code into the file.

The script will be launched every time the NAS will boot or shutdown and runs some commands inside your chroot to start or stop your services.

Thats it, you are now able to use pyLoad and it will start and stop automatically.

Use pyLoad

There are many ways to interact with the pyLoad-daemon. The most common way is to use the web-interface. Simply open http://{ip-of-your-ds}:8080 in your preferred browser and you will see some of the following screens. All of the configuration you did earlier during the set-up process can be changed under the config tab.

Sources

 

 

 

17 thoughts on “pyLoad in a Debian chroot on the DS215j

    • TMJ says:

      Hi,

      I try this tutorial “pyLoad in a Debian chroot on the DS215j” but after editing “start-stop-status” file with nano editor when i try to start it i’ve this error msg : /var/packages/debian-chroot/scripts/start-stop-status: line 96: /volume1: Permission denied

      Where is my error ? I’ve copy and paste your whole modified script …

      Regards

      • Hi,

        could you please check to things.
        Your error message looks a bit suspicious, because my initial script only has 89 lines and the your error occured on line 96?
        Could you please paste the whole script?

        Did you run the script as root?

        Best regards,
        André

  1. Squall_Titus says:

    Sorry but i get stuck on the step

    Generate locales and set timezone
    By default Debian has no configured locale packages. We have to install them and set them up according to our needs.

    I get the message
    chroot: can’t execute ‘/bin/zsh’: No such file or directory

    zsh is not installed so this message is correct. What can i do?

    • Hi Klaus,

      you have been completely right.
      by mistake i copied my zsh startup-command. i fixed it now.
      You just have to replace zsh with bash.

      Thanks for this comment.

      Best regards,
      André

  2. Chrosey says:

    Hey,

    I try to follow your How-To but when i try to Mount my Volume shell tells me
    “ash: sudo: not found”

    Can you help me?

    • Hey,

      this tutorial depends on my other how-to bootstrap ds215j.
      You just have to install sudo via ipkg as root.
      ipkg install sudo.

      Or the simplest way is to use the root user, then there is no need for sudo.

      Best regards,
      André

  3. Alex says:

    You won’t need this anymore. SynoCommunity just released a pyload beta package, which is availably in their repo. Just install and you are fine. 🙂

  4. Rico says:

    @André
    Thanks for the guide, it worked but I couldn’t get pyload to start automatically in chroot

    @Alex
    THANKS A THOUSAND TIMES for posting this. I would have never seen they released it!

    • Hi Rico,

      did you follow the autostart steps from “Autostart pyLoad on DiskStation boot”?
      I think you have to change the user used in this script from “andre” to your debian username. Hopefully this will solve your issues.

      best regards
      André

  5. david says:

    @Alex
    I tried to install the pyload beta package of SynoCommunity but it did not work.

    @André
    Is your method still the only one that works?

      • david says:

        Hi André,

        Why did you move from Pyload to JDownloader2? Can you explain a little what are the pros and cons?

        I’ve found a tutorial to install JDownloader2 without using debian chroot. Is it better to use debian chroot?

        I am a new owner of a SYNOLOGY DS215J so I don’t know so much about all these stuffs…

        Best regards,
        David

        • The main reason why i switched from pyLoad to JDownloader is the performance and the overall integration.
          Lately pyLoad became very slow, it took almost 10s to render the downloads overview or to add a new link.
          I searched for an alternative and remembered that JDownloader was capable of all the things i need but i thought i needs at least an x-server (window-server) to be able to run.
          The latest JDownloader2 integrates their own web-cloud-frontend (http://my.jdownloader.org). This enables you to add links from wherever you want. There is also an app for Android.
          And it redirects the captcha request directly to you.

          Regarding the bootstrap, I had problem with installing java on my DS215j outside of the bootstrapped debian, but if you have a good tutorial, please forward it to me 😉

          If you have any question feel free to ask.

          FYI: JDownloader eats a lot of CPU (because of Java), you should be aware of this, when you install it on your diskstation.

    • David says:

      Hi André,

      Finally I decided to install Pyload with your tutorial but i’m stuck with the installation of the locale packages:

      Nas1> /var/packages/debian-chroot/scripts/start-stop-status chroot
      bash: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8)
      root@Nas1:/# aptitude update
      bash: aptitude: command not found

      How do I install ‘aptitude’?

      • Hey David,

        the “locale” output is just a warning, you can ignore it by now.
        To install aptitude just type apt-get install aptitude.
        Or replace every aptitude command with apt-get, it does the same, but aptitude has some more advantages that are not needed to install pyload.

        Best regards,
        André

        • David says:

          Hi André,

          Thank you very much for your help! I had to fix some other issues but now I have Pyload correctly installed in my ds215j.

          Best regards,
          David

Leave a Reply

Your email address will not be published. Required fields are marked *