Development release

Note

If you are not sure, you probably want to install the stable release. Follow this guide.

You can get the development release cloning the sources.

Warning

Don’t do this if you install a packaged release.

git clone https://github.com/UPC/ravada.git

Possible development scenarios where to deploy

Obviously if you can deploy on a physical machine will be better but it is not always possible. In that case you can test on a nested KVM, that is, a KVM inside another KVM.

Note

KVM requires VT-X / AMD-V.

sudo apt install cpu-checker
sudo kvm-ok

Warning

Do not consider VirtualBox in this situation, because it doesn’t pass VT-X / AMD-V to the guest operating system.

Ubuntu required packages

Check this file at the line depends for a list of required packages. You must install it running:

Note

The libvirt-bin package was dropped since Ubuntu 18.10. The package was split into two parts: libvirt-daemon-system and libvirt-clients.

sudo apt-get install perl libmojolicious-perl mysql-common libauthen-passphrase-perl \
libdbd-mysql-perl libdbi-perl libdbix-connector-perl libipc-run3-perl libnet-ldap-perl \
libproc-pid-file-perl libsys-virt-perl libxml-libxml-perl libconfig-yaml-perl \
libmoose-perl libjson-xs-perl qemu-utils perlmagick libmoosex-types-netaddr-ip-perl \
libsys-statistics-linux-perl libio-interface-perl libiptables-chainmgr-perl libnet-dns-perl \
wget liblocale-maketext-lexicon-perl libmojolicious-plugin-i18n-perl libdbd-sqlite3-perl \
debconf adduser libdigest-sha-perl qemu-kvm libnet-ssh2-perl libfile-rsync-perl \
libdate-calc-perl libdatetime-perl libdatetime-format-dateparse-perl libnet-openssh-perl \
libpbkdf2-tiny-perl libdatetime-perl

Mysql Database

Ravada needs a MySQL database to store information.

MySQL server

Warning

MySql required minimum version 5.6

It is required a MySQL server, it can be installed in another host or in the same one as the ravada package.

Ubuntu based distros

sudo apt-get install mysql-server

Debian based distros

sudo apt-get install mariadb-server

RedHat and Fedora based distros

sudo dnf install mariadb mariadb-server
sudo systemctl enable --now mariadb.service
sudo systemctl start mariadb.service

After completion of mysql installation, run command:

sudo mysql_secure_installation

MySQL database and user

It is required a database for internal use. In this examples we call it ravada. We also need an user and a password to connect to the database. It is customary to call it rvd_user. In this stage the system wants you to set a password for the sql connection.

Warning

When installing MySQL you wont be asked for a password, you can set a password for the root user in MySQL via mysql_secure_installation or type your user’s password when it ask’s you for a password.

Create the database:

sudo mysqladmin -u root -p create ravada

Grant all permissions on this database to the rvd_user:

sudo mysql -u root -p ravada -e "create user 'rvd_user'@'localhost' identified by 'Pword12345*'"
sudo mysql -u root -p ravada -e "grant all on ravada.* to rvd_user@'localhost'"

The password chosen must fulfill the following characteristics:

  • At least 8 characters.

  • At least 1 number.

  • At least 1 special character.

Config file

Create a config file at /etc/ravada.conf with the username and password you just declared at the previous step.

db:
  user: rvd_user
  password: *****

When developping Ravada, your username must be able to read the configuration file. Protect the config file from others and make it yours.

sudo chmod o-rx /etc/ravada.conf
sudo chown your_username /etc/ravada.conf

Ravada web user

Add a new user for the ravada web. Use rvd_back to create it.

cd ravada
sudo PERL5LIB=./lib ./script/rvd_back --add-user admin

Firewall(Optional)

The server must be able to send DHCP packets to its own virtual interface.

KVM should be using a virtual interface for the NAT domnains. Look what is the address range and add it to your iptables configuration.

First we try to find out what is the new internal network:

sudo route -n
...
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

So it is 192.168.122.0 , netmask 24. Add it to your iptables configuration:

-A INPUT -s 192.168.122.0/24 -p udp --dport 67:68 --sport 67:68 -j ACCEPT

Client

The client must have a spice viewer such as virt-viewer. There is a package for linux and it can also be downloaded for windows.

Daemons

Ravada has two daemons that must run on the server:

  • rvd_back : must run as root and manages the virtual machines

  • rvd_front : is the web frontend that sends requests to the backend

Run each one of these commands in a separate terminal

Run the backend in a terminal:

sudo PERL5LIB=./lib ./script/rvd_back --debug
Starting rvd_back v1.2.0

The backend must be stopped and started again when you change a library file. Stop it pressing CTRL-C

Run the frontend in another terminal:

PERL5LIB=./lib morbo -m development -v ./script/rvd_front
Server available at http://127.0.0.1:3000

Now you must be able to reach ravada at the location http://your.ip:3000/ or http://127.0.0.1:3000 if you run it in your own workstation.

The frontend will restart itself when it detects a change in the libraries. There is no need to stop it and start it again.

Start/Shutdown scripts

If you wish to create a script to automatize the start and shutdown of the ravada server, you can use these two bash scripts:

 1#!/bin/bash
 2#script to start ravada server
 3
 4display_usage()
 5{
 6	echo "./start_ravada"
 7	echo "./start_ravada 1 (messages not shown to terminal)"
 8}
 9
10if [ "$1" == "-h" ]
11then
12	display_usage
13	exit 1
14else
15	SHOW_MESSAGES=$1
16    export PERL5LIB="./lib"
17	if [ "$SHOW_MESSAGES" == "1" ]
18	then
19	   morbo -m development -v ./script/rvd_front > /dev/null 2>&1 &
20	   sudo PERL5LIB=./lib ./script/rvd_back --debug > /dev/null 2>&1 &
21	else
22	   morbo -m development -v ./script/rvd_front &
23       sudo PERL5LIB=./lib ./script/rvd_back --debug &
24	fi
25	echo "Server initialized succesfully."
26fi
27
 1#!/bin/bash
 2#script to shutdown the ravada server
 3
 4pid_front=$(pidof './script/rvd_front')
 5if [ -n "$pid_front" ];then
 6    echo "Shutting down rvd_front"
 7    sudo kill -15 $pid_front
 8else
 9    echo rvd_front already down
10fi
11
12pid_back=$(pidof -x './script/rvd_back')
13if [ -n "$pid_back" ];then
14    echo "Shutting down rvd_back"
15    sudo kill -15 $pid_back
16else
17    echo rvd_back already down
18fi