Skip to content

Installing the client

Fons van der Plas edited this page Sep 14, 2021 · 17 revisions

This guide covers the installation of the printi client on your Onion Omega2+. First, follow the guide on setting up your Omega from the Onion website. I assume that you can access you Omega via the command line (either via SSH or over serial). Something to note about a serial terminal connection is: you sometimes need to press the RETURN key to see the terminal prompt.

Anything inside a code block is are commands that you need to run on your Omega.

When you connect your omega to power for the first time, it will run its initial OS setup, which takes 2-5 minutes. Wait for the LED to stop blinking before running the commands below.

In case the Onion is not yet connected to your Wi-Fi network:

wifisetup add -ssid "your network name" -encr psk2 -password "your password"
# when running an automated setup:
sleep 30

Update the Onion Omega device firmware:

oupgrade

Change the root password using passwd.

Download dependencies:

opkg update
opkg install git git-http ca-bundle python3 python3-pip

python3 -m pip install requests

You might need to retry these commands when the internet connection is poor.

Download the client:

cd /root
git clone --depth=1 https://github.com/fonsp/printi
mkdir /etc/printi
cp printi/client/PrintiConfigServer/PrintiConfigServer/config.ini /etc/printi/config.ini

A Python script is included that generates a cute name based on the MAC address:

PRINTINAME=$(python3 printi/client/namegenerator.py)
echo "generated name: $PRINTINAME"

Set the initial printi name:

sed -i "s/fonzy/$PRINTINAME/g" /etc/printi/config.ini

(You can change it later using the web interface.)


To disable forwarding internet over the AP (which has the easy to guess password 12345678), remove the entire forwarding section from /etc/config/firewall using this script:

python3 - <<EOF
import re

with open('/etc/config/firewall', 'r') as file :
  filedata = file.read()

filedata = re.sub(r'config forwarding\n(.+\n)+', '', filedata, flags=re.M)

with open('/etc/config/firewall', 'w') as file:
  file.write(filedata)

EOF

(You can also inspect and remove it manually using vim /etc/config/firewall. (How to use vim))

Restart the firewall with:

/etc/init.d/firewall restart

Change the SSID of the AP with:

uci set wireless.ap.ssid=printi-"$PRINTINAME"
uci commit wireless
/etc/init.d/network restart

Remove the built-in uhttpd web server that normally serves the Onion Console and web interface:

rm /etc/init.d/uhttpd

Using df should now show that the 32MB disk is somewhere between 80% and 85% occupied. (We might be able to improve on this by installing requests from source, without pip.)

Configure your Omega to run the client at boot by adding the following lines before exit 0 in /etc/rc.local:

# To be added to /etc/rc.local:
sleep 1
sh /root/printi/client/updateandrun.sh

You can use this script to do so:

python3 - <<EOF
import re

with open('/etc/rc.local', 'r') as file :
  filedata = file.read()

filedata = re.sub(r'exit 0', 'sleep 1\nsh /root/printi/client/updateandrun.sh\n\nexit 0', filedata, flags=re.M)

with open('/etc/rc.local', 'w') as file:
  file.write(filedata)

EOF

Or you can do it manually using vim /etc/rc.local.

The printi client should now be set up!

reboot
Clone this wiki locally