From 06b182b78a5053381be0ec950b79e0d91e9419c5 Mon Sep 17 00:00:00 2001 From: Pedro Pombeiro Date: Sun, 29 Sep 2024 11:41:18 +0200 Subject: [PATCH] Completely remove shell scripts --- Dockerfile | 2 -- files/brscan-skey.config | 8 ++++---- html/scan.php | 6 +++--- script/scantoemail-0.2.4-1.py | 18 ------------------ script/scantoemail-0.2.4-1.sh | 10 ---------- script/scantoemail.py | 19 ++++++++++++++++++- script/scantoemail.sh | 1 - script/scantofile-0.2.4-1.py | 18 ------------------ script/scantofile-0.2.4-1.sh | 10 ---------- script/scantofile.py | 19 ++++++++++++++++++- script/scantofile.sh | 1 - script/scantoimage-0.2.4-1.sh | 12 ------------ script/scantoimage.py | 18 ++++++++++++++++++ script/scantoimage.sh | 1 - script/scantoocr-0.2.4-1.py | 18 ------------------ script/scantoocr-0.2.4-1.sh | 10 ---------- script/scantoocr.py | 19 ++++++++++++++++++- script/scantoocr.sh | 1 - 18 files changed, 79 insertions(+), 112 deletions(-) delete mode 100755 script/scantoemail-0.2.4-1.py delete mode 100755 script/scantoemail-0.2.4-1.sh mode change 120000 => 100755 script/scantoemail.py delete mode 120000 script/scantoemail.sh delete mode 100755 script/scantofile-0.2.4-1.py delete mode 100755 script/scantofile-0.2.4-1.sh mode change 120000 => 100755 script/scantofile.py delete mode 120000 script/scantofile.sh delete mode 100755 script/scantoimage-0.2.4-1.sh create mode 100755 script/scantoimage.py delete mode 120000 script/scantoimage.sh delete mode 100755 script/scantoocr-0.2.4-1.py delete mode 100755 script/scantoocr-0.2.4-1.sh mode change 120000 => 100755 script/scantoocr.py delete mode 120000 script/scantoocr.sh diff --git a/Dockerfile b/Dockerfile index f47b941..2ad3d19 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,8 +22,6 @@ RUN apt-get -y install \ php-curl \ sudo \ iproute2 \ - jq \ - bc \ pdftk \ poppler-utils \ && apt-get -y clean diff --git a/files/brscan-skey.config b/files/brscan-skey.config index ec298ea..02029c1 100644 --- a/files/brscan-skey.config +++ b/files/brscan-skey.config @@ -1,8 +1,8 @@ password= -IMAGE="bash /opt/brother/scanner/brscan-skey/script/scantoimage.sh" -OCR="bash /opt/brother/scanner/brscan-skey/script/scantoocr.sh" -EMAIL="bash /opt/brother/scanner/brscan-skey/script/scantoemail.sh" -FILE="bash /opt/brother/scanner/brscan-skey/script/scantofile.sh" +IMAGE="python3 /opt/brother/scanner/brscan-skey/script/scantoimage.py" +OCR="python3 /opt/brother/scanner/brscan-skey/script/scantoocr.py" +EMAIL="python3 /opt/brother/scanner/brscan-skey/script/scantoemail.py" +FILE="python3 /opt/brother/scanner/brscan-skey/script/scantofile.py" SEMID=b eth= ip_address= diff --git a/html/scan.php b/html/scan.php index ddfa94e..12a3342 100644 --- a/html/scan.php +++ b/html/scan.php @@ -18,10 +18,10 @@ if (in_array($target, array('file','email','image','ocr'))) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { //return immediately - $handle = popen('sudo -b -u \#'.$UID.' /opt/brother/scanner/brscan-skey/script/scanto'.$target.'.sh', 'r'); + $handle = popen('sudo -b -u \#'.$UID.' /opt/brother/scanner/brscan-skey/script/scanto'.$target.'.py', 'r'); } else if ($_SERVER['REQUEST_METHOD'] == 'GET') { //wait for completion - $output=shell_exec('sudo -u \#'.$UID.' /opt/brother/scanner/brscan-skey/script/scanto'.$target.'.sh'); + $output=shell_exec('sudo -u \#'.$UID.' /opt/brother/scanner/brscan-skey/script/scanto'.$target.'.py'); } } else @@ -43,4 +43,4 @@ // die(); //} -?> \ No newline at end of file +?> diff --git a/script/scantoemail-0.2.4-1.py b/script/scantoemail-0.2.4-1.py deleted file mode 100755 index dcdecdb..0000000 --- a/script/scantoemail-0.2.4-1.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/python3 -# $1 = scanner device -# $2 = friendly name - -import sys - -from scanner import read_environment, scan_rear - -if __name__ == "__main__": - # Open the log file in append mode - with open("/var/log/scanner.log", "a") as f: - # Redirect stdout to the log file - sys.stdout = f - - read_environment() - - device = sys.argv[1] - scan_rear(f, device) diff --git a/script/scantoemail-0.2.4-1.sh b/script/scantoemail-0.2.4-1.sh deleted file mode 100755 index 003ce1d..0000000 --- a/script/scantoemail-0.2.4-1.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# $1 = scanner device -# $2 = friendly name - -SCRIPTPATH="$( - cd "$(dirname "$0")" || exit - pwd -P -)" - -"$SCRIPTPATH"/scantoemail.py $@ diff --git a/script/scantoemail.py b/script/scantoemail.py deleted file mode 120000 index 672e1fb..0000000 --- a/script/scantoemail.py +++ /dev/null @@ -1 +0,0 @@ -scantoemail-0.2.4-1.py \ No newline at end of file diff --git a/script/scantoemail.py b/script/scantoemail.py new file mode 100755 index 0000000..a4bae3d --- /dev/null +++ b/script/scantoemail.py @@ -0,0 +1,18 @@ +#!/usr/bin/python3 +# $1 = scanner device +# $2 = friendly name + +import sys + +from scanner import read_environment, scan_rear + +if __name__ == "__main__": + # Open the log file in append mode + with open("/var/log/scanner.log", "a") as log: + # Redirect stdout to the log file + sys.stdout = log + + read_environment() + + device = sys.argv[1] + scan_rear(log, device) diff --git a/script/scantoemail.sh b/script/scantoemail.sh deleted file mode 120000 index 36826b0..0000000 --- a/script/scantoemail.sh +++ /dev/null @@ -1 +0,0 @@ -scantoemail-0.2.4-1.sh \ No newline at end of file diff --git a/script/scantofile-0.2.4-1.py b/script/scantofile-0.2.4-1.py deleted file mode 100755 index 056fac9..0000000 --- a/script/scantofile-0.2.4-1.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/python3 -# $1 = scanner device -# $2 = friendly name - -import sys - -from scanner import read_environment, scan_front - -if __name__ == "__main__": - # Open the log file in append mode - with open("/var/log/scanner.log", "a") as f: - # Redirect stdout to the log file - sys.stdout = f - - read_environment() - - device = sys.argv[1] - scan_front(f, device) diff --git a/script/scantofile-0.2.4-1.sh b/script/scantofile-0.2.4-1.sh deleted file mode 100755 index 745b9f4..0000000 --- a/script/scantofile-0.2.4-1.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# $1 = scanner device -# $2 = friendly name - -SCRIPTPATH="$( - cd "$(dirname "$0")" || exit - pwd -P -)" - -"$SCRIPTPATH"/scantofile.py $@ diff --git a/script/scantofile.py b/script/scantofile.py deleted file mode 120000 index 64bff2a..0000000 --- a/script/scantofile.py +++ /dev/null @@ -1 +0,0 @@ -scantofile-0.2.4-1.py \ No newline at end of file diff --git a/script/scantofile.py b/script/scantofile.py new file mode 100755 index 0000000..f9912fe --- /dev/null +++ b/script/scantofile.py @@ -0,0 +1,18 @@ +#!/usr/bin/python3 +# $1 = scanner device +# $2 = friendly name + +import sys + +from scanner import read_environment, scan_front + +if __name__ == "__main__": + # Open the log file in append mode + with open("/var/log/scanner.log", "a") as log: + # Redirect stdout to the log file + sys.stdout = log + + read_environment() + + device = sys.argv[1] + scan_front(log, device) diff --git a/script/scantofile.sh b/script/scantofile.sh deleted file mode 120000 index 33f00b8..0000000 --- a/script/scantofile.sh +++ /dev/null @@ -1 +0,0 @@ -scantofile-0.2.4-1.sh \ No newline at end of file diff --git a/script/scantoimage-0.2.4-1.sh b/script/scantoimage-0.2.4-1.sh deleted file mode 100755 index fc86ca2..0000000 --- a/script/scantoimage-0.2.4-1.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# $1 = scanner device -# $2 = friendly name - -{ - - echo "ERROR!" - echo "This function is not implemented." - echo "You may implement your own script and mount under $0." - echo "Check out scripts in same folder or https://github.com/PhilippMundhenk/BrotherScannerDocker for examples." - -} >>/var/log/scanner.log 2>&1 diff --git a/script/scantoimage.py b/script/scantoimage.py new file mode 100755 index 0000000..b771462 --- /dev/null +++ b/script/scantoimage.py @@ -0,0 +1,18 @@ +#!/usr/bin/python3 +# $1 = scanner device +# $2 = friendly name + +import sys + +if __name__ == "__main__": + # Open the log file in append mode + with open("/var/log/scanner.log", "a") as log: + # Redirect stdout to the log file + sys.stdout = log + + print("ERROR!") + print("This function is not implemented.") + print("You may implement your own script and mount under $0.") + print( + "Check out scripts in same folder or https://github.com/PhilippMundhenk/BrotherScannerDocker for examples." + ) diff --git a/script/scantoimage.sh b/script/scantoimage.sh deleted file mode 120000 index bfe2ea3..0000000 --- a/script/scantoimage.sh +++ /dev/null @@ -1 +0,0 @@ -scantoimage-0.2.4-1.sh \ No newline at end of file diff --git a/script/scantoocr-0.2.4-1.py b/script/scantoocr-0.2.4-1.py deleted file mode 100755 index faa6508..0000000 --- a/script/scantoocr-0.2.4-1.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/python3 -# $1 = scanner device -# $2 = friendly name - -import sys - -from scanner import read_environment, scan_front - -if __name__ == "__main__": - # Open the log file in append mode - with open("/var/log/scanner.log", "a") as f: - # Redirect stdout to the log file - sys.stdout = f - - read_environment() - - device = sys.argv[1] - scan_front(f, device, ["--mode=True Gray"]) diff --git a/script/scantoocr-0.2.4-1.sh b/script/scantoocr-0.2.4-1.sh deleted file mode 100755 index f918b8c..0000000 --- a/script/scantoocr-0.2.4-1.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# $1 = scanner device -# $2 = friendly name - -SCRIPTPATH="$( - cd "$(dirname "$0")" || exit - pwd -P -)" - -"$SCRIPTPATH"/scantoocr.py $@ diff --git a/script/scantoocr.py b/script/scantoocr.py deleted file mode 120000 index ccdc918..0000000 --- a/script/scantoocr.py +++ /dev/null @@ -1 +0,0 @@ -scantoocr-0.2.4-1.py \ No newline at end of file diff --git a/script/scantoocr.py b/script/scantoocr.py new file mode 100755 index 0000000..d88b4a2 --- /dev/null +++ b/script/scantoocr.py @@ -0,0 +1,18 @@ +#!/usr/bin/python3 +# $1 = scanner device +# $2 = friendly name + +import sys + +from scanner import read_environment, scan_front + +if __name__ == "__main__": + # Open the log file in append mode + with open("/var/log/scanner.log", "a") as log: + # Redirect stdout to the log file + sys.stdout = log + + read_environment() + + device = sys.argv[1] + scan_front(log, device, ["--mode=True Gray"]) diff --git a/script/scantoocr.sh b/script/scantoocr.sh deleted file mode 120000 index 105eb99..0000000 --- a/script/scantoocr.sh +++ /dev/null @@ -1 +0,0 @@ -scantoocr-0.2.4-1.sh \ No newline at end of file