diff --git a/files/runScanner.sh b/files/runScanner.sh index 0d0047b..f3cc75c 100755 --- a/files/runScanner.sh +++ b/files/runScanner.sh @@ -1,4 +1,5 @@ #!/bin/bash +echo "setting up user & logfile:" if [[ -z ${UID} ]]; then UID=1000 fi @@ -13,15 +14,40 @@ touch /var/log/scanner.log chown $USERNAME /var/log/scanner.log env > /opt/brother/scanner/env.txt chmod -R 777 /opt/brother +echo "-----" +echo "setting up interface:" subnet=$(echo $IPADDRESS | sed 's/\([0-9]*\.[0-9]*\.\)[0-9]*\.[0-9]*/\1/') interface=$(ip addr show | grep -B10 $subnet | grep mtu | tail -1 | sed 's/[0-9]*: \(.*\): .*/\1/') +sed -i 's/^eth=.*//' /opt/brother/scanner/brscan-skey/brscan-skey.config +# if found an interface for scanner subnet. Will use this to contact scanner. +if [[ -z "$interface" ]]; then + # if scanner subnet (roughly) not found in interfaces, assuming network_mode="host" is not set and using Docker default interface. + interface="eth0" +fi echo "eth=$interface" >> /opt/brother/scanner/brscan-skey/brscan-skey.config echo "using interface: $interface" +echo "-----" + +echo "setting up host IP:" +sed -i 's/^ip_address=.*//' /opt/brother/scanner/brscan-skey/brscan-skey.config +if [[ -z "$HOST_IPADDRESS" ]] + echo "no host IP configured, using default discovery" +else + echo "ip_address=$HOST_IPADDRESS" >> /opt/brother/scanner/brscan-skey/brscan-skey.config +fi +echo "-----" + +echo "whole config:" +cat /opt/brother/scanner/brscan-skey/brscan-skey.config +echo "-----" +echo "setting up scanner:" su - $USERNAME -c "/usr/bin/brsaneconfig4 -a name=$NAME model=$MODEL ip=$IPADDRESS" su - $USERNAME -c "/usr/bin/brscan-skey" +echo "-----" +echo "setting up webserver:" if [ "$WEBSERVER" == "true" ]; then echo "starting webserver for API & GUI..." { @@ -63,7 +89,10 @@ if [ "$WEBSERVER" == "true" ]; then sed -i "s/server.port\W*= 80/server.port = $PORT/" /etc/lighttpd/lighttpd.conf /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf echo "webserver started" +else + echo "webserver not configured" fi +echo "-----" echo "capabilities:" scanimage -A