Skip to content

Commit

Permalink
Merge branch 'hotfix-1.1.3'
Browse files Browse the repository at this point in the history
* hotfix-1.1.3: (25 commits)
  js/script.js : Add additional disk usage refresh.
  Switch to version 1.1.3
  CHANGELOG: note down RPi Adjustments
  Version flag 1.1.3-beta
  RPI-MOTD: Version update
  Introduced SDCard helper for RPi
  CHANGELOG: Add missing entries for 1.1.3
  lighttpd.conf: Reduce cache to a minimum
  usb_share.sh: Force disk usage update
  hostapd.conf: More Comments in hostapd for WPA mode
  Feature: Add scripts for on the fly client mode
  wifi_detect: only change piratebox.conf if it is a wifi device
  wifi_detect.sh: Bugfixes and adjust piratebox configuration
  hostapd.conf:  More comment to enable n wifi mode
  Fix for issue on RPi3 with multiple wifi cards
  Fix Shellcheck results
  Track fix ger language
  Track new contribution
  Correct/translate German localisation strings.
  --added brazilian portuguese translation to the landing page (data.pt-br.properties)
  ...
  • Loading branch information
MaStr committed Mar 19, 2017
2 parents 775501c + 7602d1f commit 150ba18
Show file tree
Hide file tree
Showing 24 changed files with 340 additions and 49 deletions.
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Contributors for modifications:
# Mike Weaver
# bartschat - RTC RPi feature
# casdr
# jdieg0
# a-ira
# ... and all others I might have forgotten.


Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
CHANGELOG

=== 1.1.3 ===
* [New] Translation bt-pr
* [New] [RPi] Helper scripts to jump to wifi client mode
* [New] [RPi] Helper script to use SDCard without reboot
* [New] [RPi] Image adjustments to save SDCard for to many writes
* [Fix] Some shell incompatibilities
* [Fix] forest.py : Cleanup used folders
* [Fix] Fixed localization ID for placeholder message
* [Fix] Correct/translate German localisation strings
* [Fix] Adjust hostapd.conf with comments & addtional parameter for n-mode wifi
* [Fix] Some help about setting up WPA2 mode for AP in hostapd.conf
* [Fix] Reduce browser cache to a minimum, which solves issues with shoutbox and diskusage
* [Fix] Trigger async disk usage refresh during page load

=== 1.1.2 ===
* [Fix] Upgrade 1.1.x - 1.1.x does not create content symlink

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.1.2
VERSION = 1.1.3
ARCH = all
PB_FOLDER=piratebox
PB_SRC_FOLDER=$(PB_FOLDER)/$(PB_FOLDER)
Expand Down
6 changes: 3 additions & 3 deletions piratebox/piratebox/bin/firewall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ if test -z "$run" ; then
echo "ERROR: You need to select -s (start) or -k (stop) "
help_text
fi
if test -z $PIRATEBOX_CONFIG || test -z "$FIREWALL_CONFIG" ; then
if test -z "$PIRATEBOX_CONFIG" || test -z "$FIREWALL_CONFIG" ; then
echo "ERROR: one of the config paths is empty, while it should not"
help_text
fi

. $PIRATEBOX_CONFIG || exit 6
. $FIREWALL_CONFIG || exit 5
. "$PIRATEBOX_CONFIG" || exit 6
. "$FIREWALL_CONFIG" || exit 5

if [ "$run" = "start" ] ; then
IPT_FLAG="-A"
Expand Down
6 changes: 3 additions & 3 deletions piratebox/piratebox/bin/install_piratebox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ PIRATEBOX_CONFIG=$1

if [ $2 = 'pyForum' ] ; then
cp -v $PIRATEBOX_FOLDER/src/forest.py $WWW_FOLDER/cgi-bin
cp -v $PIRATEBOX_FOLDER/src/forest.css $WWW_FOLDER/
cp -v $PIRATEBOX_FOLDER/src/forest.css $WWW_FOLDER/content/css
mkdir -p $PIRATEBOX_FOLDER/forumspace
chmod a+rw -R $PIRATEBOX_FOLDER/forumspace
chmod a+rw -R $PIRATEBOX_FOLDER/forumspace 2> /dev/null
chown $LIGHTTPD_USER:$LIGHTTPD_GROUP $WWW_FOLDER/cgi-bin/forest.py
chown $LIGHTTPD_USER:$LIGHTTPD_GROUP $WWW_FOLDER/forest.css
chown $LIGHTTPD_USER:$LIGHTTPD_GROUP $WWW_FOLDER/content/forest.css 2> /dev/null
echo "Copied the files. Recheck your PirateBox now. "
fi

Expand Down
2 changes: 1 addition & 1 deletion piratebox/piratebox/bin/json_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ 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
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
Expand Down
14 changes: 13 additions & 1 deletion piratebox/piratebox/conf/hostapd.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
interface=wlan0
driver=nl80211
ssid=PirateBox - Share Freely
hw_mode=g

channel=1
#auth_algs=1

# Remove # to enable n wifi mode
#ieee80211n=1
#wmm_enabled=1
#ht_capab=[HT40+][SHORT-GI-40][DSSS_CCK-40]
hw_mode=g

# Put a # in front of the following line to allow
# direct client 2 client communication
ap_isolate=1

# Uncomment the following lines to enable WPA
#wpa=2
#wpa_key_mgmt=WPA-PSK
#wpa_pairwise=TKIP CCMP
#rsn_pairwise=CCMP
#wpa_passphrase=Somepassphrase
1 change: 1 addition & 0 deletions piratebox/piratebox/conf/lighttpd/lighttpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ $HTTP["url"] =~ "^/board/" {
#-------------------------------------


setenv.add-response-header += ( "Cache-Control" => "max-age=60, must-revalidate, no-store, no-cache, public" )

# 404 Error Page with redirect
#
Expand Down
2 changes: 1 addition & 1 deletion piratebox/piratebox/init.d/piratebox
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ case "$1" in
log_end_msg $?


if [ "$IPV6_ENABLE" == "yes" ] && [ "$IPV6_ADVERT" == "radvd" ] ; then
if [ "$IPV6_ENABLE" = "yes" ] && [ "$IPV6_ADVERT" = "radvd" ] ; then
log_daemon_msg "Starting radvd..."
start-stop-daemon --start --quiet --exec radvd -- -p $PIDFILE_RADVD -C $CONF_RADVD
log_end_msg $?
Expand Down
2 changes: 1 addition & 1 deletion piratebox/piratebox/init.d/piratebox_alt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ case "$1" in
$PIRATEBOX_FOLDER/bin/firewall.sh -s
echo $?

if [ "$IPV6_ENABLE" == "yes" ] && [ "$IPV6_ADVERT" == "radvd" ] ; then
if [ "$IPV6_ENABLE" = "yes" ] && [ "$IPV6_ADVERT" = "radvd" ] ; then
echo "Starting radvd..."
start-stop-daemon -S -q -x radvd -- -p $PIDFILE_RADVD -C $CONF_RADVD
echo $?
Expand Down
14 changes: 14 additions & 0 deletions piratebox/piratebox/rpi/bin/do_switch_client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

# Wrapper script for the steps to enable wifi client

systemctl stop piratebox
if /opt/piratebox/rpi/run_client.sh ; then
echo "Started Wifi client sucessfully!"
exit 0
else
echo "Error while starting wifi client, restarting piratebox"
systemctl start piratebox
exit 1
fi
exit 1
27 changes: 27 additions & 0 deletions piratebox/piratebox/rpi/bin/run_client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Runs with wpa_supplicant & wifi device from boot folder.

## Default
WIFI_DEVICE="wlan0"

WIFI_CONFIG_PATH="/boot/wifi_card.conf"
WPA_SUPPLICANT="/boot/wpa_supplicant.conf"

# Try to get wifi device
if test -e "${WIFI_CONFIG_PATH}" ; then
echo "Found wifi card config"
WIFI_DEVICE=$( head -n 1 "${WIFI_CONFIG_PATH}" | tr -d '\n' )
fi

# Try to connect to Wifi if wpa_supplicant.conf is available.
if [ -f "${WPA_SUPPLICANT}" ]; then
echo "Found wpa_supplicant conf, trying to connect..."
wpa_supplicant -i"${WIFI_DEVICE}" -c "${WPA_SUPPLICANT}" -B -D wext
dhcpcd "${WIFI_DEVICE}"
exit 0
else
echo "Wifi configuration not found"
exit 1
fi
exit 1
103 changes: 103 additions & 0 deletions piratebox/piratebox/rpi/bin/sdcard_share.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#/bin/bash

# This script enables the SDCard as ext4 to be used as storage
# it also activates some spare for swap

MOUNTPOINT="/mnt/sdshare"
FS="ext4"


SDCARD="/dev/mmcblk0"

if test -e "$SDCARD"p3 ; then
echo "ERROR: SWAP already exists"
exit 1
fi

if test -e "$SDCARD"p4 ; then
echo "ERROR: Data partition already exists"
exit 1
fi

echo "Creating partitions.."
fdisk "$SDCARD" <<EOF
n
p
3
+256M
n
p
4
w
EOF

echo Reloading partition table
partprobe "$SDCARD"

if test -e "$SDCARD"p3 ; then
if test -e "$SDCARD"p4 ; then
echo "Ok, all partitions available"
else
echo "ERROR: Data partition is missing."
exit 1
fi
else
echo "ERROR: SWAP missing."
exit 1
fi

mkswap /dev/mmcblk0p3
if [ $? -ne 0 ] ; then
echo "Error formating swap"
exit 1
fi

SWAP_UUID=$( blkid | grep "/dev/mmc*.*TYPE=\"swap\"" | egrep -o " UUID=\"([a-zA-Z0-9-])*\"" | sed 's/ //g' )

if grep -q "${SWAP_UUID}" /etc/fstab ; then
echo "Error: swap is already configured in fstab"
exit 1
fi

echo "Adding swap to fstab"
echo "${SWAP_UUID} none swap defaults 0 0" >> /etc/fstab

echo "Creating data partition"
mkfs.ext4 -F "$SDCARD"p4
if [ $? -ne 0 ] ; then
echo "Error formating data"
exit 1
fi

DATA_UUID=$( blkid | grep "${SDCARD}p4.*TYPE=\"ext4\"" | egrep -o " UUID=\"([a-zA-Z0-9-])*\"" | sed 's/ //g' )
if grep -q "${DATA_UUID}" /etc/fstab ; then
echo "Error: data is already configured in fstab"
exit 1
fi

echo "${DATA_UUID} ${MOUNTPOINT} ext4 defaults,noatime,nodiratime,data=writeback 0 0 ">> /etc/fstab

mkdir -p "${MOUNTPOINT}"
mount "${MOUNTPOINT}"

if [ $? -ne 0 ] ; then
echo "ERROR mounting data partion"
exit 1
fi

echo "## Moving files..."
mv /opt/piratebox/share "${MOUNTPOINT}/share" > /dev/null 2>&1
ln -s "${MOUNTPOINT}/share" /opt/piratebox/share > /dev/null


# Force update diskwirte
touch -t 197001010101 /opt/piratebox/www/diskusage.html
wget http://127.0.0.1/cgi-bin/diskwrite.py -q -O -

exit 0

17 changes: 16 additions & 1 deletion piratebox/piratebox/rpi/bin/starter.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
#!/bin/sh
# Try to setup WiFi and if it succeeds, start the PirateBox
/bin/sh -c /opt/piratebox/rpi/bin/wifi_detect.sh && /usr/bin/systemctl start piratebox

## Default
WIFI_DEVICE="wlan0"

WIFI_CONFIG_PATH="/boot/wifi_card.conf"

if test -e "${WIFI_CONFIG_PATH}" ; then
echo "Found wifi card config"
WIFI_DEVICE=$( head -n 1 "${WIFI_CONFIG_PATH}" | tr -d '\n' )
fi


if [ "${INTERFACE}" = "${WIFI_DEVICE}" ] ; then
/bin/sh -c /opt/piratebox/rpi/bin/wifi_detect.sh && /usr/bin/systemctl start piratebox
fi
exit 0
6 changes: 6 additions & 0 deletions piratebox/piratebox/rpi/bin/switch_to_client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

# User friendly way to switch to client
# Adds "nohup" option...

nohup /opt/piratebox/rpi/bin/do_switch_client.sh
4 changes: 4 additions & 0 deletions piratebox/piratebox/rpi/bin/usb_share.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ else
cat "/etc/fstab"
fi

# Force update diskwirte
touch -t 197001010101 /opt/piratebox/www/diskusage.html
wget http://127.0.0.1/cgi-bin/diskwrite.py -q -O -

exit 0
58 changes: 49 additions & 9 deletions piratebox/piratebox/rpi/bin/wifi_detect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,69 @@
# Install the proper hostapd package and adjust the hostapd configuration
# accordingly.

## Default
WIFI_DEVICE="wlan0"

WIFI_CONFIG_PATH="/boot/wifi_card.conf"

PACKAGE_PATH="/prebuild/hostapd"
CONFIG_PATH="/opt/piratebox/conf/hostapd.conf"
PIRATEBOX_CONFIG_PATH="/opt/piratebox/conf/piratebox.conf"

## Only use if it is set
if test -e "${WIFI_CONFIG_PATH}" ; then
echo "Found wifi card config"
WIFI_DEVICE=$( head -n 1 "${WIFI_CONFIG_PATH}" | tr -d '\n' )
fi

hostap_interface=$( grep -e '^interface' "${CONFIG_PATH}" | sed -e 's|interface=||' )
piratebox_interface=$( grep -e '^INTERFACE' "${PIRATEBOX_CONFIG_PATH}" | \
sed -e 's|INTERFACE=||' -e 's|"||g' )
dnsmasq_interface=$( grep -e '^DNSMASQ_INTERFACE' "${PIRATEBOX_CONFIG_PATH}" | \
sed -e 's|DNSMASQ_INTERFACE=||' -e 's|"||g' )

sed -i -e "s|interface=$hostap_interface|interface=$WIFI_DEVICE|" "${CONFIG_PATH}"

#Only change piratebox interface if it is a wifi interface
if echo "$piratebox_interface" | grep -q "wlan" ; then
sed -i -e "s|INTERFACE=\"$piratebox_interface\"|INTERFACE=\"$WIFI_DEVICE\"|" \
"${PIRATEBOX_CONFIG_PATH}"
fi
if echo "$dnsmasq_interface" | grep -q "wlan" ; then
sed -i -e "s|DNSMASQ_INTERFACE=\"$dnsmasq_interface\"|DNSMASQ_INTERFACE=\"$WIFI_DEVICE\"|" \
"${PIRATEBOX_CONFIG_PATH}"
fi



## Get pyhX device node
CARD_ID=$( cat /sys/class/net/"${WIFI_DEVICE}"/phy80211/index )


# Check if we have an nl80211 enabled device with AP mode, then we are done
if iw list | grep > /dev/null "* AP$"; then
if iw phy phy"${CARD_ID}" info | grep -q "* AP$"; then
echo "Found nl80211 device capable of AP mode..."
yes | pacman -U --needed "${PACKAGE_PATH}/hostapd-2"* > /dev/null
pacman --noconfirm -U --needed "${PACKAGE_PATH}/hostapd-2"* > /dev/null
sed -i 's/^#driver=nl80211/driver=nl80211/' "${CONFIG_PATH}"
exit 0
fi

#Get driver name
DRIVER_NAME=$( ls -1 /sys/class/net/"${WIFI_DEVICE}"/device/driver/module/drivers/ )

# Check for r8188eu enabled device
if dmesg | grep > /dev/null "r8188eu:"; then
if echo "$DRIVER_NAME" | grep -q "r8188eu:"; then
echo "Found r8188eu enabled device..."
yes | pacman -U --needed "${PACKAGE_PATH}/hostapd-8188eu-"* > /dev/null
pacman --noconfirm -U --needed "${PACKAGE_PATH}/hostapd-8188eu-"* > /dev/null
sed -i 's/^driver=nl80211/#driver=nl80211/' "${CONFIG_PATH}"
exit 0
fi


# Check for rtl8192cu enabled device
if dmesg | grep > /dev/null "rtl8192cu"; then
if echo "$DRIVER_NAME" | grep -q "rtl8192cu"; then
echo "Found rtl8192cu enabled device..."
yes | pacman -U --needed "${PACKAGE_PATH}/hostapd-8192cu-"* > /dev/null
pacman --noconfirm -U --needed "${PACKAGE_PATH}/hostapd-8192cu-"* > /dev/null
sed -i 's/^driver=nl80211/#driver=nl80211/' "${CONFIG_PATH}"
exit 0
fi
Expand All @@ -34,9 +74,9 @@ echo "Could not find an AP enabled WiFi card..."

# Try to connect to Wifi if wpa_supplicant.conf is available.
if [ -f /boot/wpa_supplicant.conf ]; then
echo "Found wpa_supplicant conf, trying to connect..."
wpa_supplicant -iwlan0 -c /boot/wpa_supplicant.conf -B -D wext
dhcpcd wlan0
/opt/piratebox/rpi/bin/run_client.sh
exit 1
# Exit =! 0 will result in not starting piratebox service
fi

exit 1
Loading

0 comments on commit 150ba18

Please sign in to comment.