summaryrefslogtreecommitdiffstats
path: root/remote/modules/vmchooser
diff options
context:
space:
mode:
authorSimon Rettberg2014-02-11 20:26:59 +0100
committerSimon Rettberg2014-02-11 20:26:59 +0100
commit2fed65fa7e94853079ecf0c8ad74a7963e26df84 (patch)
tree9b21c617b69dc1dbd826e5c4ed5ecde7dd54ee90 /remote/modules/vmchooser
parent[printergui] config cleanup (diff)
downloadtm-scripts-2fed65fa7e94853079ecf0c8ad74a7963e26df84.tar.gz
tm-scripts-2fed65fa7e94853079ecf0c8ad74a7963e26df84.tar.xz
tm-scripts-2fed65fa7e94853079ecf0c8ad74a7963e26df84.zip
[printergui] Spool from VM to tmpfs home if possible, fall back to /tmp
Diffstat (limited to 'remote/modules/vmchooser')
-rwxr-xr-xremote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt20
1 files changed, 15 insertions, 5 deletions
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt
index 9442635a..2cd92776 100755
--- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt
+++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt
@@ -436,16 +436,26 @@ amixer -q sset 'Front Mic' "$VOL" unmute 2>/dev/null # to be checked if Mic is
amixer -q sset 'Rear Mic' "$VOL" unmute 2>/dev/null # =""=
amixer -q -c pcsp sset Master "0%" mute 2>/dev/null # fix random static noise when starting vmplayer TODO: find out why?!
-# Start printer daemon
+# Start printer daemon
+QUEUE="STANDARD" # This has to match the queue you configured in your VM
USER="$(whoami)"
-SPOOLDIR="/var/spool"
-QUEUE="STANDARD"
+# Try using users tmpfs home first, as it gets wiped on logout
+if [ -n "${HOME}" ] && [ -w "${HOME}" ]; then
+ SPOOLDIR="${HOME}/.spool"
+ mkdir -p "${SPOOLDIR}/${QUEUE}"
+fi
+# If failed, try to fall back to /tmp
+if [ -z "${SPOOLDIR}" ] || [ ! -w "${SPOOLDIR}/${QUEUE}" ]; then
+ SPOOLDIR="/tmp/printergui/${USER}/"
+ rm -rf -- "${SPOOLDIR}"
+ mkdir -p "${SPOOLDIR}/${QUEUE}"
+fi
# Start the lpdaemon listening on the given port
-# FixMe: Solution for general printer redirection in other cases (iptables on outgoing port)
+# TODO: externalize with something like runtvirt.d (other parts might benefit from that too)
tcpsvd -E 192.168.101.1 5515 \
lpd "$SPOOLDIR" \
- sh -c "/opt/openslx/cups/printergui $USER $SPOOLDIR/$QUEUE/\$DATAFILE" &
+ ash -c "/opt/openslx/cups/printergui '${USER}' \"${SPOOLDIR}/${QUEUE}/\$DATAFILE\"" &
# PID to kill the process
PID_LPD="$!"