File: get.news.generic

package info (click to toggle)
suck 4.3.5-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,196 kB
  • sloc: ansic: 12,086; perl: 528; sh: 363; makefile: 345; java: 144
file content (90 lines) | stat: -rwxr-xr-x 2,461 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh

#BEFORE USING - check to ensure all the paths defined below are correct!!

#NOTE: this script probably needs to be run by root.  Most systems will
# not let a normal user run rnews


REMOTE_HOST=news.pixi.com
LOCAL_HOST=localhost

SPOOLDIR=/usr/spool/news		# base directory for articles to be rposted
NEWSDIR=/usr/lib/news			# base directory for news binaries 
BASEDIR=/home/boby/doNews		# base directory for suck rpost and scripts

SHLOCK=${NEWSDIR}/bin/shlock

TMPDIR=${BASEDIR}			# location for suck.* files
MSGDIR=${BASEDIR}/Msgs			# where to put MultiFile articles when getting them

OUTGOING=${SPOOLDIR}/out.going/pixi	# location of the list of articles to upload
SCRIPT=${BASEDIR}/put.news		# my filter for rpost
OUTFILE=/tmp/tmp$$			# used by rpost as article after it is filtered
LOCKFILE=${BASEDIR}/getnews.lock	# lock file to prevent multiple instances of script

TESTHOST=testhost
RPOST=rpost
SUCK=suck
TESTHOST=testhost

# if we are already running, abort

trap 'rm -f ${LOCKFILE} ; echo "Aborting" ; exit 1' 1 2 3 15
${SHLOCK} -p $$ -f ${LOCKFILE}
if [ $? -ne 0 ]; then
	echo "Already running, can't run two at one time"
	exit
fi

# is the local host up and running so we can post articles we download?
${TESTHOST} ${LOCAL_HOST} -s
LOCAL_RESULT=$?

# is the remote host up and running so we can download articles?
${TESTHOST} ${REMOTE_HOST} -s
REMOTE_RESULT=$?

if [ ${REMOTE_RESULT} -eq 0 -a ${LOCAL_RESULT} -eq 0 ]; then

	# download articles
	${SUCK} ${REMOTE_HOST} -c -A -bp -hl ${LOCAL_HOST} -dt ${TMPDIR} -dm ${MSGDIR} -dd ${BASEDIR}
	SUCK_STATUS=$?

	if [ ${SUCK_STATUS} -eq 0 ]; then
		echo "Downloaded Articles"
	elif [ ${SUCK_STATUS} -eq 1 ]; then
		echo "No articles to download"
	elif [ ${SUCK_STATUS} -eq 2 ]; then
		echo "Unexpected answer from remote server to an issued command"
	elif [ ${SUCK_STATUS} -eq 4 ]; then
		echo "Can't do NNTP authorization"
	elif [ ${SUCK_STATUS} -eq -1 ]; then
		echo "General failure"
	fi

	# now upload articles
	if [ -s ${OUTGOING} ]; then
		# outgoing articles to post

		${TESTHOST} ${REMOTE_HOST} -s

		if [ $? -ne 0 ]; then
			echo "Remote posting host not responding"
		else
			${RPOST} ${REMOTE_HOST} -d -b ${OUTGOING} -p ${SPOOLDIR} -f \$\$o=${OUTFILE} ${SCRIPT} \$\$i ${OUTFILE}

			if [ $? -ne 0 ]; then
				echo "Error remote posting"
			else
				echo "Remotely posted articles"
				rm ${OUTFILE}
			fi 
		fi
	fi	
	
	echo "You can hang up the modem now"

fi

rm -f ${LOCKFILE}