Skip to content
Snippets Groups Projects
0_setup.py 2.45 KiB
Newer Older
Stéphane Diemer's avatar
Stéphane Diemer committed
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
Stéphane Diemer's avatar
Stéphane Diemer committed
import utils


def setup(interactive=True):
    dir_path = utils.get_dir(__file__)
    wowza_setup_name = 'WowzaStreamingEngine-4.5.0-linux-x64-installer.deb'
    utils.log('It may take a while to download the Wowza installer from the UbiCast server.')
    if utils.exec_cmd('lsb_release -a | grep 14') == 0:
        jre_package = 'openjdk-7-jre-headless'  # 14.04
    else:
        jre_package = 'openjdk-8-jre-headless'  # 16.04
    cmds = [
        'apt-get install -y %s' % jre_package,
        # Get and install Wowza
        '[ -f "/tmp/%(name)s" ] || wget -q "https://www.ubicast.eu/media/downloads/packages/%(name)s" -O "/tmp/%(name)s"' % {'name': wowza_setup_name},
        'dpkg -i "/tmp/%s"' % wowza_setup_name,
        # Configure Wowza
        'echo "%s" > /usr/local/WowzaStreamingEngine/conf/Server.license' % utils.get_conf('WOWZA_LICENSE'),
        'echo "ubicast %s admin" > /usr/local/WowzaStreamingEngine/conf/admin.password' % utils.get_conf('WOWZA_MANAGER_PWD'),
Stéphane Diemer's avatar
Stéphane Diemer committed
        'update-rc.d WowzaStreamingEngine defaults',
        'update-rc.d WowzaStreamingEngineManager defaults',
        'chmod +x /usr/local/WowzaStreamingEngine/logs',
        'cp -R /usr/local/WowzaStreamingEngine/examples/LiveVideoStreaming/conf/live /usr/local/WowzaStreamingEngine/conf/',
        'mkdir -p /usr/local/WowzaStreamingEngine/applications/live',
        dict(line='write', template='%s/live-application.xml' % dir_path, target='/usr/local/WowzaStreamingEngine/conf/live/Application.xml', backup=True, params=(
            ('{{ live_pwd }}', utils.get_conf('WOWZA_LIVE_PWD')),
Stéphane Diemer's avatar
Stéphane Diemer committed
        )),
        'cp "%s/Tune.xml" /usr/local/WowzaStreamingEngine/conf/Tune.xml' % dir_path,
Stéphane Diemer's avatar
Stéphane Diemer committed
        '/etc/init.d/WowzaStreamingEngine restart',
        '/etc/init.d/WowzaStreamingEngineManager restart',
    ]
    if utils.get_conf('WOWZA_SERVER_NAME'):
Stéphane Diemer's avatar
Stéphane Diemer committed
        cmds.append('mkdir -p /var/www/streaming')
    if os.path.exists('/home/ftp/storage/www'):
        cmds.extend([
            '[ -d "/usr/local/WowzaStreamingEngine/content-back" ] || mv /usr/local/WowzaStreamingEngine/content /usr/local/WowzaStreamingEngine/content-back',
            'ln -sfn /home/ftp/storage/www /usr/local/WowzaStreamingEngine/content',
        ])
    utils.run_commands(cmds)
    utils.log('Edit /usr/local/WowzaStreamingEngine/conf/admin.password to change web manager access password.')
    utils.log('Edit /usr/local/WowzaStreamingEngine/conf/Server.license to change license key.')