To work, you will need SSH access to the root server. Installation will be made in console mode through terminal commands. If you need to execute a sudo command to obtain root privileges, you must execute a command before installing:
sudo su -
Installation of necessary packages and libraries
We establish dependencies with the help of apt:
apt update apt install git libtiff-dev libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev python-tk uwsgi build3 redis-server-essential wget pwgen libmariadb-dev nginx python-is-python3
Next, install the utility pip, it will be required to install the used python libraries:
apt install python3-pip && pip install --upgrade pip
Next, you need to download the smarty-lite, jsonrpctcp and ujson deb packages and install them:
dpkg -i smarty-lite*.deb wget http://dl.micro.im/packets/release/python3-jsonrpctcp/jsonrpctcp-0.2.0.tar.gz pip install jsonrpctcp-0.2.0.tar.gz wget http://dl.micro.im/packets/release/ujson/bullseye/ujson-2.0.4.dev0.tar.gz pip install ujson-2.0.4.dev0.tar.gz
Be careful – you need to use the Smarty Lite installation package specifically for the Debian Bullseye version, it is located in the bullseye directory. Otherwise, an error may occur when performing further commands undefined symbol: PyFPE_jbuf.
After installing the basic packages, you must install python libraries used in Smarty Lite. To do this, you need to:
pip install -r /usr/share/microimpuls/smarty-lite/requirements.txt
Installation of DBMS for Smarty Lite
Smarty Lite supports various databases, in the basic version it is recommended to use MySQL or MariaDB, for Debian Bullseye we install MariaDB:
apt install mariadb-server
Create a user to connect Smarty Lite in the database and specify the password in the Smarty Lite settings:
export DBPASSWORD='pwgen -s 16 1' 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 "PUT DB PASSWORD HERE" line with the automatically generated password in the file /etc/microimpuls/smarty-lite/smarty-lite.py - Smarty Lite settings file.
The Smarty Lite settings file defaults the connection settings to the locally installed MySQL-compatible DBMS (in this example, MariaDB), but you can install the DBMS on another machine if necessary.
Preparation of the configuration of the nginx Web server and the uWSGI application server
Prescribe a secret key for the operation of internal protection mechanisms Smarty Lite:
export SECRETKEY='pwgen -s 32 1' 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
Change the default plugin uwsgi on python on python3 (string) pluginsin /etc/uwsgi/apps-available/smarty-lite.ini
Create a directory for cache and logs nginx:
mkdir -p /var/cache/nginx/smarty-lite mkdir -p /var/log/nginx/microimpuls/smarty-lite
Configure storage of nginx cache in tmpfs:
echo tmpfs /var/cache/nginx/smarty-lite tmpfs defaults,size=1200M 0> /etc/fstab mount -a
We change the limit of open sockets for optimal work:
echo "net.core.somaxconn=64000" > > /etc/sysctl.conf sysctl -p
Install the correct directory rights for logs and file downloads in Smarty Lite:
chown -R www-data:www-data /var/log/microimpuls chown -R www-data:www-data /usr/share/microimpuls
Installation of the licence key
Next, you need to register the license key.
To obtain the license key, you need to use the HW key – the print of the machine on which the Smarty Lite is installed. To get it, you need to run uwsgi:
/etc/init.d/uwsgi restart
With each uwsgi restart, be sure to make sure that the old uwsgi processes are killed (you can see using the uwsgi process) ps aux | grep uwsgi and pay attention to processes with earlier start times and kill them with kill -9 where appropriate)
And then in the file /var/log/uwsgi/app/smarty-lite.log find the HW key 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:
9eb4a0c2b360c93e32cf2471780cda494705f0a9d026c69fe033d8c8
This value must be inserted into the appropriate field in the license generation window in the operator’s personal account, and then copy the resulting key with all license parameters that must be written into the configuration file /etc/microimpuls/smarty-lite/smarty-lite.py.
License generation is called by the button "Generate a new license key" in the corresponding product in the LC.
Copying the license and all parameters is done using the icon "Copy" in the line with the license key.
After adding the license configuration, you need to check that it is valid. To do this, restart uwsgi and check the logs for no license errors and no Traceback logs due to the lack of additional python libraries.
/etc/init.d/uwsgi restart
Remember to make sure old uwsgi processes are killed
Checking the logs:
tail -n 1000 /var/log/uwsgi/app/*.log | grep "*** Starting" -A 100
The last run log must not contain the "Key Incorrect" and "Traceback" errors
Installation of the OBD scheme
We will 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
Launch of services
Restart nginx and uwsgi with current settings:
/etc/init.d/nginx restart /etc/init.d/uwsgi restart
Remember to make sure old uwsgi processes are killed
System settings and configuration example
To quickly start using Smarty Lite, we have prepared a team that will set system settings and create examples of data – sets of TV channels, EPG, tariffs, streaming services and other objects necessary for the operation of the IPTV & OTT service. To do this, do:
python /usr/share/microimpuls/smarty-lite/manage.py setup_initial_data --settings=settings.smarty-lite
Then you can edit them and add your data.
Set up regular commands in crontab
For the correct operation of Smarty Lite and updating subscriber data, you need to configure the execution of commands on a schedule in crontab, for this at the end of the file /etc/crontab add the following lines:
*/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 team updates the cache of TV channels. The second command imports EPG (teleguide) 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
IPTV & OTT service in Smarty Lite is managed through the Web-control panel.
Next, create a user with superadministrator rights to access the control panel:
export ADMINPASSWORD='pwgen -s 16 1' 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 output the generated password - save it.
For the correct display of pictures / styles in Django-adminka, it is necessary to correct in the catalog
/etc/nginx/sites-enabled/smarty* packageway django current version python
For this, it is necessary to update the ways for the following: location:
location ^~ /admin/media/css/
alias /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/css/;
}
location ^~ /admin/media/img/
alias /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/;
}
location ^~ /admin/media/js/
alias /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/;
}
location ^~ /media/static/admin/css/
alias /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/css/;
}
location ^~ /media/static/admin/img/
alias /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/;
}
location ^~ /media/static/admin/js/
alias /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/;
}
For the prescribed python version 3.9.6 (check version) python team python --version) alias should indicate a new version 3.9 instead of 2.7.
Restart nginx to apply changes:
systemctl restart nginx
Затем открываем в браузере панель управления Smarty Lite http://X.X.X.X:8180 и авторизуемся созданным пользователем (в нашем примере это admin и пароль, сгенерированный выше):

Next, you need to install and configure the subscriber portal, connecting it with the Smarty Lite API. Through the portal, the subscriber gets access to IPTV & OTT services.
After installing the portal, do not forget to replace the location srv1 configuration in nginx with mw1 and then restart the nginx configuration:
/etc/init.d/nginx reload