Skip to content

Installation

Antonio S. Cofiño edited this page Jan 10, 2022 · 4 revisions

There are several ways to install the DRM4G.

With pip

The recommended way to install the ''DRM4G'' is by using the command pip install drm4g. To check if you have this tool installed just open a terminal and execute which pip. If you have it installed you'll see something like this:

$ which pip
/usr/bin/pip

Once you've made sure you have pip installed, just run one of the following commands:

  • With root access: You can go ahead and run sudo pip install drm4g
  • Without root access: Run pip install drm4g --user
  • In a [virtual environment]: Just run pip install drm4g

Bear in mind that you can also download the package from our pypi DRM4G and then indicate the it's path to the command.

Install in custom directory

Sometimes you will want to specify a certain directory in which to install ''DRM4G''. To do that you'll have to take into account a couple of details.

The installation command would have to be:

$ pip install drm4g --install-option="--prefix=/your/path" -v

or

$ pip install drm4g --install-option="--home=/your/path" -v

This will install your binary files and libraries under the specified path, but ''DRM4G'' will still not be able to run.

  • You want your system to be aware of where the ''DRM4G'' package is, so that python may be able to import it. You'll have to define the environment variable PYTHONPATH, which will have to point to the library folder under the path you chose. At the end of the installation, you'll see a message that will inform you on how to do that.

  • The next step is to have it know that ''DRM4G'' has been installed. You'll have to make sure that the directory you choose is added in your environment variable PATH or you could have it added to your sys.path. The folder we are interested in is the "''bin''" folder inside your directory.

During the installation, you will be prompted with a question about modifying your $HOME/.profile or $HOME/.bashrc file. If you accept, you will only have to define these two environment variables the first time.

  • Alternatively you can access the file yourself, which is under the home directory, and make the necessary changes.

Without pip

First and foremost you would have to make sure you have installed the necessary requirements. Those are Paramiko and docopt.

For Ubuntu or Debian:

sudo apt-get install python-paramiko
sudo apt-get install python-docopt

For Centos or !RedHat:

sudo yum install python-paramiko
sudo yum install python-docopt

Once that has been taken care of, you can download the source code from here.

After you extract the package, in a terminal, head into the folder and run:

  • With root access: sudo python setup.py install
  • Without root access: python setup.py install --user
  • In a [Virtual environment]: python setup.py install

Bear in mind that you can extract the package in some other directory and then indicate the setup.py's path to the command.

Install in custom directory

If you want to use a specific directory as the installation path, you can do it like this:

python setup.py install --prefix=/your/path

or

python setup.py install --home=/your/path

There are other considerations to have in mind, but they are the same as the ones explained [#customInstall above].

Verifying the installation

To check if the DRM4G has been successfully installed you can run the following commands:

  • which drm4g
    • If it returns something, it means it has been installed
    • If the program doesn't exist, it won't show anything
  • drm4g start
    • If there aren't any errors, it will show a message like this:
$ drm4g start
Starting DRM4G .... 
  OK

Optional Environment Variables

DRM4G uses the following environment variables:

  • DRM4G_DIR: By default your configuration files will be located in $HOME/.drm4g/. If you wish to define where your configuration and log files will be created, before starting ''DRM4G'' with drm4g start you should set the environment variable DRM4G_DIR with whichever directory you wish to use, .drm4g will be automatically created under it.

  • EDITOR: Select an editor to configure the resource configuration file. The nano editor will be used by default.

By default your configuration files will be located in $HOME/.drm4g/. If you wish to define where your configuration and log files will be created, before starting the ''DRM4G'' with drm4g start you should set the environment variable DRM4G_DIR with whichever directory you wish to use, .drm4g will be automatically created under it.)

Installing Extras

Inside the ''DRM4G'' distribution package, there is a directory called "extras" that will contain scripts that can improve your experience using ''DRM4G''. For the moment, there is only one:

  • drm4g_autocomplete.sh bash script adds tab-completion features to drm4g.

Enabling

To enable the ''DRM4G'' command completion without installing it:

source /path/to/extras/drm4g_autocomplete.sh

After you do that, tab-completion will immediately be available in your current Bash shell, but it won't be available next time you log in.

Installing

To install drm4g_autocomplete.sh, add the the line bellow in your $HOME/.bashrc or $HOME/.profile file :

source /path/to/extras/drm4g_autocomplete.sh

Thus tab-completion will take effect the next time you log in.

Updating the DRM4G

Whenever a new version is released, you'll want to install it. To do so the best way is to simply run one of the following:

With pip

pip install --upgrade drm4g

Without pip

python setup.py update

Your configuration files (resources.conf, logger.conf, etc) won't be overwritten but some of the configuration keys in resources.conf for example might have changed so you'll have to check the resource configuration page.