User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
services:scanservjs [2024/08/30 12:52] willyservices:scanservjs [2024/08/30 13:24] (current) – [ScanServJS] willy
Line 1: Line 1:
 ====== ScanServJS ====== ====== ScanServJS ======
  
-[[https://github.com/sbs20/scanservjs|ScanServJS]]+At first i tried to make **saned** work, the great network extension to Sane scan tool for Linux. Unfortunately it turns out that the scanner i own (a MFD HP Laser printer/scanner) cannot be shared with saned over the network because the HP provided driver does not allow itFrankly it seems more an oversight bug than anything else, but still that's an issue, because i do not want to install HP drivers on all my computers just for scanning.
  
-emerge -vp app-arch/deb2targz+Luckly, [[https://github.com/sbs20/scanservjs|ScanServJS]] is very nice, simple and powerful WEB GUI to the sane backend which works wonders and can be self-hosted on your home server.
  
-mkdir /opt/scanservjs +===== Prerequisites =====
-chown saned:scanner /opt/scanservjs+
  
-as user saned+ScanServJs require, of course, sane-backends package to be installed and your scanners to be configured to work locally on the server. I will not cover those steps here, i assume your scanner is already properly configured and can scan with the **saned** user on the server.
  
-sudo -u saned bash +You must install **nodejs** and the **deb2targz** packages, because ScanServJS is deployed as a DEB package and requires NodeJS to run.
-cd /opt/scanservjs+
  
-wget ... https://github.com/sbs20/scanservjs/releases+So, if you don't already have them: 
 +<code bash> 
 +emerge -vp app-arch/deb2targz nodejs 
 +</code>
  
 +Also, you might want to install **tesseract** to enable OCR functionalities.
  
-deb2targz scanservjs_3.0.3-1_all.deb 
  
-tar xvf scanservjs_3.0.3-1_all.tar.xz+===== Installation =====
  
 +You will need to alter a little bit the content of the DEB package, because it's better to install it on **/opt/scanservjs** rather than having it mess with your **/usr** and **/var** system folders, so as root:
 +<code bash>
 +mkdir /opt/scanservjs
 +chown saned:scanner /opt/scanservjs
 +</code>
 +
 +And then now, as user **saned**:
 +<code bash>
 +sudo -u saned bash
 +cd /opt/scanservjs
 +wget https://github.com/sbs20/scanservjs/releases/ << get here latest deb file for your server >>
 +deb2targz scanservjs_X.Y.Z-1_all.deb
 +tar xvf scanservjs_X.Y.Z-1_all.tar.xz
 cd usr/lib/scanservjs cd usr/lib/scanservjs
 +</code>
  
 +Now, since the DEB package assumes it's installed on **/usr** you need to recreate two symlinks:
 +<code bash>
  rm config   rm config 
 ln -s /opt/scanservjs/etc/scanservjs config ln -s /opt/scanservjs/etc/scanservjs config
  rm data   rm data 
 ln -s /opt/scanservjs/var/lib/scanservjs data ln -s /opt/scanservjs/var/lib/scanservjs data
 +</code>
  
-edit etc/scanservjs/config.default.js save as config.local.js +Now move the default config file from **/opt/scanservjs/etc/scanservjs/config.default.js** to **/opt/scanservjs/etc/scanservjs/config.local.js** and edit to resemble the following (adapt where needed): 
-fix path on first line+<file - config.local.js>
 const options = { paths: ['/opt/scanservjs/usr/lib/scanservjs'] }; const options = { paths: ['/opt/scanservjs/usr/lib/scanservjs'] };
     config.host = '127.0.0.1';     config.host = '127.0.0.1';
     config.port = 7781;     config.port = 7781;
-    +    config.scanimage = '/usr/sbin/scanimage'; 
 +    config.convert = '/usr/bin/convert'; 
 +... [ omissis ] ... 
 +</file> 
 + 
 +And that's it!  
 + 
 +===== NGINX configuration ===== 
 + 
 +I choose to install ScanServJS as a sub-path of my **home.mydomain.com**, so this is the relative NGINX config file: 
 +<file - scanner.conf> 
 + 
 +location = /scanner { 
 +        return 301 https://$host/scanner/; 
 +
 + 
 +# Interfaccia Web stmapante HP 
 +location /scanner/ { 
 +        proxy_pass http://10.70.43.1:7781/; 
 +
 +</file> 
 + 
 +For more details, see [[selfhost:nginx|The Reverse Proxy concept]] 
 + 
 +And restart your NGINX service. 
 + 
 + 
 +===== Start and Autostart ===== 
 + 
 +Since i use OpenRC, just drop the following **/etc/init.d/scanservjs**: 
 +<file - scanservjs> 
 +#!/sbin/openrc-run 
 +# Copyright 1999-2021 Gentoo Authors 
 +# Distributed under the terms of the GNU General Public License v2 
 + 
 +description="SCan from web interface" 
 +pidfile="/run/scanservjs.pid" 
 +command_background=true 
 +command="node /opt/scanservjs/usr/lib/scanservjs/server/server.js " 
 +command_args="" 
 +command_user="saned:scanner" 
 + 
 +depend() { 
 +        need net 
 +
 + 
 +start_pre() 
 +
 +        cd /opt/scanservjs/usr/lib/scanservjs 
 +        export NODE_ENV=production 
 +
 +</file> 
 + 
 +make it executable and add it to the default runlevel: 
 +<code bash> 
 +chmod +x /etc/init.d/scanservjs 
 +rc-update add /etc/init.d/scanservjs default 
 + /etc/init.d/scanservjs start 
 +</code> 
 + 
 + 
 +===== Update =====
  
-node /opt/scanservjs/usr/lib/scanservjs/server/server.js +Get new DEB, replace files, restart!
  
  

This website uses technical cookies only. No information is shared with anybody or used in any way but provide the website in your browser.

More information