Skip to content

Commit 8e3d3e2

Browse files
committed
script/_ceremony: insert SN for detected printer into printers.conf
This works in coordination w/ the placeholder for the SN that's setup by OKOS.
1 parent 9166ed9 commit 8e3d3e2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

script/_ceremony

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ set -eou pipefail
44

55
. oks-lib.sh
66

7+
command_on_path lpinfo
8+
command_on_path systemctl
9+
command_on_path sed
10+
command_on_path oks
11+
12+
# NixOS generates `printers.conf` for us but we can't know the printers SN in
13+
# advance of the first ceremony where it's used. As a work-around we query cups
14+
# for the serial number for the attached printer and then swap it in
15+
# `printers.conf` with the place holder `SN_GOES_HERE`
16+
PRINTER_SN_REGEX='^direct[[:space:]]\+usb:\/\/Brother\/QL-600?serial=\(.*\)$'
17+
PRINTER_SN=$(lpinfo -v | sed -n "s/$PRINTER_SN_REGEX/\1/p")
18+
info "Label printer with SN: $PRINTER_SN found"
19+
20+
systemctl stop cups.service
21+
sed -i "s/SN_GOES_HERE/$PRINTER_SN/g" /etc/cups/printers.conf
22+
systemctl start cups.service
23+
info "Label printer with SN: $PRINTER_SN configured"
24+
725
while read -rsp "Enter password: " OKS_PASSWORD; do
826
export OKS_PASSWORD
927

0 commit comments

Comments
 (0)