diff --git a/Dockerfile b/Dockerfile index e57512d..622f4d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,21 @@ FROM ubuntu:16.04 RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get update && apt-get -y install tzdata && apt-get -y clean RUN apt-get -y update && apt-get -y upgrade && apt-get -y clean -RUN apt-get -y install sane sane-utils ghostscript netpbm x11-common- wget graphicsmagick curl ssh sshpass && apt-get -y clean +RUN apt-get -y install \ + sane \ + sane-utils \ + ghostscript \ + netpbm \ + x11-common \ + wget \ + graphicsmagick \ + curl \ + ssh \ + sshpass \ + lighttpd \ + php-cgi \ + php-curl \ + && apt-get -y clean RUN cd /tmp && \ wget https://download.brother.com/welcome/dlf105200/brscan4-0.4.11-1.amd64.deb && \ @@ -18,6 +32,13 @@ RUN cd /tmp && \ ADD files/runScanner.sh /opt/brother/runScanner.sh COPY script /opt/brother/scanner/brscan-skey/script +RUN cp /etc/lighttpd/conf-available/05-auth.conf /etc/lighttpd/conf-enabled/ +RUN cp /etc/lighttpd/conf-available/15-fastcgi-php.conf /etc/lighttpd/conf-enabled/ +RUN cp /etc/lighttpd/conf-available/10-fastcgi.conf /etc/lighttpd/conf-enabled/ +RUN mkdir -p /var/run/lighttpd +RUN touch /var/run/lighttpd/php-fastcgi.socket +RUN chown -R www-data /var/run/lighttpd + ENV NAME="Scanner" ENV MODEL="MFC-L2700DW" ENV IPADDRESS="192.168.1.123" @@ -38,6 +59,12 @@ ENV FTP_PATH="/scans/" EXPOSE 54925 EXPOSE 54921 +EXPOSE 80 + +ADD files/gui/index.php /var/www/html +ADD files/gui/main.css /var/www/html +ADD files/api/scan.php /var/www/html +RUN chown -R www-data /var/www/ #directory for scans: VOLUME /scans diff --git a/files/api/scan.php b/files/api/scan.php new file mode 100644 index 0000000..f6e900e --- /dev/null +++ b/files/api/scan.php @@ -0,0 +1,25 @@ +"); +} +if (in_array($target, array('file','email','image','ocr'))) { + $output = shell_exec('/opt/brother/scanner/brscan-skey/script/scanto'.$target.'.sh'); +} +else +{ + header($_SERVER["SERVER_PROTOCOL"] . " 400 OK"); + die("Error: Thou shalt not inject unknown script names!"); +} + +header($_SERVER["SERVER_PROTOCOL"] . " 200 OK"); +header("Cache-Control: public"); // needed for internet explorer +header("Content-Type: text/plain"); +die($output); + +?> \ No newline at end of file diff --git a/files/gui/index.php b/files/gui/index.php new file mode 100644 index 0000000..3e53e97 --- /dev/null +++ b/files/gui/index.php @@ -0,0 +1,49 @@ + + + + +Brother Scanner + + + + +
+
Brother Scanner
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + diff --git a/files/gui/main.css b/files/gui/main.css new file mode 100644 index 0000000..6f55eeb --- /dev/null +++ b/files/gui/main.css @@ -0,0 +1,136 @@ +#based on https://codepen.io/ainalem/pen/GRqPwoz + +body { + align-items: center; + background-color: #000; + display: flex; + justify-content: center; + height: 100vh; +} + +.form { + background-color: #15172b; + border-radius: 20px; + box-sizing: border-box; +# height: 550px; +# height: 100%; + padding: 20px; +# width: 320px; +} + +.title { + color: #eee; + font-family: sans-serif; + font-size: 36px; + font-weight: 600; + margin-top: 30px; +} + +.subtitle { + color: #eee; + font-family: sans-serif; + font-size: 16px; + font-weight: 600; + margin-top: 10px; +} + +.input-container { + height: 50px; + position: relative; + width: 100%; +} + +.ic1 { + margin-top: 30px; +} + +.ic2 { + margin-top: 30px; +} + +.ic3 { + margin-top: 30px; + height: auto; +} + +.input { + background-color: #303245; + border-radius: 12px; + border: 0; + box-sizing: border-box; + color: #eee; + font-size: 18px; + height: 100%; + outline: 0; + padding: 4px 20px 0; + width: 100%; +} + +.cut { + background-color: #15172b; + border-radius: 10px; + height: 20px; + left: 20px; + position: absolute; + top: -20px; + transform: translateY(0); + transition: transform 200ms; + width: 76px; +} + +.cut-short { + width: 50px; +} + +.cut-long { + width: 100px; +} + +.input:focus ~ .cut, +.input:not(:placeholder-shown) ~ .cut { + transform: translateY(8px); +} + +.placeholder { + color: #65657b; + font-family: sans-serif; + left: 20px; + line-height: 14px; + pointer-events: none; + position: absolute; + transform-origin: 0 50%; + transition: transform 200ms, color 200ms; + top: 20px; +} + +.input:focus ~ .placeholder, +.input:not(:placeholder-shown) ~ .placeholder { + transform: translateY(-30px) translateX(10px) scale(0.75); +} + +.input:not(:placeholder-shown) ~ .placeholder { + color: #808097; +} + +.input:focus ~ .placeholder { + color: #dc2f55; +} + +.submit { + background-color: #08d; + border-radius: 12px; + border: 0; + box-sizing: border-box; + color: #eee; + cursor: pointer; + font-size: 18px; + height: 50px; + margin-top: 30px; + // outline: 0; + text-align: center; + width: 100%; +} + +.submit:active { + background-color: #06b; +} diff --git a/files/runScanner.sh b/files/runScanner.sh index 7fad9c3..0da5520 100755 --- a/files/runScanner.sh +++ b/files/runScanner.sh @@ -16,6 +16,15 @@ chmod -R 777 /opt/brother su - $USERNAME -c "/usr/bin/brsaneconfig4 -a name=$NAME model=$MODEL ip=$IPADDRESS" su - $USERNAME -c "/usr/bin/brscan-skey" +echo "starting webserver for API & GUI..." +if [[ -z ${PORT} ]]; then + PORT=80 +fi +echo "running on port $PORT" +sed 's/server.port\W*= 80/server.port = $PORT/' /etc/lighttpd/lighttpd.conf +/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf +echo "webserver started" + echo "capabilities:" scanimage -A