#!/bin/bash # ############################################################################################## # # Project : Obtain HOTSPOT INFO # # Script : cgi to display player's information previously retrieved from CMS # # Author : Oriol, based in Fabien Script # Date : 2015-02-24 # Change Log : 2015-03-24 - First Version # Copyright (C) 2008 - 2014 Beabloo. All rights reserved. # ############################################################################################## # # # -------------------------------------------------------------------------------------------- # Variables # -------------------------------------------------------------------------------------------- SCRIPTS_DIR=/opt/beabloo/scripts # DETERMINE HOSTNAME . ${SCRIPTS_DIR}/getHostname.sh PROPERTIES=/opt/beabloo/data/conf/Global.properties # -------------------------------------------------------------------------------------------- # Functions # -------------------------------------------------------------------------------------------- initContentType(){ echo "Content-type: application/json" echo "" echo "" } getFileData(){ GLOBAL_FILE="${1}" local VALUE local VAR if [ -s ${GLOBAL_FILE} ] ; then for VAR in hotspotId hostname organizationId organizationName; do VALUE=`grep -i "^${VAR}=" ${GLOBAL_FILE} | cut -d "=" -f 2` eval "GLOBAL_${VAR/./_}=\"${VALUE}\"" done fi } printJSONINFO(){ JSON_INFO="{"; JSON_INFO+="\"hotspotId\": ${GLOBAL_hotspotId}"; JSON_INFO+=","; JSON_INFO+="\"hostname\": "; #if[ -z "${GLOBAL_hostname}"]; #then JSON_INFO+="\"${HOSTNAME}\"" #else # JSON_INFO+="\""+${GLOBAL_hostname}+"\"" #fi JSON_INFO+=","; JSON_INFO+="\"organizationId\": ${GLOBAL_organizationId}"; JSON_INFO+=","; JSON_INFO+="\"organizationName\": \"${GLOBAL_organizationName}\""; JSON_INFO+="}"; echo ${JSON_INFO}; } # -------------------------------------------------------------------------------------------- # Main # -------------------------------------------------------------------------------------------- # INIT HTML CONTENT TYPE initContentType # GET DATA FROM FILE getFileData ${PROPERTIES} # PRINT FORM printJSONINFO