-
Notifications
You must be signed in to change notification settings - Fork 0
Add setup script and README for Brother HL-L1222-V Android IPP print server on Raspberry Pi (openSUSE) #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,30 @@ | ||
| ```codex_answers | ||
| <!-- placeholder for codex's responses textual data --> | ||
| # Brother HL-L1222-V Android Print Server (Raspberry Pi 4B+ / openSUSE Tumbleweed) | ||
|
|
||
| This repository now provides an executable setup script that configures a Raspberry Pi 4B+ (openSUSE Tumbleweed) as a print server for a USB-connected Brother HL-L1222/HL-L1222-V. | ||
|
|
||
| ## What this enables | ||
| - Android phones on the **same Wi-Fi network** can print through IPP (Mopria-compatible workflow). | ||
| - USB Brother printer is shared by CUPS over the local network. | ||
| - Firewall and discovery services are configured for LAN printing. | ||
|
|
||
| ## Important Bluetooth note | ||
| Android-to-Raspberry-Pi Bluetooth printing into CUPS is generally not reliable/supported in modern Android/CUPS workflows. The script still enables Bluetooth service for optional experimentation, but the production path is **Wi-Fi IPP**. | ||
|
|
||
| ## Script | ||
| - `scripts/setup_hl_l1222_android_print.sh` | ||
|
|
||
| ## Run | ||
| ```bash | ||
| sudo bash scripts/setup_hl_l1222_android_print.sh | ||
| ``` | ||
|
|
||
| ## After script completes | ||
| 1. Keep printer connected via USB to Raspberry Pi. | ||
| 2. Connect Android phone to same Wi-Fi as Raspberry Pi. | ||
| 3. Enable Mopria Print Service (or equivalent Android print service). | ||
| 4. Add printer with: | ||
| - `ipp://<raspberrypi-ip>/printers/Brother_HL_L1222_V` | ||
|
|
||
| ## Notes | ||
| - Script uses CUPS `everywhere` model as default for broad compatibility. | ||
| - If you have an official Brother HL-L1222-V Linux PPD/driver package, install it and adjust queue model if desired. | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,118 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Setup script: Brother HL-L1222(-V) USB printer on openSUSE Tumbleweed (Raspberry Pi) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Goal: receive print jobs from Android phones over the same Wi-Fi (IPP/Mopria) via CUPS. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Note: Bluetooth printing from Android to CUPS is generally unsupported/restricted; script enables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # practical network printing path and optional USB OTG fallback guidance. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PRINTER_NAME="Brother_HL_L1222_V" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PPD_MODEL="everywhere" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ ${EUID} -ne 0 ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Please run as root: sudo bash $0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| REQ_CMDS=(zypper systemctl lpinfo lpadmin lpstat) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Preflight checks require CUPS commands before CUPS is installed, so the script can fail immediately on fresh systems. Prompt for AI agents
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for c in "${REQ_CMDS[@]}"; do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| command -v "$c" >/dev/null || { echo "Missing command: $c"; exit 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+17
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The script checks for Useful? React with 👍 / 👎. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+17
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 CUPS commands (lpinfo, lpadmin, lpstat) are checked before CUPS is installed, blocking fresh installs Lines 17-19 check that
Suggested change
Was this helpful? React with 👍 or 👎 to provide feedback. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "[1/8] Installing print/network discovery stack..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| zypper --non-interactive refresh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| zypper --non-interactive install \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cups cups-filters ghostscript avahi nss-mdns \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| firewalld ipp-usb bluez bluez-tools | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "[2/8] Enabling required services..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| systemctl enable --now cups.service | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| systemctl enable --now avahi-daemon.service | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| systemctl enable --now firewalld.service | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| systemctl enable --now bluetooth.service | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Ensure cupsd listens on local network for Android clients using IPP/Mopria. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CUPSD_CONF="/etc/cups/cupsd.conf" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ! grep -q '^Port 631' "$CUPSD_CONF"; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sed -i 's/^Listen localhost:631/# &/' "$CUPSD_CONF" || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo 'Port 631' >> "$CUPSD_CONF" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ! grep -q '^Browsing Yes' "$CUPSD_CONF"; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo 'Browsing Yes' >> "$CUPSD_CONF" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ! grep -q '^DefaultShared Yes' "$CUPSD_CONF"; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo 'DefaultShared Yes' >> "$CUPSD_CONF" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ! grep -q '^WebInterface Yes' "$CUPSD_CONF"; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo 'WebInterface Yes' >> "$CUPSD_CONF" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+36
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Appending directives to cupsd.conf creates ordering issues Lines 36-51 append Was this helpful? React with 👍 or 👎 to provide feedback. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ! grep -q '<Location />' "$CUPSD_CONF"; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Logic error: Additionally, the Consider using Prompt for AI agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cat >> "$CUPSD_CONF" <<'CUPSLOC' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Location /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Order allow,deny | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Allow @LOCAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Location> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Location /admin> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Order allow,deny | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Allow @LOCAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Location> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CUPSLOC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+34
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The manual modification of
Using
Suggested change
Comment on lines
+53
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 guard skips adding Allow @Local when default CUPS block already exists Line 53 checks whether Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "[3/8] Opening firewall for IPP + mDNS..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| firewall-cmd --permanent --add-service=ipp || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Do not swallow firewall command failures; this can produce a false successful setup with broken network printing. Prompt for AI agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| firewall-cmd --permanent --add-service=mdns || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| firewall-cmd --reload || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "[4/8] Detecting USB printer URI..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+67
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (bug_risk): Avoid fully swallowing firewall-cmd failures or at least surface them to the user. Using
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| USB_URI="$(lpinfo -v | awk '/^direct usb:\/\/Brother\//{print $2; exit}')" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚩 ipp-usb package may conflict with direct USB backend for printer detection The script installs Was this helpful? React with 👍 or 👎 to provide feedback. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ -z "$USB_URI" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "No Brother USB URI auto-detected. Available devices:" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lpinfo -v | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Connect the printer via USB and re-run this script." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Detected URI: $USB_URI" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "[5/8] Creating/updating CUPS queue..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if lpstat -p "$PRINTER_NAME" >/dev/null 2>&1; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lpadmin -x "$PRINTER_NAME" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lpadmin -p "$PRINTER_NAME" -E -v "$USB_URI" -m "$PPD_MODEL" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The queue is created with Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P0: The Since Prompt for AI agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lpoptions -d "$PRINTER_NAME" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Disable duplex (hardware lacks automatic duplex) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lpadmin -p "$PRINTER_NAME" -o sides=one-sided -o media=A4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Enable sharing explicitly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lpadmin -p "$PRINTER_NAME" -o printer-is-shared=true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "[6/8] Restarting CUPS..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| systemctl restart cups.service | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "[7/8] Printing a test page..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lp -d "$PRINTER_NAME" /usr/share/cups/data/testprint || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+97
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Test print may silently fail due to CUPS restart timing At line 97, CUPS is restarted with Was this helpful? React with 👍 or 👎 to provide feedback. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "[8/8] Final status" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lpstat -t | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: lpstat -t at end of script can abort under set -e if CUPS is still restarting Line 103 runs Was this helpful? React with 👍 or 👎 to provide feedback. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| IP_ADDR="$(hostname -I | awk '{print $1}')" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cat <<MSG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Setup complete. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Android printing method (recommended): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1) Connect phone to same Wi-Fi as Raspberry Pi. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2) Ensure Mopria Print Service is enabled on Android. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3) Add/find printer: ipp://$IP_ADDR/printers/$PRINTER_NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bluetooth note: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Direct Android->CUPS Bluetooth printing is typically not supported on modern Android/CUPS stacks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Use Wi-Fi IPP/Mopria path above, or USB-OTG direct phone-to-printer where supported by phone/app. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MSG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick (typo): Consider adding an article: "as the default" for smoother grammar.
Suggestion: "Script uses CUPS
everywheremodel as the default for broad compatibility."