Skip to content

Commit

Permalink
Merge branch 'hotfix-1.0.2' - Hotfix 1.0.2 release
Browse files Browse the repository at this point in the history
 * [Fix] Settings for correct permission of shoutbox files
 * [Fix] Broken probe function in some shells
 * [Fix] Issues with Python scripts on some plattforms
 * [Fix] Fixes in installation script
 * [Fix] Distribute files did not work with folder containing whitespaces
  • Loading branch information
MaStr committed Dec 26, 2014
2 parents 274b839 + a98d3d3 commit 6626cbc
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 107 deletions.
15 changes: 10 additions & 5 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ Script collection by:
Matthias Strubel http://piratebox.aod-rpg.de

Live CD & Installer by:
TerrorByte
TerrorByte ~ Cale Blac k

Contributors for modifications:
* General Support
# stylesuxx - Makefile and development support
# FriedZombie - OpenWRT and scripting support
* Droopy
# someguy - Droopy Directory support
# Reventlov - Modification for better iOS Support
* python Forum
# someguy - Modifications for running on OpenWRT
# ToM'aSs - Languag-Support
# Liblor - Fixes
# Liblor - Fixes
# Loris Reiff
# iamarf
# stylesuxx
# denis-d
# taffy-nay
# risca
# ... and all others I might have forgotten.


Design:
* David Brooks
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
CHANGELOG

=== 1.0.2 ===
* [Fix] Settings for correct permission of shoutbox files
* [Fix] Broken probe function in some shells
* [Fix] Issues with Python scripts on some plattforms
* [Fix] Fixes in installation script
* [Fix] Distribute files did not work with folder containing whitespaces

=== 1.0.1 ===
* [Fix] Fixed setting permissions of shoutbox datafile
* [New] Service File for RPi image
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME = piratebox-ws
VERSION = 1.0.1
VERSION = 1.0.2
ARCH = all
PB_FOLDER=piratebox
PB_SRC_FOLDER=$(PB_FOLDER)/$(PB_FOLDER)
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# PirateBoxScripts with Modifications for running in a Webserver
© 2013 [Matthias Strubel](mailto:matthias.strubel@aod-rpg.de) licenced under GPL-3
© 2012-2014 [Matthias Strubel](mailto:matthias.strubel@aod-rpg.de) licenced under GPL-3

## Maintainers
* [Matthias Strubel](matthias.strubel@aod-rpg.de)
* [Cale Black](cablack@rams.colostate.edu)

Sources for Running PirateBox with Webserver lighttpd
Contains: Shoutbox, Forum
Expand Down
6 changes: 4 additions & 2 deletions piratebox/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#=======================================================================
#Import PirateBox conf
CURRENT_CONF=piratebox/conf/piratebox.conf
scriptfile="$(readlink -f $0)"
CURRENT_DIR="$(dirname ${scriptfile})"

#Must be root
if [[ $EUID -ne 0 ]]; then
Expand All @@ -32,7 +34,7 @@ else
exit 0
fi

if [[ -f $CURRENT_CONF ]]; then
if [[ -f "$CURRENT_DIR"/$CURRENT_CONF ]]; then
. $CURRENT_CONF 2> /dev/null
else
echo "PirateBox config is not in its normal directory"
Expand All @@ -44,7 +46,7 @@ if [[ ! -d /opt ]]; then
mkdir -p /opt
fi

cp -rv piratebox/piratebox /opt &> /dev/null
cp -rv "$CURRENT_DIR"/piratebox /opt &> /dev/null
echo "Finished copying files..."
echo "$NET.$IP_SHORT piratebox.lan">>/etc/hosts
echo "$NET.$IP_SHORT piratebox">>/etc/hosts
Expand Down
4 changes: 2 additions & 2 deletions piratebox/piratebox/bin/distribute_file_into_directory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ filename="${src_file##*/}"
$DEBUG && echo "filename: $filename"
$DEBUG && echo "Overwrite mode : $overwrite "

if [ ! -e $directory/$filename ] || [ "$overwrite" == "true" ] ; then
if [ ! -e "$directory/$filename" ] || [ "$overwrite" = true ] ; then
echo "Distribute $filename into $directory "
$DEBUG && echo " cp $src_file $directory "
$TEST_RUN || cp $src_file $directory
$TEST_RUN || cp "$src_file" "$directory"
else
$DEBUG && echo "File exists"
fi
Expand Down
4 changes: 2 additions & 2 deletions piratebox/piratebox/bin/distribute_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ destination=$1
overwrite=$2
overwrite=${overwrite:=false}
src_file=$3
src_file=${src_file:=all}
src_file=${src_file:="all"}

$DEBUG && echo "parameters:
destination $destination
Expand All @@ -38,7 +38,7 @@ $DEBUG && echo "parameters:
call script: $script
";

if [ "$src_file" == "all" ] ; then
if [ "$src_file" = "all" ] ; then
work_on_file $destination $PIRATEBOX_FOLDER/src/HEADER.txt
work_on_file $destination $PIRATEBOX_FOLDER/src/README.txt
else
Expand Down
4 changes: 2 additions & 2 deletions piratebox/piratebox/bin/install_piratebox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ if [ $2 = 'part2' ] ; then
cp $PIRATEBOX_FOLDER/src/kareha.pl $PIRATEBOX_FOLDER/share/board
fi

[[ ! -L $PIRATEBOX_FOLDER/www/board ]] && ln -s $PIRATEBOX_FOLDER/share/board $PIRATEBOX_FOLDER/www/board
[[ ! -L $PIRATEBOX_FOLDER/www/Shared ]] && ln -s $UPLOADFOLDER $PIRATEBOX_FOLDER/www/Shared
[ ! -L $PIRATEBOX_FOLDER/www/board ] && ln -s $PIRATEBOX_FOLDER/share/board $PIRATEBOX_FOLDER/www/board
[ ! -L $PIRATEBOX_FOLDER/www/Shared ] && ln -s $UPLOADFOLDER $PIRATEBOX_FOLDER/www/Shared
fi

#Install the image-board
Expand Down
41 changes: 22 additions & 19 deletions piratebox/piratebox/bin/piratebox_setup_wlan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@
# Netmask
# Interface

probe() {
if [ "$PROBE_INTERFACE" = "yes" ] ; then
echo -n "Probing interface $INTERFACE"
ifconfig "$INTERFACE" >> /dev/null 2>&1
TEST_OK=$?
CNT=$PROBE_TIME
while [[ "$TEST_OK" != "0" && "$CNT" != "0" ]]
do
echo -n "."
sleep 1
CNT=$(( $CNT - 1 ))
if [ "$CNT" = 0 ] ; then
exit 99
fi
ifconfig "$INTERFACE" >> /dev/null 2>&1
TEST_OK=$?
done
fi
}



# Load configfile

if [ -z $1 ] || [ -z $2 ]; then
Expand Down Expand Up @@ -82,23 +104,4 @@ elif [ $ = "probe" ] ; then
fi


probe() {
if [ "$PROBE_INTERFACE" = "yes" ] ; then
echo -n "Probing interface $INTERFACE"
ifconfig "$INTERFACE" >> /dev/null 2>&1
TEST_OK=$?
CNT=$PROBE_TIME
while [[ "$TEST_OK" != "0" && "$CNT" != "0" ]]
do
echo -n "."
sleep 1
CNT=$(( $CNT - 1 ))
if [ "$CNT" = 0 ] ; then
exit 99
fi
ifconfig "$INTERFACE" >> /dev/null 2>&1
TEST_OK=$?
done
fi
}

2 changes: 1 addition & 1 deletion piratebox/piratebox/bin/shoutbox_stuff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ python psogen.py generate
chown $LIGHTTPD_USER:$LIGHTTPD_GROUP $SHOUTBOX_CHATFILE
chown $LIGHTTPD_USER:$LIGHTTPD_GROUP $SHOUTBOX_GEN_HTMLFILE
chmod ug+rw $SHOUTBOX_CHATFILE
chmod ug+rw $SHOUTBOX_CHATFILE
chmod ug+rw $SHOUTBOX_GEN_HTMLFILE


2 changes: 1 addition & 1 deletion piratebox/piratebox/init.d/piratebox
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ else
fi


if [[ -f $PIRATEBOX/conf/init_done ]] ; then
if [ -f $PIRATEBOX/conf/init_done ] ; then
INIT=OK
else
$PIRATEBOX/bin/hooks/hook_pre_init.sh "$CONF"
Expand Down
4 changes: 2 additions & 2 deletions piratebox/piratebox/python_lib/broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def __errorMessage (self, msg):
def send(self):
for destination in self.destination:
if socket.has_ipv6 and re.search(":", destination) and not self.ipv6_disabled == 1:

self.__debugMessage( "working in ipv6 part on destination " + destination )
self.__debugMessage( "working in ipv6 part on destination " + destination )

# Even if Python is compiled with IPv6, it doesn't mean that the os
# is supporting IPv6. (like the Nokia N900)
Expand Down
18 changes: 9 additions & 9 deletions piratebox/piratebox/python_lib/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ def handle(self):
socket = self.request[1]
if data[:9] == "piratebox":
if data[10:12] == "sb":
if data != lastmsg :
msg = messages.shoutbox_message()
msg.set_message(data)
content = msg.get()
writeToDisk(content)
if data != lastmsg :
msg = messages.shoutbox_message()
msg.set_message(data)
content = msg.get()
writeToDisk(content)
generate_html_from_file()
lastmsg = data
else:
print data[11:12]
print data
lastmsg = data
else:
print data[11:12]
print data
else:
print "debug : not a piratebox message"

Expand Down
59 changes: 28 additions & 31 deletions piratebox/piratebox/python_lib/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,43 @@
import sys

class message:

def __init__(self, name="generate" ):
if name == "generate":
self.name=socket.gethostname()
else:
self.name=name
def __init__(self, name="generate" ):
if name == "generate":
self.name=socket.gethostname()
else:
self.name=name

self.type="gc"
self.decoded=""
self.type="gc"
self.decoded=""

def set ( self, content=" " ):
base64content = base64.b64encode ( content )
self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content

def get ( self ):

# TODO Split decoded part
message_parts = string.split ( self.decoded , ";" )
def set ( self, content=" " ):
base64content = base64.b64encode ( content )
self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content

if message_parts[0] != "piratebox" :
return None
def get ( self ):
# TODO Split decoded part
message_parts = string.split ( self.decoded , ";" )

b64_content_part = message_parts[4]
if message_parts[0] != "piratebox":
return None

content = base64.b64decode ( b64_content_part )
return content
b64_content_part = message_parts[4]

content = base64.b64decode ( b64_content_part )
return content

def get_sendername (self):
return self.name
def get_sendername (self):
return self.name

def get_message ( self ):
return self.decoded
def get_message ( self ):
return self.decoded

def set_message ( self , decoded):
self.decoded = decoded
def set_message ( self , decoded):
self.decoded = decoded


class shoutbox_message(message):
def __init__(self, name="generate" ):
message.__init__( self , name)
self.type="sb"

def __init__(self, name="generate" ):
message.__init__( self , name)
self.type="sb"

49 changes: 27 additions & 22 deletions piratebox/piratebox/python_lib/psogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
broadcast_destination = False


def html_escape(text):
"""Remove HTML chars from the given text and replace them with HTML
entities. """
html_escape_table = {
'"': """, "'": "'", ">": ">",
"<": "&lt;"}
return "".join(html_escape_table.get(c,c) for c in text)

#--------------
# Generates Shoutbox-HTML-Frame ...
# Imports:
Expand Down Expand Up @@ -91,27 +99,27 @@ def save_input( name , indata , color ):
return writeToDisk ( content )

def writeToNetwork ( content , broadcast_destination ):
message = messages.shoutbox_message()
message.set(content)
casting = broadcast.broadcast( )
casting.setDestination(broadcast_destination)
casting.set( message.get_message() )
casting.send()
return None
message = messages.shoutbox_message()
message.set(content)
casting = broadcast.broadcast( )
casting.setDestination(broadcast_destination)
casting.set( message.get_message() )
casting.send()
return None

def writeToDisk ( content ):
old = read_data_file()
finalcontent = content + old
datafile = open(datafilename, 'r+')
datafile.write(finalcontent)
#datafile.truncate(0)
datafile.close()
return finalcontent


def prepare_line ( name, indata, color ):
datapass = re.sub("<", "&lt;", indata)
data = re.sub(">", "&gt;", datapass)
old = read_data_file()
finalcontent = content + old
datafile = open(datafilename, 'r+')
datafile.write(finalcontent)
#datafile.truncate(0)
datafile.close()
return finalcontent

def prepare_line (name, indata, color):
name = html_escape(name)
data = html_escape(indata)
color = html_escape(color)
curdate = datetime.datetime.now()
# Trying to make it look like this:
# <div class="message">
Expand All @@ -132,6 +140,3 @@ def prepare_line ( name, indata, color ):

generate_html_from_file ()
print "Generated HTML-Shoutbox File."



Loading

0 comments on commit 6626cbc

Please sign in to comment.