def writeHostAPDConfFile(campaign, restartServer=True):
        global DeviceClientInstance
        clientConfig = DeviceClientInstance.clientConfig

        if campaign != None:
            wifiCampaign = campaign.wifiCampaign
        else:
            wifiCampaign = None

        if wifiCampaign == None:
            networkName = ClientURISettings.MESSAGE_DEFAULT_WIFI
        else:
            networkName = wifiCampaign.networkName

        accessPointInterface = SystemWriter.getCurrentAccessPointInterface()

        data = hostapd.CONTENT.replace("PROXIMUSCHANNELHERE",
                                       clientConfig.channel).replace(
                                           "PROXIMUSNETWORKNAMEHERE",
                                           networkName).replace(
                                               "PROXIMUSACCESSPOINTHERE",
                                               accessPointInterface)

        if (Platform.getPlatform() == Platform.PLATFORM_LINUX_DDWRT):
            logger.info("writing hostapd.conf file %s" %
                        ClientURISettings.HOSTAPD_CONF_FILE_DDWRT)
            SystemWriter.writeFile(ClientURISettings.HOSTAPD_CONF_FILE_DDWRT,
                                   data)
        else:
            logger.info("writing hostapd.conf file %s" %
                        ClientURISettings.HOSTAPD_CONF_FILE)
            SystemWriter.writeFile(ClientURISettings.HOSTAPD_CONF_FILE, data)
        if (restartServer):
            ProcessExecutor.restartLighttpd(
            )  # on bluegiga this script restarts the hostapd daemon too
 def writeHostAPDConfFile(campaign, restartServer=True):
     global DeviceClientInstance
     clientConfig = DeviceClientInstance.clientConfig
     
     if campaign != None:
         wifiCampaign = campaign.wifiCampaign
     else:
         wifiCampaign = None
     
     if wifiCampaign == None:
         networkName = ClientURISettings.MESSAGE_DEFAULT_WIFI
     else:
         networkName = wifiCampaign.networkName
         
     accessPointInterface = SystemWriter.getCurrentAccessPointInterface()
     
     data = hostapd.CONTENT.replace("PROXIMUSCHANNELHERE", clientConfig.channel
                                    ).replace("PROXIMUSNETWORKNAMEHERE", networkName
                                    ).replace("PROXIMUSACCESSPOINTHERE", accessPointInterface)
     
     if (Platform.getPlatform() == Platform.PLATFORM_LINUX_DDWRT):
         logger.info("writing hostapd.conf file %s" % ClientURISettings.HOSTAPD_CONF_FILE_DDWRT)
         SystemWriter.writeFile(ClientURISettings.HOSTAPD_CONF_FILE_DDWRT, data)
     else:
         logger.info("writing hostapd.conf file %s" % ClientURISettings.HOSTAPD_CONF_FILE)
         SystemWriter.writeFile(ClientURISettings.HOSTAPD_CONF_FILE, data)
     if (restartServer):
         ProcessExecutor.restartLighttpd() # on bluegiga this script restarts the hostapd daemon too
    def makeLighttpdConfFile(campaign=None, restartServer=True):

        props = SystemWriter.readLogProperties()

        try:
            logger.info("writing lighttpd.conf file %s" %
                        ClientURISettings.LIGHTTPD_FILE)

            proxdata = ""
            phppath = "/usr/bin/php"
            if (campaign != None):
                campaign_id = campaign.id
                doc_root = ClientURISettings.CAMPAIGNS_ROOT_DIR + os.sep + campaign_id + "/WIFI/"
            else:
                doc_root = ClientURISettings.CAMPAIGNS_ROOT_DIR

            log_file = ClientURISettings.LOG_WORKING + os.sep + props[
                ClientURISettings.WIFI_TRANSFER_PROP]

            http_doc_root = """server.document-root = "%s"\n""" % doc_root

            proxdata += http_doc_root

            if Platform.getPlatform() == Platform.PLATFORM_LINUX_DREAMPLUG:
                # On non-bluegiga devices we have to insert the MAC address in a pipe logger
                proxdata += """accesslog.filename = "|/home/proximus/bin/accesslog_addmac.py"\n"""
                proxdata += """accesslog.format = "[%h] %t [%r] [%s] [%{User-Agent}i] [%V]"\n"""
                phppath = "/usr/bin/php-cgi"
            else:
                proxdata += """accesslog.filename = "%s"\n""" % log_file
                proxdata += """accesslog.format = "[%h] %t [%r] [%s] [%{User-Agent}i] [%V] [%M]"\n"""
                phppath = "/usr/bin/php"

            content = lighttpd.CONTENT.replace("PROXIMUS_HTTP_CONFIG_HERE",
                                               proxdata)
            # virtual dir setup coolspot.proximusmobility\.com
            virtualDir = """
$HTTP["host"] =~ "(^|\.)coolspot.proximusmobility\.com$" { 
  %s
}""" % http_doc_root
            content = content.replace("PROXIMUS_VIRTUAL_DIR", virtualDir)
            content = content.replace("PROXIMUS_PHP_PATH", phppath)
            SystemWriter.writeFile(ClientURISettings.LIGHTTPD_FILE, content)

            # Commented out, why is this here?  Do it separately
            #SystemWriter.writeCaptivePortalConf(campaign)

            if (restartServer):
                ProcessExecutor.restartLighttpd()

        except Exception as err:
            logger.error(err)
    def makeLighttpdConfFile(campaign=None, restartServer=True):
        
        props = SystemWriter.readLogProperties()
        
        try:
            logger.info("writing lighttpd.conf file %s" % ClientURISettings.LIGHTTPD_FILE)
            
            proxdata = ""
            phppath = "/usr/bin/php"
            if (campaign != None):
                campaign_id = campaign.id
                doc_root = ClientURISettings.CAMPAIGNS_ROOT_DIR + os.sep + campaign_id + "/WIFI/"
            else:
                doc_root = ClientURISettings.CAMPAIGNS_ROOT_DIR
                
            log_file = ClientURISettings.LOG_WORKING + os.sep + props[ClientURISettings.WIFI_TRANSFER_PROP]
            
            http_doc_root = """server.document-root = "%s"\n""" % doc_root
            
            proxdata += http_doc_root
            
            if Platform.getPlatform() == Platform.PLATFORM_LINUX_DREAMPLUG:
                # On non-bluegiga devices we have to insert the MAC address in a pipe logger
                proxdata += """accesslog.filename = "|/home/proximus/bin/accesslog_addmac.py"\n"""
                proxdata += """accesslog.format = "[%h] %t [%r] [%s] [%{User-Agent}i] [%V]"\n"""
                phppath = "/usr/bin/php-cgi"
            else:
                proxdata += """accesslog.filename = "%s"\n""" % log_file
                proxdata += """accesslog.format = "[%h] %t [%r] [%s] [%{User-Agent}i] [%V] [%M]"\n"""
                phppath = "/usr/bin/php"
            
            content = lighttpd.CONTENT.replace("PROXIMUS_HTTP_CONFIG_HERE", proxdata)
            # virtual dir setup coolspot.proximusmobility\.com
            virtualDir ="""
$HTTP["host"] =~ "(^|\.)coolspot.proximusmobility\.com$" { 
  %s
}""" % http_doc_root
            content = content.replace("PROXIMUS_VIRTUAL_DIR", virtualDir)
            content = content.replace("PROXIMUS_PHP_PATH", phppath)
            SystemWriter.writeFile(ClientURISettings.LIGHTTPD_FILE, content)
            
            # Commented out, why is this here?  Do it separately
            #SystemWriter.writeCaptivePortalConf(campaign)
            
            if (restartServer):
                ProcessExecutor.restartLighttpd()
        
        except Exception as err:
            logger.error(err)