Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix api usage with custom name environment variable #56

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
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');
} 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');
}
Expand Down
Loading