Skip to content

Commit fbb9205

Browse files
committed
Merge branch 'json_generation' into development
2 parents 7a04488 + 233e3ba commit fbb9205

File tree

5 files changed

+70
-0
lines changed

5 files changed

+70
-0
lines changed

customization/bin/hooks/hook_piratebox_start_done.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ if [ "$SHOUTBOX_ENABLED" == "no" ] ; then
5151
echo "done"
5252
fi
5353

54+
$PIRATEBOX_FOLDER/bin/json_generation.sh $1
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/sh
2+
3+
# Matthias Strubel (c) 2013 - GPL3
4+
# Generate a JSON file, which relfects some part of the current configuration
5+
6+
# First parameter is the piratebox.conf
7+
### Used parameter : JSON_FILE
8+
9+
. $1
10+
11+
# json.conf contains some information about modules on the frontend
12+
. $PIRATEBOX_FOLDER/conf/json.conf
13+
14+
### JSON convert functions
15+
. $PIRATEBOX_FOLDER/lib/json_func.sh
16+
17+
18+
####
19+
# DROOPY_ENABLED => upload_droopy
20+
# DROOPY_PORT => droopy_port
21+
# HOST => droopy_host
22+
23+
json_droopy_enabled=`convert_yn_to_tf $DROOPY_ENABLED`
24+
json_shoutbox_enabled=`convert_yn_to_tf $SHOUTBOX_ENABLED`
25+
26+
echo "Generating json configuration file: $JSON_FILE"
27+
28+
echo "" > $JSON_FILE
29+
echo "{ \"librarybox\" : { \"module\" : { " >> $JSON_FILE
30+
#------------ upload configuration
31+
echo -n " \"upload\" : { \"status\" : $json_droopy_enabled , \"file\" : \"$UPLOAD_MODULE_FILE\" " >> $JSON_FILE
32+
#----------- droopy specialities
33+
if [ "$DROOPY_ENABLED" == "yes" ] ; then
34+
echo -n ", " >> $JSON_FILE
35+
echo -n " \"upload_style\" : \"droopy\" , " >> $JSON_FILE
36+
echo -n " \"droopy_port\" : \"$DROOPY_PORT\", \"droopy_host\" : \"$HOST\" " >> $JSON_FILE
37+
fi
38+
echo " } " >> $JSON_FILE
39+
40+
#--------------- Shoutbox config file
41+
echo ", \"shoutbox\" : { \"status\" : $json_shoutbox_enabled , \"file\" : \"$CHAT_MODULE_FILE\" } " >> $JSON_FILE
42+
43+
#---------------
44+
echo " } } " >> $JSON_FILE

customization/conf/hook_custom.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ PROFTPD_PID="$PIRATEBOX_FOLDER/tmp/proftpd.pid"
1515

1616
### Shoutbox
1717
SHOUTBOX_ENABLED="yes"
18+
19+
### JSON Configuration file for frontend
20+
JSON_FILE="$WWW_FOLDER/config.json"

customization/conf/json.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
###
3+
# This file contains some valid informations for the content
4+
##
5+
6+
7+
CHAT_MODULE_FILE="modules/chat.html"
8+
UPLOAD_MODULE_FILE="modules/upload.html"
9+
10+

customization/lib/json_func.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
# Matthias Strubel (c) 2013 - GPL3
4+
5+
convert_yn_to_tf(){
6+
local value=$1 ; shift
7+
if [ "$value" == "yes" ] ; then
8+
echo "true"
9+
else
10+
echo "false"
11+
fi
12+
}

0 commit comments

Comments
 (0)