diff --git a/AUTHORS b/AUTHORS index acf7a17b..477a35b2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -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 diff --git a/CHANGELOG b/CHANGELOG index 422638db..e13f8dc5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/Makefile b/Makefile index 7e63e0b1..faa131cc 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/README.md b/README.md index ed4be83c..f433c991 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/piratebox/install.sh b/piratebox/install.sh index 5cc69363..41474399 100755 --- a/piratebox/install.sh +++ b/piratebox/install.sh @@ -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 @@ -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" @@ -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 diff --git a/piratebox/piratebox/bin/distribute_file_into_directory.sh b/piratebox/piratebox/bin/distribute_file_into_directory.sh index 746b6486..d1098859 100755 --- a/piratebox/piratebox/bin/distribute_file_into_directory.sh +++ b/piratebox/piratebox/bin/distribute_file_into_directory.sh @@ -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 diff --git a/piratebox/piratebox/bin/distribute_files.sh b/piratebox/piratebox/bin/distribute_files.sh index 20530e5c..45d59c47 100755 --- a/piratebox/piratebox/bin/distribute_files.sh +++ b/piratebox/piratebox/bin/distribute_files.sh @@ -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 @@ -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 diff --git a/piratebox/piratebox/bin/install_piratebox.sh b/piratebox/piratebox/bin/install_piratebox.sh index 62fd1025..bee7a871 100755 --- a/piratebox/piratebox/bin/install_piratebox.sh +++ b/piratebox/piratebox/bin/install_piratebox.sh @@ -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 diff --git a/piratebox/piratebox/bin/piratebox_setup_wlan.sh b/piratebox/piratebox/bin/piratebox_setup_wlan.sh index dc89f080..f2c2b917 100755 --- a/piratebox/piratebox/bin/piratebox_setup_wlan.sh +++ b/piratebox/piratebox/bin/piratebox_setup_wlan.sh @@ -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 @@ -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 -} diff --git a/piratebox/piratebox/bin/shoutbox_stuff.sh b/piratebox/piratebox/bin/shoutbox_stuff.sh index 0d357cc2..c492d77d 100755 --- a/piratebox/piratebox/bin/shoutbox_stuff.sh +++ b/piratebox/piratebox/bin/shoutbox_stuff.sh @@ -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 diff --git a/piratebox/piratebox/init.d/piratebox b/piratebox/piratebox/init.d/piratebox index f35aeae8..d44e3e26 100755 --- a/piratebox/piratebox/init.d/piratebox +++ b/piratebox/piratebox/init.d/piratebox @@ -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" diff --git a/piratebox/piratebox/python_lib/broadcast.py b/piratebox/piratebox/python_lib/broadcast.py index e2916f21..70107bfa 100644 --- a/piratebox/piratebox/python_lib/broadcast.py +++ b/piratebox/piratebox/python_lib/broadcast.py @@ -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) diff --git a/piratebox/piratebox/python_lib/discover.py b/piratebox/piratebox/python_lib/discover.py index 4cdee2f7..9ab4f6d1 100644 --- a/piratebox/piratebox/python_lib/discover.py +++ b/piratebox/piratebox/python_lib/discover.py @@ -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" diff --git a/piratebox/piratebox/python_lib/messages.py b/piratebox/piratebox/python_lib/messages.py index dae0843e..1884efb8 100644 --- a/piratebox/piratebox/python_lib/messages.py +++ b/piratebox/piratebox/python_lib/messages.py @@ -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" diff --git a/piratebox/piratebox/python_lib/psogen.py b/piratebox/piratebox/python_lib/psogen.py index 70911f50..00a28b7e 100755 --- a/piratebox/piratebox/python_lib/psogen.py +++ b/piratebox/piratebox/python_lib/psogen.py @@ -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 = { + '"': """, "'": "'", ">": ">", + "<": "<"} + return "".join(html_escape_table.get(c,c) for c in text) + #-------------- # Generates Shoutbox-HTML-Frame ... # Imports: @@ -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("<", "<", indata) - data = re.sub(">", ">", 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: #