Skip to content

Commit

Permalink
suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lutz Bender committed Dec 5, 2022
1 parent 3945e38 commit feb26d7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
4 changes: 1 addition & 3 deletions helperFunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ openwbDebugLog() {
export -f openwbDebugLog

openwbRunLoggingOutput() {
functionName="$1"
shift
$functionName "$@" 2>&1 | while read -r line
"$@" 2>&1 | while read -r line
do
# use path to /var/log as link in ramdisk may not be set up yet!
echo "$(date +"%Y-%m-%d %H:%M:%S"): $1: $line" >> "/var/log/openWB.log"
Expand Down
3 changes: 1 addition & 2 deletions runs/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ LOGFILE="$OPENWBBASEDIR/web/tools/upload/restore.log"
echo "****************************************"
echo "Step 4: replacing old files..."
# we use cp not mv because of not empty directories in destination
# dotglob is needed to include files and directories beginning with a dot
(shopt -s dotglob; sudo cp -v -p -r "${WORKINGDIR}${OPENWBBASEDIR}/"* "${OPENWBBASEDIR}/")
sudo cp -v -p -r "${WORKINGDIR}${OPENWBBASEDIR}/." "${OPENWBBASEDIR}/"
echo "****************************************"
echo "Step 5: restoring mosquitto db..."
if [[ -f "${WORKINGDIR}${MOSQUITTODIR}/mosquitto.db" ]]; then
Expand Down
6 changes: 2 additions & 4 deletions web/settings/backup.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php
// if parameter extendedFilename is passed with value 1 the filename changes
// from backup.tar.gz to openWB_backup_YYYY-MM-DD_HH-MM-SS.tar.gz
$useExtendedFilename = 0;
if( isset($_GET["extendedFilename"]) && $_GET["extendedFilename"] == "1") {
$useExtendedFilename = 1;
}
$useExtendedFilename = isset($_GET["extendedFilename"]) && $_GET["extendedFilename"] == "1" ? 1 : 0;

// execute backup script
$filename = exec("sudo -u pi " . $_SERVER['DOCUMENT_ROOT'] . "/openWB/runs/backup.sh " . $useExtendedFilename, $output, $result);
?>
Expand Down
2 changes: 1 addition & 1 deletion web/settings/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function(data){
</script>
<?php
if($uploadOk === true) {
exec("sudo -u pi " . $_SERVER['DOCUMENT_ROOT'] . "/openWB/runs/restore.sh");
exec("sudo -u pi " . escapeshellarg($_SERVER['DOCUMENT_ROOT']) . "/openWB/runs/restore.sh");
?>
<script>
setTimeout(function() { window.location = "index.php"; }, 15000);
Expand Down

0 comments on commit feb26d7

Please sign in to comment.