-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisa
executable file
·40 lines (30 loc) · 1002 Bytes
/
visa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# when called without any arguments CUPS expects us to print a backend
# info for use in the new printer page
if [ $# -eq 0 ]; then
echo "virtual visa \"Unknown\" \"VISA Printer\""
exit 0
fi
JOBID=$1
CLOUD_INSTANCE_ID=`cloud-init query ds.meta_data.instance-id`
if [ -z "$CLOUD_INSTANCE_ID" ]; then
echo "ERROR:Failed to get CLOUD_INSTANCE_ID from OpenStack instance metadata"
exit 1
fi
if [ $# -eq 6 ]; then
PDFFILE=$6
else
PDFFILE=$(mktemp </dev/null /tmp/visa-printer.XXXXXX) ||
(echo "ERROR:Failed to create temporary file" 1>&2; exit 1)
cat > $PDFFILE
fi
chmod a+r $PDFFILE
VISA_PRINT_STATUS=$(curl -X POST -H "x-auth-token: $CLOUD_INSTANCE_ID" http://localhost:8091/api/printer --data-urlencode "jobId=$JOBID" --data-urlencode "path=$PDFFILE")
if [[ $VISA_PRINT_STATUS != "ok" ]]; then
echo "ERROR:Sending PDF to VISA client failed: $VISA_PRINT_STATUS" 1>&2
exit $VISA_PRINT_RC
fi
if [ $# -lt 6 ];then
rm -f $PDFFILE
fi
exit 0