Including JSON generation feature.

Merge branch 'json_generation' into development
This commit is contained in:
Matthias Strubel 2014-06-27 16:32:40 +02:00
commit b6dabf9643
6 changed files with 78 additions and 1 deletions

View file

@ -0,0 +1,46 @@
#!/bin/sh
# Matthias Strubel (c) 2013 - GPL3
# Generate a JSON file, which relfects some part of the current configuration
# First parameter is the piratebox.conf
### Used parameter : JSON_FILE
. $1
# json.conf contains some information about modules on the frontend
. $PIRATEBOX_FOLDER/conf/json.conf
### JSON convert functions
. $PIRATEBOX_FOLDER/lib/json_func.sh
JSON_FILE=$PBX_JSON_FILE
####
# DROOPY_ENABLED => upload_droopy
# DROOPY_PORT => droopy_port
# HOST => droopy_host
json_droopy_enabled=`convert_yn_to_tf $DROOPY_ENABLED`
json_shoutbox_enabled=`convert_yn_to_tf $SHOUTBOX_ENABLED`
echo "Generating json configuration file: $JSON_FILE"
echo "" > $PBX_JSON_FILE
echo "{ \"piratebox\" : { \"module\" : { " >> $JSON_FILE
#------------ upload configuration
echo -n " \"upload\" : { \"status\" : $json_droopy_enabled , \"file\" : \"$UPLOAD_MODULE_FILE\" " >> $JSON_FILE
#----------- droopy specialities
if [ "$DROOPY_ENABLED" == "yes" ] ; then
echo -n ", " >> $JSON_FILE
echo -n " \"upload_style\" : \"droopy\" , " >> $JSON_FILE
echo -n " \"droopy_port\" : \"$DROOPY_PORT\", \"droopy_host\" : \"$HOST\" " >> $JSON_FILE
fi
echo " } " >> $JSON_FILE
#--------------- Shoutbox config file
echo ", \"shoutbox\" : { \"status\" : $json_shoutbox_enabled , \"file\" : \"$CHAT_MODULE_FILE\" } " >> $JSON_FILE
#---------------
echo ", \"version\" : \""$(cat $PIRATEBOX_FOLDER/version )"\" >> $JSON_FILE
echo " } } }" >> $JSON_FILE

View file

@ -0,0 +1,9 @@
#!/bin/sh
###
# This file contains some valid informations for the content
##
CHAT_MODULE_FILE="modules/chat.html"
UPLOAD_MODULE_FILE="modules/upload.html"

View file

@ -147,6 +147,10 @@ RESET_CHAT="yes"
#Provide files needed for PirateBox custom dirlisting
CUSTOM_DIRLIST_COPY="yes"
#Generate config json for frontend
PBX_JSON_GENERATION="yes"
PBX_JSON_FILE="$WWW_FOLDER/piratebox_config.json"
#Activate Global chat
# Still experimentall!
GLOBAL_CHAT="no"

View file

@ -91,6 +91,10 @@ case "$1" in
$PIRATEBOX/bin/distribute_files.sh $SHARE_FOLDER/Shared
fi
if [ "$PBX_JSON_GENERATION" = "yes" ]; then
$PIRATEBOX_FOLDER/bin/json_generation.sh $CONF
fi
if [ "$DO_IW" = "yes" ] ; then
log_daemon_msg " Setting up Interface (iw) "
iw $PHY_IF interface add $INTERFACE type managed

View file

@ -84,7 +84,9 @@ case "$1" in
$PIRATEBOX/bin/distribute_files.sh $SHARE_FOLDER/Shared
fi
if [ "$PBX_JSON_GENERATION" = "yes" ]; then
$PIRATEBOX_FOLDER/bin/json_generation.sh $CONF
fi
if [ "$DO_IW" = "yes" ] ; then
log_daemon_msg " Setting up Interface (iw) "

View file

@ -0,0 +1,12 @@
#!/bin/sh
# Matthias Strubel (c) 2013 - GPL3
convert_yn_to_tf(){
local value=$1 ; shift
if [ "$value" == "yes" ] ; then
echo "true"
else
echo "false"
fi
}