• Quick Start
  • Booting
  • Platform
  • Portals
  • References
    • API Reference TOI3
    • IIP Reference
  • Resources
ARRIS Enterprises, Inc. Confidential Information

Example Apache2 configurations

This section contains an python CGI-BIN example script illustrating how to utilize the HTTP request parameters. It is for instance possible to send out certain boot images to STBs with certain serial numbers or MAC addresses. This can be quite handy if friendly test users should receive a different software image.

Simple internal redirect using mod_rewrite

Make sure that AllowOverride All is set in the Apache configuration file and restart the server.

Create the following .htaccess file in your WWW root directory.


RewriteEngine on
RewriteRule   ^arris-vip(.*)$ cgi-bin/stbconfig [L]

Simple external redirect using mod_rewrite

Make sure that AllowOverride All is set in the Apache configuration file and restart the server.

Create the following .htaccess file in your WWW root directory.


Rewrit  Engine on
RewriteRule   ^arris-vip4302wbt-dev$ http://www.example2.com/cgi-bin/stbconfig [R]

Example CGI script

Create the following file, stbconfig, in your cgi-bin directory, remember to make the file executable.


#!/usr/bin/python
#
# Copyright (c) 2016 ARRIS Enterprises, Inc. All rights reserved.
# Copyright (c) 2016 ARRIS Enterprises, LLC. All rights reserved.
#
# This program is confidential and proprietary to ARRIS Enterprises, LLC.
# (ARRIS), and may not be copied, reproduced, modified, disclosed to others,
# published or used, in whole or in part, without the express prior written
# permission of ARRIS.

# This is an example CGI-BIN script for hosting boot images for HTTP boot. See
# the documentation page booting/methods/http_boot.html for more information

import os
import traceback

def generate_stbconfig(server, image, splash):
  out = """<?xml version="1.0"?>
<!DOCTYPE StbConfig SYSTEM "stbconfig.dtd">
<StbConfig>
<BootParams>
  <KernelUrl>%s/%s</KernelUrl>
  <KernelVersion>1.0</KernelVersion>
  <SplashUrl>%s/%s</SplashUrl>
  <SplashVersion>1.0</SplashVersion>
</BootParams>
<PermanentParams>
  <StatusScreenColor>0,0,0</StatusScreenColor>
</PermanentParams>
</StbConfig>
"""
  return out % (server, image, server, splash)

def parse_qs(qs):
  d = {}
  for item in qs.split('&'):
      name, value = item.split('=')
      if name in d:
          d[name].append(value)
      else:
          d[name] = [value]
  return d

serial_db = {'1931690851': 'kreatv-bi-special_4302.bin'}
product_db = {'arris-vip4302wbt-dev': ('kreatv-bi-default_4302.bin',
                                     'splash-4302.bmp')}
output = ''
try:
  http_server = 'http://%s' % os.getenv('SERVER_ADDR')
  parameters = parse_qs(os.getenv('QUERY_STRING'))

  default_bi, splash = product_db[parameters['product'][0]]
  image = serial_db.get(parameters['serial'][0],
                        default_bi)
  output += generate_stbconfig(http_server,
                               image,
                               splash)
  output = 'Content-type: text/xml\n\n' + output
except Exception, e:
  output = 'Status: 500 Internal Server Error\n'
  output += 'Content-type: text/html\n\n'
  output += '<html><body>HTTP/1.1 500 Internal Server Error\n'
  output += '<br>%s</body></html>' % traceback.format_exc()

print output

5.1.1.p8

Copyright (c) 2018 ARRIS Enterprises, LLC. All Rights Reserved. ARRIS Enterprises, LLC. Confidential Information.