From 5acda3eaeabae9045609539303a8c12c4ce401f1 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 25 Apr 2016 12:01:08 +0200 Subject: merge with latest dev version --- .../system/network.target.wants/printergui.service | 1 + .../data/etc/systemd/system/printergui.service | 8 +++ .../iptables/rules.d/50-lpd-redirect-and-fw | 8 +++ .../data/opt/openslx/scripts/run-virt_print | 67 ++++++++++++++++++++++ .../openslx/scripts/systemd-printergui_preparation | 20 +++++++ core/modules/printergui/module.build | 29 ++++++++++ core/modules/printergui/module.conf | 7 +++ core/modules/printergui/module.conf.debian | 7 +++ core/modules/printergui/module.conf.fedora | 5 ++ core/modules/printergui/module.conf.opensuse | 5 ++ core/modules/printergui/module.conf.ubuntu | 5 ++ 11 files changed, 162 insertions(+) create mode 120000 core/modules/printergui/data/etc/systemd/system/network.target.wants/printergui.service create mode 100644 core/modules/printergui/data/etc/systemd/system/printergui.service create mode 100755 core/modules/printergui/data/opt/openslx/iptables/rules.d/50-lpd-redirect-and-fw create mode 100755 core/modules/printergui/data/opt/openslx/scripts/run-virt_print create mode 100755 core/modules/printergui/data/opt/openslx/scripts/systemd-printergui_preparation create mode 100644 core/modules/printergui/module.build create mode 100644 core/modules/printergui/module.conf create mode 100644 core/modules/printergui/module.conf.debian create mode 100644 core/modules/printergui/module.conf.fedora create mode 100644 core/modules/printergui/module.conf.opensuse create mode 100644 core/modules/printergui/module.conf.ubuntu (limited to 'core/modules/printergui') 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 +" + -- cgit v1.2.3-55-g7522