From b45b46c5aa5bcfa0165e9bb149872918d7f70dbd Mon Sep 17 00:00:00 2001 From: Sampsa Laapotti Date: Wed, 23 Oct 2019 21:53:31 +0300 Subject: [PATCH 01/10] Add installation script to facillitate installation --- remarkable-cups/install.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 remarkable-cups/install.sh diff --git a/remarkable-cups/install.sh b/remarkable-cups/install.sh new file mode 100755 index 0000000..b1022bd --- /dev/null +++ b/remarkable-cups/install.sh @@ -0,0 +1,21 @@ +! /usr/bin/env bash + +# Set bash to stop execution on failed commands. For sanity and safety +set -e + +echo "Adding Unofficial remarkable printing driver" + +# Compile ppd driver & copy to somewhere where CUPS can find it. +ppdc remarkable.drv; sudo cp ppd/remarkable.ppd /usr/share/cups/model/ + +# Copy & rename CUPS backend script +sudo cp remarkable.sh /usr/lib/cups/backend/remarkable + +# Secure permissions +sudo chown root:root /usr/lib/cups/backend/remarkable +sudo chmod 700 /usr/lib/cups/backend/remarkable + +# Add/Update "Remarkable" cups printer +sudo lpadmin -L 'Cloud Printer' -D 'my remarkable' -p "reMarkable" -E -v 'remarkable:/Print' + +echo "All done ׋, happy printing! " From 4f0167e5a9d29a6ec1534f8d662ab45cba33b137 Mon Sep 17 00:00:00 2001 From: Sampsa Laapotti Date: Wed, 23 Oct 2019 22:04:58 +0300 Subject: [PATCH 02/10] Fixup utf-8 --- remarkable-cups/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remarkable-cups/install.sh b/remarkable-cups/install.sh index b1022bd..aa8bf8a 100755 --- a/remarkable-cups/install.sh +++ b/remarkable-cups/install.sh @@ -18,4 +18,4 @@ sudo chmod 700 /usr/lib/cups/backend/remarkable # Add/Update "Remarkable" cups printer sudo lpadmin -L 'Cloud Printer' -D 'my remarkable' -p "reMarkable" -E -v 'remarkable:/Print' -echo "All done ׋, happy printing! " +echo "All done ✓, happy printing! " From 8289ff817d1d2b1ac62e3d35ce77a4e9aa8122cc Mon Sep 17 00:00:00 2001 From: Sampsa Laapotti Date: Thu, 24 Oct 2019 15:24:16 +0300 Subject: [PATCH 03/10] Fix shebang in install script --- remarkable-cups/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remarkable-cups/install.sh b/remarkable-cups/install.sh index aa8bf8a..5a6e158 100755 --- a/remarkable-cups/install.sh +++ b/remarkable-cups/install.sh @@ -1,4 +1,4 @@ -! /usr/bin/env bash +#! /usr/bin/env bash # Set bash to stop execution on failed commands. For sanity and safety set -e From 37cd4ef7fb7e04bf0ac8a80fe48c33fb580ba2ff Mon Sep 17 00:00:00 2001 From: Sampsa Laapotti Date: Wed, 12 Feb 2020 00:30:47 +0200 Subject: [PATCH 04/10] Add credentials installation to the script --- remarkable-cups/install.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/remarkable-cups/install.sh b/remarkable-cups/install.sh index 5a6e158..42466a2 100755 --- a/remarkable-cups/install.sh +++ b/remarkable-cups/install.sh @@ -18,4 +18,19 @@ sudo chmod 700 /usr/lib/cups/backend/remarkable # Add/Update "Remarkable" cups printer sudo lpadmin -L 'Cloud Printer' -D 'my remarkable' -p "reMarkable" -E -v 'remarkable:/Print' +# Copy user credentials for printer driver user home +FILE=~/.rmapi +if [ -f "$FILE" ]; then + echo "Installing credentials for cups user (root in debian)" + sudo cp $FILE /root/ +else + echo "$FILE does not exist, please authenticate with .rmapi file" +fi + +echo "Do you want to print a test page? (y/n)" + +cowsay "Howdy there! Hopefully this printer works! Cheers to RMS!" |pandoc -o /tmp/test.pdf + +lp -d reMarkable /tmp/test.pdf + echo "All done ✓, happy printing! " From df024ac831e144d0bd0a04e4eee7ad526ab56a53 Mon Sep 17 00:00:00 2001 From: Sampsa Laapotti Date: Wed, 12 Feb 2020 00:31:34 +0200 Subject: [PATCH 05/10] Fix whitespace --- remarkable-cups/remarkable.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remarkable-cups/remarkable.sh b/remarkable-cups/remarkable.sh index 2dd7248..d275836 100755 --- a/remarkable-cups/remarkable.sh +++ b/remarkable-cups/remarkable.sh @@ -30,7 +30,7 @@ case ${#} in fi rm ${outname} ;; - + 6) cat ${6} > ${outname} if [ ! -e ${DEVICE_URI#remarkable:} ]; then From f1800f52bdf62d2b74bf4c93f3a0b514fba9d8f2 Mon Sep 17 00:00:00 2001 From: Sampsa Laapotti Date: Wed, 12 Feb 2020 00:37:28 +0200 Subject: [PATCH 06/10] Fix test printing feature --- remarkable-cups/install.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/remarkable-cups/install.sh b/remarkable-cups/install.sh index 42466a2..95c9063 100755 --- a/remarkable-cups/install.sh +++ b/remarkable-cups/install.sh @@ -27,10 +27,12 @@ else echo "$FILE does not exist, please authenticate with .rmapi file" fi -echo "Do you want to print a test page? (y/n)" +echo "Do you want to print a test page?" +read -p 'test page? (y/N): ' tp -cowsay "Howdy there! Hopefully this printer works! Cheers to RMS!" |pandoc -o /tmp/test.pdf - -lp -d reMarkable /tmp/test.pdf +if [ "$tp" = "y" ]; then + cowsay "Howdy there! Hopefully this printer works! Cheers to RMS!" |pandoc -o /tmp/test.pdf + lp -d reMarkable /tmp/test.pdf +fi echo "All done ✓, happy printing! " From 594e28c328ac2718d2f8fcd49459a4c48261903c Mon Sep 17 00:00:00 2001 From: Sampsa Laapotti Date: Wed, 12 Feb 2020 01:06:05 +0200 Subject: [PATCH 07/10] Add rudimentary rmapi binary finder * Assume user has setup rmapi to her path --- remarkable-cups/install.sh | 13 +++++++++++++ remarkable-cups/remarkable.sh | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/remarkable-cups/install.sh b/remarkable-cups/install.sh index 95c9063..b203303 100755 --- a/remarkable-cups/install.sh +++ b/remarkable-cups/install.sh @@ -8,6 +8,19 @@ echo "Adding Unofficial remarkable printing driver" # Compile ppd driver & copy to somewhere where CUPS can find it. ppdc remarkable.drv; sudo cp ppd/remarkable.ppd /usr/share/cups/model/ +# Find rmapi binary +RMAPI=$(which rmapi) +if [ -f $RMAPI ]; then + # Escape all '/' from rmapi path in order to use sed later + RMAPI=$(echo $RMAPI|sed 's/\//\\\//g') + # Replace original rmapi-location from rmapi.sh + template='s/#TEMPLATED_BY_INSTALL/rmapi='$RMAPI'/' + sed -i $template remarkable.sh +fi + +# TODO Copy rmapi binary to print user (root) +# TODO Get rid of root user, use some lower privileged user for printing + # Copy & rename CUPS backend script sudo cp remarkable.sh /usr/lib/cups/backend/remarkable diff --git a/remarkable-cups/remarkable.sh b/remarkable-cups/remarkable.sh index d275836..13eee79 100755 --- a/remarkable-cups/remarkable.sh +++ b/remarkable-cups/remarkable.sh @@ -7,8 +7,13 @@ jobcopies=${4} joboptions=${5} jobfile=${6} +#Default value if templating does not find tha binary rmapi=/home/mark/gosrc/bin/rmapi +#### Installation script will template a new path for rmapi-binary +#TEMPLATED_BY_INSTALL +#### End of templating + printtime=$(date +%Y-%b-%d-%H-%M) sanitized_jobtitle="$(echo ${jobtitle} | tr [[:blank:]:/%\&=+?\\\\#\'\`\´\*] _)" outname=/tmp/${printtime}_${sanitized_jobtitle} From 9e2ec6b85c790120feabb152835bbcdd63824d1b Mon Sep 17 00:00:00 2001 From: Sampsa Laapotti Date: Wed, 12 Feb 2020 01:33:10 +0200 Subject: [PATCH 08/10] Remove cowsay, as output got somehow badly mangled * Did not have time to debug, sorry! --- remarkable-cups/install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/remarkable-cups/install.sh b/remarkable-cups/install.sh index b203303..42215aa 100755 --- a/remarkable-cups/install.sh +++ b/remarkable-cups/install.sh @@ -44,8 +44,10 @@ echo "Do you want to print a test page?" read -p 'test page? (y/N): ' tp if [ "$tp" = "y" ]; then - cowsay "Howdy there! Hopefully this printer works! Cheers to RMS!" |pandoc -o /tmp/test.pdf + echo "Hi there! Hopefully this printer works! Cheers to RMS!" >> /tmp/rminstall.txt + pandoc -i /tmp/rminstall.txt -o /tmp/test.pdf lp -d reMarkable /tmp/test.pdf + #rm /tmp/test.pdf /tmp/rminstallcow fi echo "All done ✓, happy printing! " From e294cd7d2ba6b4812da21fec4a8bdb8693f0eb73 Mon Sep 17 00:00:00 2001 From: Sampsa Laapotti Date: Wed, 12 Feb 2020 01:37:40 +0200 Subject: [PATCH 09/10] Enable cleanup --- remarkable-cups/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remarkable-cups/install.sh b/remarkable-cups/install.sh index 42215aa..c9592ea 100755 --- a/remarkable-cups/install.sh +++ b/remarkable-cups/install.sh @@ -47,7 +47,7 @@ if [ "$tp" = "y" ]; then echo "Hi there! Hopefully this printer works! Cheers to RMS!" >> /tmp/rminstall.txt pandoc -i /tmp/rminstall.txt -o /tmp/test.pdf lp -d reMarkable /tmp/test.pdf - #rm /tmp/test.pdf /tmp/rminstallcow + rm /tmp/test.pdf /tmp/rminstallcow fi echo "All done ✓, happy printing! " From 6ba68566e92d32e708c0686446691966ab5c33bc Mon Sep 17 00:00:00 2001 From: Sampsa Laapotti Date: Wed, 12 Feb 2020 01:47:50 +0200 Subject: [PATCH 10/10] Fix typo --- remarkable-cups/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remarkable-cups/install.sh b/remarkable-cups/install.sh index c9592ea..e49a03c 100755 --- a/remarkable-cups/install.sh +++ b/remarkable-cups/install.sh @@ -47,7 +47,7 @@ if [ "$tp" = "y" ]; then echo "Hi there! Hopefully this printer works! Cheers to RMS!" >> /tmp/rminstall.txt pandoc -i /tmp/rminstall.txt -o /tmp/test.pdf lp -d reMarkable /tmp/test.pdf - rm /tmp/test.pdf /tmp/rminstallcow + rm /tmp/test.pdf /tmp/rminstall.txt fi echo "All done ✓, happy printing! "