#! /bin/sh

# Arrange to poll one or more hosts, by creating a file that will cause
#	the normal UUCP mechanisms to do the work.
# If the -p arg is given, the UUCP mechanisms are started.


SPOOL=/var/spool/uucp

USAGE='usage: [-p] host1 [host2...]'

while getopts p c; do
	case $c in
	p) poll=1;;
	\?) echo "$USAGE"; exit 1;;
	esac
done
shift `expr $OPTIND - 1`

if test $# -eq 0; then
	echo "$USAGE"; exit 1
fi

trap "" 1
umask 022
set +e

while test $# -gt 0; do
	if test ! -d $SPOOL/$1; then
		mkdir $SPOOL/$1
		chown uucp $SPOOL/$1
	fi

	j=`expr $1 : '\(.\{1,7\}\)'`
	sfile=$SPOOL/$1/C.${j}n0000
	touch $sfile
	chown uucp $sfile
	shift
done

if test "$poll" = 1 -a ! -f /etc/nologin; then
	/usr/lib/uucp/uusched &
fi
