New upstream version 2.1.3
This commit is contained in:
45
nxredir/nxsmb
Executable file
45
nxredir/nxsmb
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# nxsmb: Small wrapper for the SMB backend to be able to print to CIFS or SMB ports directly.
|
||||
#
|
||||
# Copyright (c) 2008 by Fabian Franz.
|
||||
#
|
||||
#
|
||||
|
||||
# turn on DEBUG?
|
||||
#set -x -v
|
||||
CUPS_BACKEND="/usr/lib/cups/backend"
|
||||
PATH_LIB="/usr/lib"
|
||||
|
||||
NXREDIR_LIBRARY="$PATH_LIB/freenx-server/libnxredir.so.0"
|
||||
COMMAND_SMB="$CUPS_BACKEND/smb"
|
||||
|
||||
PORT=$(echo $DEVICE_URI | cut -d/ -f3 | cut -d@ -f2 | cut -d: -f2)
|
||||
PROTOCOL=$(echo $DEVICE_URI | cut -d/ -f4)
|
||||
PRINTER=$(echo $DEVICE_URI | cut -d/ -f5)
|
||||
|
||||
if [ -z "$PRINTER" ]; then # old style setup
|
||||
echo "Warning: Not using nxredir library. The DEVICE_URI is not in the right format."
|
||||
exec "$COMMAND_SMB" "$@"
|
||||
fi
|
||||
|
||||
if [ ! -x "$NXREDIR_LIBRARY" ]; then
|
||||
# repair DEVICE_URI
|
||||
DEVICE_URI=$(echo $DEVICE_URI | sed "s|/$PROTOCOL||g")
|
||||
echo "Error: Not using nxredir library. $NXREDIR_LIBRARY could not be found or is not executable."
|
||||
exec "$COMMAND_SMB" "$@"
|
||||
fi
|
||||
|
||||
if [ "$PROTOCOL" = "cifs" -o "$PROTOCOL" = "CIFS" ]; then
|
||||
REAL_PORT="445"
|
||||
else
|
||||
REAL_PORT="139"
|
||||
fi
|
||||
|
||||
DEVICE_URI=$(echo $DEVICE_URI | sed "s|:$PORT/$PROTOCOL/|:$REAL_PORT/|g")
|
||||
export DEVICE_URI=$(echo $DEVICE_URI | sed "s|nxsmb://|smb://|g")
|
||||
|
||||
export NXSAMBA_PORT="$PORT"
|
||||
export LD_PRELOAD="$NXREDIR_LIBRARY${LD_PRELOAD:+:$LD_PRELOAD}"
|
||||
|
||||
exec "$COMMAND_SMB" "$@"
|
||||
Reference in New Issue
Block a user