Skip to content

Commit

Permalink
added HOST_IPADDRESS setting
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippMundhenk committed Nov 2, 2023
1 parent e9c760e commit a15b9fa
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions files/runScanner.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
echo "setting up user & logfile:"
if [[ -z ${UID} ]]; then
UID=1000
fi
Expand All @@ -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..."
{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a15b9fa

Please sign in to comment.