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 | |
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')
11 files changed, 162 insertions, 0 deletions
diff --git a/core/modules/printergui/data/etc/systemd/system/network.target.wants/printergui.service b/core/modules/printergui/data/etc/systemd/system/network.target.wants/printergui.service new file mode 120000 index 00000000..40453c80 --- /dev/null +++ b/core/modules/printergui/data/etc/systemd/system/network.target.wants/printergui.service @@ -0,0 +1 @@ +../printergui.service
\ No newline at end of file diff --git a/core/modules/printergui/data/etc/systemd/system/printergui.service b/core/modules/printergui/data/etc/systemd/system/printergui.service new file mode 100644 index 00000000..8b00514c --- /dev/null +++ b/core/modules/printergui/data/etc/systemd/system/printergui.service @@ -0,0 +1,8 @@ +[Unit] +Description=Printergui - bwLehrpool printing system +Requires=network.target graphical.target +After=network.target +Before=cups.service + +[Service] +ExecStart=/opt/openslx/scripts/systemd-printergui_preparation 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 + diff --git a/core/modules/printergui/module.build b/core/modules/printergui/module.build new file mode 100644 index 00000000..a6f3ab17 --- /dev/null +++ b/core/modules/printergui/module.build @@ -0,0 +1,29 @@ +#!/bin/bash + +fetch_source() { + git clone "${REQUIRED_GIT}" src + cd src + git checkout "$REQUIRED_COMMIT" + cd .. +} + +build() { + local SRCDIR="${MODULE_WORK_DIR}/src/" + local DESTDIR="$MODULE_BUILD_DIR/opt/openslx/cups" + + # first activate qt 4 + activate_qt 4 + + mkdir -p "$DESTDIR" + cd "$DESTDIR" || perror "Could not cd to $DESTDIR!" + pinfo "Running cmake" + cmake "$SRCDIR/" || perror "'cmake' failed (e.g. not installed)." + pinfo "Running make" + make || perror "'make' failed." + chmod 0700 "$DESTDIR/printpwgui" # So picky cupsd won't drop privileges to lp + +} +post_copy() { + : +} + diff --git a/core/modules/printergui/module.conf b/core/modules/printergui/module.conf new file mode 100644 index 00000000..39e64b16 --- /dev/null +++ b/core/modules/printergui/module.conf @@ -0,0 +1,7 @@ +REQUIRED_GIT="git://git.openslx.org/openslx-ng/printergui.git" +REQUIRED_COMMIT="HEAD" +REQUIRED_BINARIES=" + printergui + printpwgui +" + diff --git a/core/modules/printergui/module.conf.debian b/core/modules/printergui/module.conf.debian new file mode 100644 index 00000000..54123003 --- /dev/null +++ b/core/modules/printergui/module.conf.debian @@ -0,0 +1,7 @@ +REQUIRED_INSTALLED_PACKAGES=" + libcups2-dev + libqt4-dev +" +REQUIRED_CONTENT_PACKAGES=" + libcups2-dev +" diff --git a/core/modules/printergui/module.conf.fedora b/core/modules/printergui/module.conf.fedora new file mode 100644 index 00000000..f1f55014 --- /dev/null +++ b/core/modules/printergui/module.conf.fedora @@ -0,0 +1,5 @@ +REQUIRED_INSTALLED_PACKAGES=" + cups-devel + qt-devel +" + diff --git a/core/modules/printergui/module.conf.opensuse b/core/modules/printergui/module.conf.opensuse new file mode 100644 index 00000000..478d0a71 --- /dev/null +++ b/core/modules/printergui/module.conf.opensuse @@ -0,0 +1,5 @@ +REQUIRED_INSTALLED_PACKAGES=" + cups-devel + libqt4-devel +" + diff --git a/core/modules/printergui/module.conf.ubuntu b/core/modules/printergui/module.conf.ubuntu new file mode 100644 index 00000000..73c89910 --- /dev/null +++ b/core/modules/printergui/module.conf.ubuntu @@ -0,0 +1,5 @@ +REQUIRED_INSTALLED_PACKAGES=" + libcups2-dev + libqt4-dev +" + |