From 73a5be43d96bfeaf1f6f22d2962d3c8c29a7d7e8 Mon Sep 17 00:00:00 2001 From: Pedro Pombeiro Date: Fri, 11 Oct 2024 18:21:26 +0200 Subject: [PATCH 1/3] Fix API usage when NAME variable is customized --- Dockerfile | 4 +--- files/runScanner.sh | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 88c3bc1..cbf0a8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,14 +43,12 @@ cp /etc/lighttpd/conf-available/15-fastcgi-php.conf /etc/lighttpd/conf-enabled/ cp /etc/lighttpd/conf-available/10-fastcgi.conf /etc/lighttpd/conf-enabled/ && \ mkdir -p /var/run/lighttpd && \ touch /var/run/lighttpd/php-fastcgi.socket && \ -chown -R www-data /var/run/lighttpd && \ -echo 'www-data ALL=(NAS) NOPASSWD:ALL' >> /etc/sudoers +chown -R www-data /var/run/lighttpd EOF ENV NAME="Scanner" ENV MODEL="MFC-L2700DW" ENV IPADDRESS="192.168.1.123" -ENV USERNAME="NAS" ENV REMOVE_BLANK_THRESHOLD="0.3" # Only set these variables in the compose file, if inotify needs to be triggered (e.g., for Synology Drive): diff --git a/files/runScanner.sh b/files/runScanner.sh index 8b1a195..b52f0d3 100755 --- a/files/runScanner.sh +++ b/files/runScanner.sh @@ -55,6 +55,8 @@ echo "-----" echo "setting up webserver:" if [ "$WEBSERVER" == "true" ]; then + echo "www-data ALL=($NAME) NOPASSWD:ALL" >>/etc/sudoers + echo "starting webserver for API & GUI..." { echo " Date: Fri, 11 Oct 2024 18:22:24 +0000 Subject: [PATCH 2/3] fixed broken js --- html/index.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/html/index.php b/html/index.php index 5e58710..6171fa6 100644 --- a/html/index.php +++ b/html/index.php @@ -169,15 +169,15 @@ function set_state(state) { if (data.ocr && data.waiting && !data.scan) { state = 'ocr'; - } elseif (data.scan && data.waiting) { + } else if (data.scan && data.waiting) { state = 'scan'; - } elseif (data.scan) { + } else if (data.scan) { state = 'scan'; - } elseif (data.ocr && !data.scan) { + } else if (data.ocr && !data.scan) { state = 'ocr'; - } elseif (!data.ocr && !data.scan && data.waiting) { + } else if (!data.ocr && !data.scan && data.waiting) { state = 'waiting'; - } elseif (!data.ocr && !data.scan && !data.waiting) { + } else if (!data.ocr && !data.scan && !data.waiting) { state = 'idle'; } set_state(state); From 727db3547124e4231c6d8292f54be88026c41a5d Mon Sep 17 00:00:00 2001 From: Philipp Mundhenk Date: Fri, 11 Oct 2024 18:30:01 +0000 Subject: [PATCH 3/3] more js fixes --- html/scan.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/scan.php b/html/scan.php index df9fc84..8490893 100644 --- a/html/scan.php +++ b/html/scan.php @@ -8,7 +8,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $target = $_POST["target"]; -} elseif ($_SERVER['REQUEST_METHOD'] == 'GET') { +} else if ($_SERVER['REQUEST_METHOD'] == 'GET') { $target = $_GET["target"]; } @@ -20,7 +20,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { // return immediately $handle = popen('sudo -b -u \#'.$UID.' /opt/brother/scanner/brscan-skey/script/scanto'.$target.'.py', 'r'); - } elseif ($_SERVER['REQUEST_METHOD'] == 'GET') { + } else if ($_SERVER['REQUEST_METHOD'] == 'GET') { // wait for completion $output=shell_exec('sudo -u \#'.$UID.' /opt/brother/scanner/brscan-skey/script/scanto'.$target.'.py'); }