Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ data/log/*
data/charge_log/*
data/daily_log/*
data/monthly_log/*
data/backup/*.tar.gz
ramdisk/*
web/lastcommit
!.gitignore
6 changes: 0 additions & 6 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@

RedirectMatch 404 \.conf$
RedirectMatch 404 \.ini$
RedirectMatch 404 \.py$
#<FilesMatch "\.(ini|conf|py|sh|json)$">
#Order allow,deny
#Deny from all

#</FilesMatch>
File renamed without changes.
9 changes: 8 additions & 1 deletion data/config/000-default.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# openwb-version:4
# openwb-version:5
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
Expand All @@ -22,6 +22,13 @@
<Directory /var/www/>
AllowOverride All
Require all granted
Options -Indexes
</Directory>
<Directory /var/www/html/openWB/ramdisk>
Options +Indexes
</Directory>
<Directory /var/www/html/openWB/data/backup>
Options +Indexes
</Directory>
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
Expand Down
9 changes: 8 additions & 1 deletion data/config/apache-openwb-ssl.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# openwb-version:5
# openwb-version:6
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
Expand Down Expand Up @@ -103,6 +103,13 @@
<Directory /var/www/html/openWB>
AllowOverride All
Require all granted
Options -Indexes
</Directory>
<Directory /var/www/html/openWB/ramdisk>
Options +Indexes
</Directory>
<Directory /var/www/html/openWB/data/backup>
Options +Indexes
</Directory>
# SSL Protocol Adjustments:
# The safe and default but still SSL/TLS standard compliant shutdown
Expand Down
3 changes: 2 additions & 1 deletion data/config/openwb_local.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# openwb-version:1
# openwb-version:2
listener 1886 localhost
allow_anonymous true

Expand Down Expand Up @@ -53,3 +53,4 @@ topic openWB/log/# out
topic openWB/system/# out

topic openWB/command/+/error both
topic openWB/command/+/messages/+ both
331 changes: 210 additions & 121 deletions packages/helpermodules/command.py

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions packages/helpermodules/setdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,8 @@ def process_command_topic(self, msg):
self._validate_value(msg, "json")
elif "error" in msg.topic:
self._validate_value(msg, "json")
elif "messages" in msg.topic:
self._validate_value(msg, "json")
else:
self.__unknown_topic(msg)
except Exception:
Expand Down
44 changes: 44 additions & 0 deletions runs/backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
OPENWBBASEDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
BACKUPDIR="$OPENWBBASEDIR/data/backup"
LOGFILE="$OPENWBBASEDIR/ramdisk/backup.log"

useExtendedFilename=$1
if ((useExtendedFilename == 1)); then
FILENAME="openWB_backup_$(date +"%Y-%m-%d_%H:%M:%S").tar.gz"
else
FILENAME="backup.tar.gz"
fi

{
echo "creating new backup: $FILENAME"
# remove old backup files
echo "deleting old backup files if present in '$BACKUPDIR'"
rm -v "$BACKUPDIR/"*
BACKUPFILE="$BACKUPDIR/$FILENAME"

# tell mosquitto to store all retained topics in db now
echo "sending 'SIGUSR1' to mosquitto processes"
sudo pkill -e -SIGUSR1 mosquitto
# give mosquitto some time to finish
sleep 0.2

# create backup file
echo "creating new backup file: $BACKUPFILE"
sudo tar --verbose --create --gzip \
--exclude="$BACKUPDIR" \
--exclude="$OPENWBBASEDIR/.git" \
--exclude "$OPENWBBASEDIR/ramdisk" \
--exclude "$OPENWBBASEDIR/__pycache__" \
--exclude "$OPENWBBASEDIR/.pytest_cache" \
--file="$BACKUPFILE" \
"$OPENWBBASEDIR/" "/var/lib/mosquitto/" "/var/lib/mosquitto_local/"
echo "setting permissions of new backup file"
sudo chown openwb:www-data "$BACKUPFILE"
sudo chmod 664 "$BACKUPFILE"

echo "backup finished"
} >>"$LOGFILE" 2>&1

# return our filename for further processing
echo "$FILENAME"