#!/usr/bin/python3 # -*- coding: utf-8 -*- import os 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.check_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'), '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')), )), 'cp "%s/Tune.xml" /usr/local/WowzaStreamingEngine/conf/Tune.xml' % dir_path, '/etc/init.d/WowzaStreamingEngine restart', '/etc/init.d/WowzaStreamingEngineManager restart', ] ms_conf = '/etc/mediaserver/lives_conf.py' if os.path.exists(ms_conf): utils.log('The file "%s" already exists, it will not be changed.' % ms_conf) else: cmds.extend([ 'mkdir -p /etc/mediaserver', 'echo "RTMP_PWD = \'%s\'" > %s' % (utils.get_conf('WOWZA_LIVE_PWD'), ms_conf), ]) if utils.get_conf('WOWZA_SERVER_NAME'): 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.')