-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from OS2borgerPC/20-princh-scripts
Use princh-setup to add the printer instead of lpadmin
- Loading branch information
Showing
4 changed files
with
21 additions
and
17 deletions.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,33 @@ | ||
#! /usr/bin/env sh | ||
#!/usr/bin/env sh | ||
|
||
set -ex | ||
|
||
if get_os2borgerpc_config os2_product | grep --quiet kiosk; then | ||
echo "Dette script er ikke designet til at blive anvendt på en kiosk-maskine." | ||
exit 1 | ||
fi | ||
# lpadmin doesn't like spaces | ||
|
||
# CUPS/lpadmin doesn't like spaces | ||
NAME="$(echo "$1" | tr ' ' '_')" | ||
PRINCH_ID="$2" | ||
DESCRIPTION="$3" | ||
SET_STANDARD="$4" | ||
SET_DEFAULT="$4" | ||
|
||
if [ "$SET_DEFAULT" = "True" ]; then | ||
DEFAULT_MAYBE="--default" | ||
fi | ||
|
||
# Delete the printer if a printer already exists by that NAME | ||
lpadmin -x "$NAME" || true | ||
|
||
# No princh-cloud-printer binary in path, so checking for princh-setup | ||
if which princh-setup > /dev/null; then | ||
lpadmin -p "$NAME" -v "princh:$PRINCH_ID" -D "$DESCRIPTION" -E -P /usr/share/ppd/princh/princheu.ppd -L "$DESCRIPTION" | ||
# The two driver options are ISO and US, determining the paper sizes it uses, and specifically whether princheu.ppd (ISO) or princhus.ppd (US) is being used | ||
# shellcheck disable=SC2086 # With quotes around princh_setup gets an explicitly empty argument and fails because of it | ||
princh-setup add --name "$NAME" --device-id "$PRINCH_ID" --driver iso --description "$DESCRIPTION" $DEFAULT_MAYBE | ||
# Finally additionally set the location on the newly added printer | ||
lpadmin -p "$NAME" -L "$DESCRIPTION" | ||
else | ||
echo "Princh is not installed. Please run the script that installs Princh before this one." | ||
exit 1 | ||
fi | ||
|
||
if [ "$SET_STANDARD" = "True" ]; then | ||
# Set the printer as standard printer | ||
lpadmin -d "$NAME" && lpstat -d | ||
fi |
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