Book Image

Beaglebone Media Center

By : David Lewin
Book Image

Beaglebone Media Center

By: David Lewin

Overview of this book

Table of Contents (15 chapters)
BeagleBone Media Center
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Ideas to Improve Your Server
Index

MediaDrop installation steps


The following sections will take you through the installation of Mediadrop.

BBB Debian – prerequisites

Now that your system is ready to accept all the applications you want to install, let's begin with the MySQL part:

debian@beaglebone:~$ install mysql-server mysql-client

Note

Actually, sudo apt-get install works behind the scenes. From this point onwards, we'll rely on aliases to ease our life from the command line. Refer to the Appendix to get all the details.

During this you'll be asked for the database's root password, then the remaining system files:

debian@beaglebone:~$ install libjpeg-dev zlib1g-dev libfreetype6-dev libmysqlclient-dev python-dev

Finally, the Python-related requirements that will help you in virtual environments can be installed using the following command:

debian@beaglebone:~$ install python-setuptools python-virtualenv

With system requirements in place, you can set up MediaDrop in just six installation steps. Before doing that, you need to define a database for it.

Setting up a dedicated database

You need to create some credentials and assign a user to a new MediaDrop database. It requires you to type only a few commands. If this is something that you don't want to do, the script is available on the GitHub companion website at https://github.com/dlewin/BeagleboneBlack-Server-Book.

Just execute the following command:

./create_mediadropdb.sh

Instead, if you are like me and want to control your entire system, then open a MySQL console, and pay attention to the syntax of the following command (with the ;):

debian@beaglebone:~$ mysql –u root –p

Then, fill in the password you have defined in the installation steps.

You will now have access to the MySQL console for all the database operations that MediaDrop requires. Now, perform the following steps:

  1. Create your user with a password:

    create user 'debian'@'localhost'IDENTIFIED BY 'temppwd';
    
  2. Create the MediaDrop database; pay attention to the use of capital letters:

    create database MediaDrop;
    
  3. Now, we tell that we want to work on this database:

    use MediaDrop;
    
  4. Set some rights on this database for the debian user:

    grant create,insert,update,select,delete on MediaDrop.* to debian@localhost;
    
    exit
    

Here's a screenshot that shows these operations along with the related MySQL feedback you should get:

Step 1 – set up a Python virtual environment

MediaDrop has been programmed in Python, a simple but powerful language that we'll also use in Chapter 6, Illuminate Your Imagination with Your Own Projects. As plugins are also in Python, you are free to extend the platform as you wish.

Let's see how to define a dedicated environment for this purpose.

Virtual environments introduce a functionality provided with Python that I like to use: actually, with this functionality, you can resolve the problems of software versions and incompatibility. The principle is to use as many virtual spaces with different packages or executables as you want without any confusion that might create a broken system. Thanks to the isolation provided by this tool, you are guaranteed that it is kept as you want it to be and thus you always have a safe system.

Note

If you want to know more about virtualenv, take a look at https://virtualenv.readthedocs.org/en/latest/. There is also a virtualenvwrapper that is intended to ease the creation and deletion of many virtual environments at https://virtualenvwrapper.readthedocs.org/en/latest/.

Currently, we are using the 0.10.3 version of MediaDrop, but nothing stops you from trying the next version in order to test any side effects on your architecture. Thus, instead of executing the current environment, you'll just have to start MediaDrop from the n+1 environment.

Virtual environment is presented just here, but you should create an environment each time you need different usages of an application or dependencies. It requires just less than a minute and can be done by performing the following steps:

  1. Create the environment with a specific name; in our case, venv:

    debian@beaglebone:~$ virtualenv --distribute venv
    
  2. Enter the dedicated virtual environment:

    debian@beaglebone:~$ source venv/bin/activate
    

That's all! You are in now. Cool, eh?

The command prompt is preceded by the virtual environment's name, so you can guess which environment is currently activated, which is shown in the screenshot that follows the code:

(venv)debian@beaglebone:~$

You can now install any package you want; it will only be accessible in the currently activated environment.

Step 2 – installing MediaDrop

For installation, retrieve the last stable release from downloads:

(venv)debian@beaglebone:~$ mkdir MediaDrop
(venv)debian@beaglebone:~$ cd MediaDrop
(venv)debian@beaglebone:~/MediaDrop$ wget http://static.mediadrop.net/releases/MediaCore-0.10.3.tar.gz

Note

You can find all the releases at http://static.mediadrop.net/releases/.

Then, perform the following steps:

  1. Extract the archive:

    (venv)debian@beaglebone:~/MediaDrop$ tar xvzf MediaCore-0.10.3.tar.gz
    
  2. Enter the new directory to launch the installation script:

    (venv)debian@beaglebone:~/MediaDrop$ cd MediaCore-0.10.3
    
    (venv)debian@beaglebone:~/MediaDrop/MediaCore-0.10.3$ python setup.py develop
    
  3. This will take a few minutes, as it checks and downloads the required dependencies, and will end with the following lines:

    Finished processing dependencies for MediaCore==0.10.3
    
    (venv)debian@beaglebone:~/MediaDrop/MediaCore-0.10.3$ cd ..
    
    (venv)debian@beaglebone:~/MediaDrop$
    
  4. From here, the recommended installation is to enter the following:

    (venv)debian@beaglebone:~/MediaDrop$ paster make-config MediaCore production.ini
    

This will generate the production.ini file, which the server will use as a configuration file. So, we can adapt by editing it.

Step 3 – basic configuration file

What we want to do here is tell which database we created and the related credentials. So, edit the production.ini file, with nano (or vim) in order to focus on the [app:main] section, as we want to change the following line:

sqlalchemy.url = mysql://username:pass@localhost/dbname?charset=utf8&use_unicode=0

The settings are shown in the following screenshot:

At the same time, as port 8080 is already used, let's change this to an available port, something such as 8082. As you'll see later on, many servers use the 8080 port for their configuration settings, and obviously only one application will be able to use this port, which means that according to your configurations, you will have to decide which application will use the 8080 port.

Note

Additionally, you can eventually customize your configuration file with an e-mail that will let you receive notifications from the server. You will then need to install a local SMTP server and apply the settings in this production.ini file at the [DEFAULT] section.

Now, save and quit the editor. We are done with the configuration part.

Step 4 – copying content from the initial data

We have completed all the configuration steps, and we are now going to deploy all the website data content.

To do this, copy the data directory from the sources to be at the same level as your production.ini file:

(venv)debian@beaglebone:~/MediaDrop$ cp -a MediaCore-0.10.3/data/.

Give it the write permissions for the debian user; when some content is uploaded, it will be written here:

(venv)debian@beaglebone:~/MediaDrop$ chmod 666 data

Step 5 – filling the server database and contents

It's now time to fill the MediaDrop database we've created previously with some tables and required data. We just have to call a predefined command:

(venv)debian@beaglebone:~/MediaDrop$ paster setup-app deployment.ini

Step 6 (optional) – full-text searching

Create some triggers that will allow you to have better searches than exact matches, as follows:

(venv)debian@beaglebone:~/MediaDrop$ mysql -u root -proot MediaDrop < MediaCore-0.10.3/setup_triggers.sql

Nothing else is remaining; we are in. Time to start our first server!