diff --git a/printer_princh_add.md b/printer_princh_add.md index 770761a..1ba2ef8 100644 --- a/printer_princh_add.md +++ b/printer_princh_add.md @@ -1,8 +1,8 @@ --- title: "Tilføj Princh Cloud Printer" -version: 1 +version: 2 parent: "Printer" -source: scripts/printer_options_set.sh +source: scripts/printer_princh_add.sh parameters: - name: "Navn (OBS: INGEN ÆØÅ, mellemrum eller apostrofer)" type: "string" diff --git a/printer_princh_install.md b/printer_princh_install.md index b89ad72..e44e334 100644 --- a/printer_princh_install.md +++ b/printer_princh_install.md @@ -1,6 +1,6 @@ --- title: "Installer Princh Cloud Printer" -version: 1 +version: 2 parent: "Printer" source: scripts/printer_princh_install.sh parameters: diff --git a/scripts/printer_princh_add.sh b/scripts/printer_princh_add.sh old mode 100755 new mode 100644 index 6ecbead..06f29fb --- a/scripts/printer_princh_add.sh +++ b/scripts/printer_princh_add.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env sh +#!/usr/bin/env sh set -ex @@ -6,24 +6,28 @@ 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 diff --git a/scripts/printer_princh_install.sh b/scripts/printer_princh_install.sh index 2a92801..4692792 100644 --- a/scripts/printer_princh_install.sh +++ b/scripts/printer_princh_install.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env sh +#!/usr/bin/env sh set -ex @@ -29,15 +29,15 @@ if [ "$PRINCH_VERSION_AVAILABLE" != "$PRINCH_VERSION_INSTALLED" ]; then # predictable for the command to install it below curl $URL --output $FILE dpkg --install $FILE - + rm $FILE else printf '%s\n' "Princh is already installed and in the most recent version." fi # Create Princh autostart -princh_autostart_dir=/home/.skjult/.config/autostart +PRINCH_AUTOSTART_DIR=/home/.skjult/.config/autostart -mkdir --parents $princh_autostart_dir +mkdir --parents $PRINCH_AUTOSTART_DIR # This will fail if the symlink already exists, but the exit status is still 0 so no problem -ln -sf /usr/share/applications/com-princh-print-daemon.desktop $princh_autostart_dir +ln -sf /usr/share/applications/com-princh-print-daemon.desktop $PRINCH_AUTOSTART_DIR