Print(script - auto setup (Linux & Mac) )
Introduction
Are you tired of opening the ThinLinc Client app, uploading your file, choosing the right driver, selecting the printer, printing one document, closing it all down again — and then starting from the top for the next document?
We have written a shell script that puts the institute's printers into the normal print dialog of your
own system. After that it is ⌘P, pick printer, print. Nothing else. No app, no upload, no driver
hunting, no VPN and no terminal.
Prerequisite: the compute-hosting setup. This script builds on the SSH access that
imath-setup.shcreates — see the page imath script. Install that first, then come back here.
These scripts are tested on macOS and Linux devices. The device for Windows is not tested.
How it works
The print server print22.math.uzh.ch lives on the institute's internal network. It is not just
firewalled — it is not even in public DNS. You need to be connected to the UZH Network.
Instead, the script sends your print jobs through the jump host you already have SSH access to:
printer_uzh is a small background service. It does not hold an SSH connection open. It only
listens on the local port 6631; the moment a print job arrives, launchd (macOS) or systemd
(Linux) starts one SSH connection, the job goes through, and the connection closes again. While you
are not printing, nothing is connected — you can check that yourself with --status.
Which networks work: eduroam, the institute WLAN, a cable in the office. From outside UZH you need the UZH VPN, because the jump host itself is only reachable from a UZH network.
1. Installation
chmod +x imath-printers.sh
./imath-printers.sh
It shows you every printer of the institute, numbered, and asks which ones you want:
Printers at the institute (52)
1 g25 2 h06 3 h52
4 j 5 j-ps 6 j04
7 j06 8 j08 9 j10
…
Which ones do you want?
a all of them
1 5 9 by number, separated by spaces
h52 j or simply by name
<Enter> cancel
>
Options:
| Command | Effect |
|---|---|
./imath-printers.sh |
pick printers from the list |
./imath-printers.sh --uninstall |
remove everything it installed |
It is idempotent. Running it again adds what is missing, corrects what has changed, and leaves everything else alone. Add more printers later by simply running it again with their names.
2. Everyday use
There is nothing to learn. The printers are in the print dialog of every program, exactly like a printer at home:
Paper size, duplex, trays and the finishing options are the real ones: the script asks the print server for each printer's own capabilities instead of guessing a driver.
If a job sits in the queue instead of printing, you are simply offline. It goes out by itself as soon as the machine has internet again — no need to print it a second time.
3. Documentation
For transparency — the same reason as on the compute page. This is what the script does, so that nobody has to take "just run this" on faith.
3.1 What it creates
| Where | What |
|---|---|
~/Library/LaunchAgents/printer_uzh.plist (macOS) |
the background service, socket-activated |
~/.config/systemd/user/printer_uzh.socket + printer_uzh@.service (Linux) |
the same thing for systemd |
~/.config/imath/printers.list |
the list of printer queues this script created |
| CUPS queues | one per printer you chose, pointing at ipp://localhost:6631/printers/<name> |
That is all. It writes nothing into your shell configuration, installs no packages, and needs no
sudo — CUPS queues belong to your user account.
~/.config/imath/printers.list is the important one: it is how the script knows which printers are
its own. Printers you added yourself are never touched, not even by --uninstall.
3.2 What the installation does, step by step
- Check the jump host.
ssh -o BatchMode=yes imath true. If that fails, the script stops and tells you to runimath-setup.shfirst. Nothing has been changed at that point. - Clean up an older version. If a previous, hand-made setup is still holding the port under an
old name, that service and its
IMATH-…queues are removed first, so the two do not fight over port 6631. - Read the printer list.
ssh imath "lpstat -h print22.math.uzh.ch -a"— the list comes from the print server itself, over the jump host. No tunnel is needed just to read it. - Ask you which ones you want (or take
--all, or the names you gave on the command line). - Install the service. The service comes before the printers, because it is what gives them the local port to talk to.
- Add the printers:
lpadmin -p <name> -E -v ipp://localhost:6631/printers/<name> -m everywhere.-m everywhereis the part that asks the server for the printer's real capabilities. - Check. It sends an IPP request to
localhost:6631and reports whether the answer came back.
3.3 Where the data comes from
Everything comes from the institute's own print server, nothing is hard-coded:
- the list of printers —
lpstat -h print22.math.uzh.ch -a, run on the jump host - each printer's capabilities (trays, duplex, colour, finishing) — from the printer itself, via
-m everywhere - the status you see in
--status—lpstat -p, i.e. what CUPS on your own machine reports
The only fixed values in the script are the server name print22.math.uzh.ch, the SSH host entry
imath, and the local port 6631.
3.4 What it does not do
- No
sudo, anywhere. - No permanently open connection
- It never touches printers it did not create.
- It does not install a print driver:
-m everywhereis IPP Everywhere, which is built into macOS and Linux. - It sends nothing anywhere except your print jobs, to the institute's own print server.
3.5 Uninstall
./imath-printers.sh --uninstall
Removes exactly the printers listed in ~/.config/imath/printers.list, stops and deletes the
printer_uzh service, and removes its log. Your own printers stay, and your SSH setup from
imath-setup.sh stays as it is.
4. When something does not work
| Symptom | Cause and remedy |
|---|---|
Run imath-setup.sh first |
The SSH access is missing. Install the compute-hosting setup, then run this again. |
| The job waits in the queue | You are offline, or not on a UZH network. Connect to eduroam, or switch on the VPN; the job goes out by itself. |
--status says the tunnel does not answer |
Something else is using port 6631, or the service did not start. Run the script again — it rewrites the service. |
| The printer is there but prints nothing | Check in --status whether the queue is idle or disabled. A disabled queue: cupsenable <name>. |
| A printer is missing from the list | ./imath-printers.sh --list shows everything the institute has; add it by name. |


No comments to display
No comments to display