File test_remote_novell.without_ping of Package yast2-printer

#! /bin/bash
#
# Test ability to connect to remote IPX Novell server.
#
# Exits:   0 queue on host accepts print jobs
#          1 host $1 or queue $2 not set
#          2 queue does not accept a print job
#         17 give up empty-handed because nprint not executable (no ncpfs RPM installed?)
#
# Johannes Meixner <jsmeix@suse.de>, 2000, 2002, 2007, 2008, 2009, 2010, 2011, 2014
# Jan Holesovsky <kendy@suse.cz>, 2000
# Jiri Srain <jsrain@suse.cz>, 2002
# $Id: test_remote_novell 43943 2008-01-28 13:38:58Z mzugec $

#set -x

# Make sure to have a clean environment:
export PATH="/sbin:/usr/sbin:/usr/bin:/bin"
export LC_ALL="POSIX"
export LANG="POSIX"
umask 022
# Disable bash file name globbing:
set -f

MY_NAME=${0##*/}
HOST=$1
QUEUE=$2
[ -z "$HOST" -o -z "$QUEUE" ] && { echo -en "\nUsage:\n$MY_NAME HOST QUEUE [TIMEOUT]\n" 1>&2 ; exit 1 ; }
USER=$3
PASSWORD=$4
TIMEOUT="$5"
[ -z "$TIMEOUT" ] && TIMEOUT=10

# Use the binaries of the operating system (no aliases, functions, /usr/local/):
export NPRINT=$( type -ap nprint | head -n 1 )

# Test whether nprint is executable:
if test -z "$NPRINT"
then # Give up empty-handed when nprint is not executable:
     echo -en "\nGiving up empty-handed because 'nprint' not executable (no 'ncpfs' RPM installed?)\n" 1>&2
     exit 17
fi
# Test whether the queue on the server accepts print jobs:
echo -en "\nTesting queue '$QUEUE' on host '$HOST':\n"
if echo -en "\r" | $NPRINT -S "$HOST" -U "$USER" -P "$PASSWORD" -q "$QUEUE" - 2>&1
then echo -en "\nQueue '$QUEUE' on host '$HOST' accepts print jobs\n"
     exit 0
fi

# The nprint test failed:
echo -en "\nQueue '$QUEUE' on host '$HOST' does not accept print jobs."
echo -en "\n(Network issue or wrong host/queue or queue disabled or no server running or firewall active there?)\n\n"
exit 2

openSUSE Build Service is sponsored by