diff options
author | Sebastian | 2016-04-25 12:01:08 +0200 |
---|---|---|
committer | Sebastian | 2016-04-25 12:01:08 +0200 |
commit | 5acda3eaeabae9045609539303a8c12c4ce401f1 (patch) | |
tree | 7e71975f8570b05aafe2ea6ec0e242a8912387bb /core/modules/printergui/data/opt/openslx | |
parent | initial commit (diff) | |
download | mltk-5acda3eaeabae9045609539303a8c12c4ce401f1.tar.gz mltk-5acda3eaeabae9045609539303a8c12c4ce401f1.tar.xz mltk-5acda3eaeabae9045609539303a8c12c4ce401f1.zip |
merge with latest dev version
Diffstat (limited to 'core/modules/printergui/data/opt/openslx')
3 files changed, 95 insertions, 0 deletions
diff --git a/core/modules/printergui/data/opt/openslx/iptables/rules.d/50-lpd-redirect-and-fw b/core/modules/printergui/data/opt/openslx/iptables/rules.d/50-lpd-redirect-and-fw new file mode 100755 index 00000000..c0b724a2 --- /dev/null +++ b/core/modules/printergui/data/opt/openslx/iptables/rules.d/50-lpd-redirect-and-fw @@ -0,0 +1,8 @@ +#!/bin/ash + +# Close from outside +iptables -A INPUT -i br0 -p tcp --dport 515 -j DROP +iptables -A INPUT -i br0 -p tcp --dport 5515 -j DROP +# Redirect from VM to lpd +iptables -t nat -A PREROUTING -s 192.168.0.0/16 -p tcp --dport 515 -j REDIRECT --to-port 5515 + diff --git a/core/modules/printergui/data/opt/openslx/scripts/run-virt_print b/core/modules/printergui/data/opt/openslx/scripts/run-virt_print new file mode 100755 index 00000000..ba352778 --- /dev/null +++ b/core/modules/printergui/data/opt/openslx/scripts/run-virt_print @@ -0,0 +1,67 @@ +#!/bin/ash + +# Called with $1=USERNAME $2=PRINTFILE + +USER="$1" +FILE="$2" +PRINTERGUI="/opt/openslx/cups/printergui" + +errlog () { + FD=0 + [ -t 1 ] && FD=1 + [ -t 2 ] && FD=2 + if [ $FD -ne 0 ]; then + echo "$2" >&$FD + elif [ $# -gt 2 ]; then + slxlog "$1" "$2" "$3" + sleep 1 + else + slxlog "$1" "$2" + fi + $PRINTERGUI --error "$2" & +} + +if [ $# -ne 2 ]; then + # Bad usage + errlog "printergui-call" "Error: Wrong number of arguments (got $#) ($@)" + exit 1 +fi + +if [ ! -r "$FILE" ]; then + errlog "printergui-file" "Error: File '$FILE' not readable" + exit 1 +fi + +if [ ! -s "$FILE" ]; then + errlog "printergui-file" "Error: File '$FILE' is empty" + exit 1 +fi + +# Some basic error checking if we have ghostscript available +if which gs 2>/dev/null; then + ERRLOG=$(mktemp) + [ -z "$ERRLOG" ] && ERRLOG="/tmp/tmp-$RANDOM-$$-$(whoami)" + gs -sDEVICE=nullpage -dNOPAUSE -dBATCH "$FILE" 2>"$ERRLOG" + RET=$? + if [ $RET -ne 0 ]; then + errlog "printergui-validate" "Error: Ghostscript choked on input file" "$ERRLOG" + rm -f -- "$ERRLOG" + exit 1 + fi + rm -f -- "$ERRLOG" +else + errlog "printergui-nogs" "Warning: Cannot validate file prior to printing: gs binary not found" +fi + +# Try to print +$PRINTERGUI "$USER" "$FILE" +RET=$? +if [ $RET -ne 0 -a $RET -ne 143 ]; then # SIGTERM results in 143, is sent by printpwgui + errlog "printergui-exec" "Error: printergui execution failed with exit code $RET" +fi + +sleep 1 +rm -f -- "$FILE" + +exit $RET + diff --git a/core/modules/printergui/data/opt/openslx/scripts/systemd-printergui_preparation b/core/modules/printergui/data/opt/openslx/scripts/systemd-printergui_preparation new file mode 100755 index 00000000..33a861e6 --- /dev/null +++ b/core/modules/printergui/data/opt/openslx/scripts/systemd-printergui_preparation @@ -0,0 +1,20 @@ +#!/bin/ash + +ERR=0 +SRCDIR=/usr/lib/cups/backend +DESTDIR=/opt/openslx/cups/backend +PRINTPWGUI=/opt/openslx/cups/printpwgui + +if [ ! -d "$DESTDIR" ]; then + mkdir -p "$DESTDIR" || exit 1 +fi + +mv "$SRCDIR"/* "$DESTDIR" + +cd "$SRCDIR" +for i in "$DESTDIR"/*; do + ln -sf "$PRINTPWGUI" $(basename "$i") +done + +exit 0 + |