This repository was archived by the owner on May 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 98
Updated guide to use cupsctl
#251
Open
rabbitt
wants to merge
3
commits into
sunknudsen:master
Choose a base branch
from
rabbitt:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
you can use
grep -q
here to silence the output from grep, and rely on the status code returned depending on whether the search term was found or not, and avoid having to redirect stdout/stderr, e.g.:Also, if you wanted, you could also simplify that down to a single line:
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.
Using
grep
’s--quiet
flag is much cleaner, thanks!Elegant one-liner… that said,
if
andthen
might be more literal for people getting started with command line (I try to use long form when possible in guides hence using--quiet
vs-q
flag.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.
Is regular expression necessary given config is generated programatically by
cupsctl
?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.
Probably not, I'm just paranoid 😳 lol
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.
Btw, love how thorough you are. 🤓
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.
Does
lpstat -W completed -o
purge job files from/var/spool/cups
? Btw, not too worried about usingcancel -a -x
in this specific use case, but definitively worth considering.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.
It does, and it does it according to your settings (e.g., "PreserveJobXXX" and MaxJobTime). Also, with the
-W completed
flag, it only cleans up completed jobs, and not active jobs.Sure, I'm just thinking that people tend to blindly run commands without researching them, so I figure using
lpstat
is safer as it doesn't kill jobs that are actively printing or stuck, only jobs that have actually completed. Maybe include both commands and explain the difference between the two (i.e.,cancel
blindly purges everything, vslpstat -W completed -o
just purges completed jobs).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.
Thanks for feedback… would you happen to have ideas to limit
cupsctl
calls while preserving command intelligibility for people who are just getting started (ideally, one command to get current state and one to update config if need be)?My (perhaps naive) understanding is that, if above is implemented, config would be updated 3 times which would also reload CUPS same amount of times.
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.
Here's a more thorough rewrite that is idempotent, logs changes to syslog, and only calls out to cupsctl at most once:
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.
Hey @sunknudsen - I'm sure you've been pretty busy, especially with holidays just past us. Wanted to follow up on this request and see if there's any thoughts on moving forward with the discussion and changes ?