Below are the instructions for installing Smarty Lite on a server with Debian Buster OS. For information about setting up certain functions or services of the Smarty Middleware platform, which you will not find here, you should look for on the help page of the full Smarty version: link
You will need SSH access to the server with root privileges. Installation will be done in console mode via terminal commands. If you need to run the sudo command to gain root privileges, you must run the following command before starting the installation:
Installing required packages and libraries
Set dependencies using apt:
apt update apt install git python-dev libtiff-dev libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev python-tk uwsgi uwsgi-plugin-python redis-server build-essential wget pwgen libmariadb-dev nginx
Next, install the pip utility, it will be required to install the python libraries:
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py && python get-pip.py && rm get-pip.py
Next, you need to download the smarty-lite and python2.7-jsonrpctcp installation deb packages and install them:
dpkg -i smarty-lite*.deb dpkg -i python2.7-jsonrpctcp_*.deb
Be careful — you need to use the Smarty Lite installation package specifically for the Debian Buster version, it is located in the buster directory. Otherwise, when executing further commands, an undefined symbol: PyFPE_jbuf error may occur.
When an error occurs
dpkg: warning: 'ldconfig' not found in PATH or not executable dpkg: warning: 'start-stop-daemon' not found in PATH or not executable
run the following command:
After that, try to install the packages again.
After installing the main packages, you need to install the python libraries used in Smarty. To do this, you first need to run (only for Debian Buster):
cp /usr/share/microimpuls/smarty-lite/requirements.txt ./temp.txt && cat ./temp.txt | grep -vE '^[Mm]y[Ss][Qq][Ll]-python==.*' > /usr/share/microimpuls/smarty-lite/requirements.txt && rm ./temp.txt pip install mysql-connector pip install mysql-connector-python pip install mysqlclient
Then install python libraries:
pip install -r /usr/share/microimpuls/smarty-lite/requirements.txt
Installing a DBMS for Smarty Lite
Smarty Lite supports various DBMS, in the basic version it is recommended to use MySQL or MariaDB, for Debian Buster install MariaDB::
apt install mariadb-server
Create a user to connect Smarty Lite to the database and specify the password in Smarty Lite settings:
export DBPASSWORD=`pwgen -s 16` echo "CREATE DATABASE smarty CHARACTER SET = utf8;" | mysql -u root echo "SET default_storage_engine=InnoDB;" | mysql -u root echo "CREATE USER 'smarty'@'%' IDENTIFIED BY '$DBPASSWORD';" | mysql -u root echo "GRANT ALL PRIVILEGES ON smarty.* TO 'smarty'@'%';" | mysql -u root echo "FLUSH PRIVILEGES;" | mysql -u root sed -i -e 's/PUT DB PASSWORD HERE/'"$DBPASSWORD"'/g' /etc/microimpuls/smarty-lite/smarty-lite.py
The last command replaces the line «PUT DB PASSWORD HERE» with the automatically generated password in the file
/etc/microimpuls/smarty-lite/smarty-lite.py — Smarty Lite configuration file.
The Smarty Lite configuration file defaults to connecting to a locally installed MySQL database (or compatible MariaDB), but you can install the database on another machine if necessary.
Preparing the nginx Web Server and uWSGI Application Server Configuration
Register the secret key for the operation of the internal security mechanisms of Smarty Lite:
export SECRETKEY=`pwgen -s 32` sed -i -e 's/PUT RANDOM SECRET KEY HERE/'"$SECRETKEY"'/g' /etc/microimpuls/smarty-lite/smarty-lite.py
Activate the Smarty Lite configuration for nginx and uwsgi:
ln -s /etc/nginx/sites-available/smarty-lite /etc/nginx/sites-enabled/smarty-lite ln -s /etc/uwsgi/apps-available/smarty-lite.ini /etc/uwsgi/apps-enabled/smarty-lite.ini
Create a directory for nginx cache and logs:
mkdir /var/cache/nginx mkdir -p /var/log/nginx/microimpuls/smarty-lite
Change the limit of open sockets for optimal uwsgi work:
echo "net.core.somaxconn=4096" >> /etc/sysctl.conf sysctl -p
Set the correct permissions for the directories for logs and file uploads in Smarty:
chown -R www-data:www-data /var/log/microimpuls chown -R www-data:www-data /usr/share/microimpuls
License Key Installation
Next, you need to register a license key.
To obtain a license key, you need to use the HW key — the fingerprint of the machine on which Smarty Lite is installed. To get it, you need to run uwsgi:
And then in the file
/var/log/uwsgi/app/smarty-lite.log find the HW key value, or use the command:
cat /var/log/uwsgi/app/smarty-lite.log | grep "Exception: Key incorrect, HW key"
For example, the resulting HW key will be as follows:
This value must be inserted into the corresponding field in the license generation window in the operator’s personal account, and then copy the resulting key with all the license parameters that need to be registered in the configuration file
License generation is done by clicking the «Generate a new license key» button in the corresponding product in the PA.
The license and all parameters are copied using the «Copy» icon in the line with the license key.
Setting the database schema
Install the Smarty Lite database schema using the built-in data migration mechanism:
python /usr/share/microimpuls/smarty-lite/manage.py migrate --settings=settings.smarty-lite
Let’s restart nginx and uwsgi with the current settings:
/etc/init.d/nginx restart /etc/init.d/uwsgi restart
Setting system settings and example configuration
To quickly start using Smarty Lite, we have prepared a command that will set the system settings and create sample data — TV channel sets, EPG, tariffs, streaming services and other objects necessary for the operation of the IPTV & OTT service. To do this, run:
python /usr/share/microimpuls/smarty-lite/manage.py setup_initial_data --settings=settings.smarty-lite
Then you will be able to edit them and add your details.
Configuring Regular Commands in Crontab
For Smarty Lite to work correctly and update subscriber data, you need to configure crontab to execute commands on a schedule, for this, add the following lines at the end of the
*/1 * * * * root python /usr/share/microimpuls/smarty-lite/manage.py cache_channel_list --settings=settings.smarty-lite 0 5,9,13 * * * root python /usr/share/microimpuls/smarty-lite/manage.py epg_import --settings=settings.smarty-lite 0 3 * * * root python /usr/share/microimpuls/smarty-lite/manage.py clean_old_messages --days_count 3 --settings=settings.smarty-lite
The first command updates the TV channel cache. The second command imports the EPG (TV guide) every day 3 times — at 5:00, 9:00 and 13:00 server time. The third command clears old undelivered text messages and commands (with a creation date older than three days).
Creating a User and Getting Started
Management of the IPTV & OTT service in Smarty Lite is carried out through the Web control panel.
Create a user with super-administrator rights to access the control panel:
export ADMINPASSWORD=`pwgen -s 16` python /usr/share/microimpuls/smarty-lite/manage.py create_user --settings=settings.smarty-lite --reset_password=False --username=admin --password=`echo $ADMINPASSWORD` --is_admin=True --client_id=1 --is_superuser=True echo $ADMINPASSWORD
The last command will display the generated password — save it.
Then open the Smarty Lite control panel http://X.X.X.X:8180 in the browser and log in with the created user (in our example, this is admin and the password generated above):
Next, you need to install and configure the subscriber portal by connecting it to the Smarty Lite API. Through the portal, the subscriber gains access to IPTV & OTT services.