Skip to content

Commit

Permalink
Merge pull request #56 from PhilippMundhenk/pedropombeiro/fix-api-usa…
Browse files Browse the repository at this point in the history
…ge-with-custom-NAME-env-var

Fix api usage with custom name environment variable
  • Loading branch information
PhilippMundhenk authored Oct 20, 2024
2 parents 0cb8ebe + 727db35 commit 93e6f9c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions files/runScanner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<?php"
Expand Down
10 changes: 5 additions & 5 deletions html/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions html/scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
}

Expand All @@ -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');

Check failure on line 22 in html/scan.php

View workflow job for this annotation

GitHub Actions / run-lint

Variable $UID might not be defined.
} 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');

Check failure on line 25 in html/scan.php

View workflow job for this annotation

GitHub Actions / run-lint

Variable $UID might not be defined.
}
Expand Down

0 comments on commit 93e6f9c

Please sign in to comment.