-
Notifications
You must be signed in to change notification settings - Fork 5
printer_install_macos.sh
Installs network printers on macOS using CUPS/lpadmin with support for local or remote PPD driver files.
This script automates network printer deployment on macOS systems using CUPS. It supports multiple printers, can download PPD files from URLs or use local files, optionally installs full driver packages, and configures printers with appropriate security settings.
Provides standardized printer deployment for managed macOS workstations, supporting both local PPD files and remote driver downloads for flexible deployment scenarios.
- Operating System: macOS 10.12 or later
- Privileges: Root/sudo privileges required
- Network: Access to printer hosts and PPD/driver URLs (if using URL source)
- Driver File: PPD file for printer model (local or URL)
Edit these variables in the script before running:
PRINTERS Array:
PRINTERS=(
"printer1.example.com|Main Office|Office Printer"
"printer2.example.com|Sales Dept|Sales Printer"
)Format: "hostname|location|display_name"
- If display_name is empty, hostname prefix will be used
PROTOCOL: Connection protocol
- Options:
lpd,ipp,ipps - Default:
lpd
PPD_SOURCE: Source of PPD file
- Options:
localorurl - Default:
local
PPD_PATH: Path to local PPD file (if PPD_SOURCE="local")
- Example:
/Library/Printers/PPDs/Contents/Resources/YourPrinter.ppd.gz - Supports
.ppdor.ppd.gzfiles
PPD_URL: URL to download PPD file (if PPD_SOURCE="url")
- Example:
https://example.com/drivers/printer.ppd
DRIVER_URL: Optional URL for full driver package
- Leave empty if using generic PPD or driver already installed
- Supports ZIP format, extracts to
/Library/Printers/
- Root Check: Verifies script is run with sudo privileges
- Configuration Display: Shows protocol, PPD source, and printer count
-
Driver Download (optional):
- Downloads driver package from DRIVER_URL if specified
- Extracts to
/Library/Printers/ - Installs driver components
-
PPD Setup:
-
URL Source: Downloads PPD from PPD_URL to
/Library/Printers/PPDs/Contents/Resources/ - Local Source: Verifies PPD_PATH exists
- Sets appropriate ownership (root:wheel) and permissions (644)
-
URL Source: Downloads PPD from PPD_URL to
-
Printer Installation Loop:
- For each printer in PRINTERS array:
- Removes existing printer with same name
- Builds URI based on protocol (lpd, ipp, or ipps)
- Creates printer using lpadmin
- Sets location and display name
- Configures printer-is-shared=false
- Sets error-policy to abort-job
- Enables printer
- Verifies installation with lpstat
- For each printer in PRINTERS array:
-
Results Display:
- Shows success/failure count
- Displays final status
The script exits immediately on critical errors due to set -euo pipefail.
- Requires root privileges for printer configuration
- Printer sharing disabled by default (printer-is-shared=false)
- Downloads over HTTPS for secure driver/PPD retrieval
- PPD files installed with restricted permissions (root:wheel, 644)
- No credentials stored in printer configuration
- Error policy set to abort-job (prevents print queue pile-up on errors)
- 0: All printers installed successfully
-
1: Installation failed:
- Script not run as root
- Driver download failed
- PPD file not found (local) or download failed (URL)
- Invalid PPD_SOURCE value
- All printer installations failed
Note: Partial success (some printers installed) returns exit code 1.
[ NETWORK PRINTER INSTALL - macOS ]
--------------------------------------------------------------
Protocol : lpd
PPD Source : local
Printers : 2
[ SETTING UP PPD ]
--------------------------------------------------------------
Using local PPD: /Library/Printers/PPDs/Contents/Resources/Generic.ppd.gz
[ INSTALLING PRINTERS ]
--------------------------------------------------------------
Installing: Office Printer
Hostname : printer1.example.com
Location : Main Office
Name : Office_Printer
Status : SUCCESS
Installing: Sales Printer
Hostname : printer2.example.com
Location : Sales Dept
Name : Sales_Printer
Status : SUCCESS
[ FINAL STATUS ]
--------------------------------------------------------------
Installed : 2 printer(s)
Failed : 0 printer(s)
Result : SUCCESS
[ SCRIPT COMPLETED ]
--------------------------------------------------------------
-
v1.0.0: Initial release
- Multi-printer support
- Local and remote PPD support
- Optional full driver package installation
- Protocol selection (lpd, ipp, ipps)
- Automatic printer name generation from hostname
- Security-focused default settings
- Installation verification
- View Script Source
- Scripts - Back to script index