head 1.8; access; symbols; locks; strict; comment @# @; 1.8 date 99.04.28.11.08.50; author alexis; state Exp; branches; next 1.7; 1.7 date 99.02.20.18.13.08; author alexis; state Exp; branches; next 1.6; 1.6 date 99.01.08.17.20.18; author alexis; state Exp; branches; next 1.5; 1.5 date 99.01.07.13.21.27; author alexis; state Exp; branches; next 1.4; 1.4 date 98.10.07.16.49.21; author alexis; state Exp; branches; next 1.3; 1.3 date 98.08.28.17.40.43; author alexis; state Exp; branches; next 1.2; 1.2 date 98.08.28.13.50.42; author alexis; state Exp; branches; next ; desc @SHPP PORT OF news-suck.in 1.1. @ 1.8 log @added gep.sh.shpp dependency and use @ text @#!MARKER_SHELL_CMD PATH=/bin:/usr/bin PROGNAME=`basename $0` ############################################################################### # # # NEWS TRANSFER PROGRAM - USES SUCK # # # ############################################################################### ############################################################################### # # CONFIGURABLE STUFF STARTS HERE # ############################################################################### ATTEMPT_LIMIT=20 LOCK_DIR=MARKER_LOCK_DIR ############################################################################### # # CONFIGURABLE STUFF ENDS HERE # ############################################################################### FACILITY=news VERSION="MARKER_PATCHLEVEL" # $Header: /diskb/home/alexis/dev/supported/ppplc/lib/news/RCS/news-suck.shpp,v 1.7 1999/02/20 18:13:08 alexis Exp alexis $ ############################################################################### # # MAIN FUNCTION (called from very bottom of script) # ############################################################################### main() { ########################################################################### # # PROCESS OPTIONS # ########################################################################### MODE=unset while [ "X$1" != X ]; do case "$1" in -V) echo "$PROGNAME version $VERSION" exit 0 ;; -d) [ "X$2" = X ] && usage VERBOSE_LEVEL=$2 shift ;; -v) VERBOSE_LEVEL=3 ;; -i) [ $MODE != unset ] && usage MODE=inn ;; -c) [ $MODE != unset ] && usage MODE=cnews ;; -*) usage ;; *) break ;; esac shift done [ $MODE = unset ] && usage # Older versions of Suck use get-news.cnews and get-news.inn if [ -x MARKER_GETNEWS_CMD.$MODE ]; then GETNEWS_CMD=MARKER_GETNEWS_CMD.$MODE elif [ -x MARKER_GETNEWS_CMD ]; then GETNEWS_CMD=MARKER_GETNEWS_CMD else error "can't work out how to run MARKER_GETNEWS_CMD" fi am_i_root || error "this program requires root priviledges" # Are locks required? Yes, would be sensible. lock DUMMY gen_lock_file_name || error "lock failed" ########################################################################### # # FLUSH UNPROCESSED INCOMING NEWS BATCHES # ########################################################################### if [ $MODE = cnews ]; then info "flushing old inbound CNews batches" su - news -c "MARKER_NEWSBINDIR/input/newsrunning on" < /dev/null su - news -c MARKER_NEWSBINDIR/input/newsrun < /dev/null else warning "don't know how to flush old inbound INN batches" fi ########################################################################### # # DO THE NEWS TRANSFER # ########################################################################### if [ $MODE = cnews ]; then info "stopping CNews processing before downloading news" su - news -c "MARKER_NEWSBINDIR/input/newsrunning off" < /dev/null fi info "getting new news" for SERVER in ${*:-default}; do ATTEMPT=0 while :; do ATTEMPT=`expr $ATTEMPT + 1` info "attempt number $ATTEMPT of $ATTEMPT_LIMIT to server $SERVER" if [ $SERVER = default ] && $GETNEWS_CMD < /dev/null; then break elif [ $SERVER != default ] && $GETNEWS_CMD $SERVER < /dev/null; then break elif [ $ATTEMPT -lt $ATTEMPT_LIMIT ]; then info "news retrieval failed, retrying" sleep 3 else warning "news retrieval failed, giving up" break fi done done if [ $MODE = cnews ]; then info "restarting CNews processing after downloading news" su - news -c "MARKER_NEWSBINDIR/input/newsrunning on" < /dev/null fi ########################################################################### # # FLUSH NEWLY ARRIVED UNPROCESSED INCOMING NEWS BATCHES # ########################################################################### if [ $MODE = cnews ]; then info "flushing new inbound CNews batches" su - news -c "MARKER_NEWSBINDIR/input/newsrunning on" < /dev/null su - news -c MARKER_NEWSBINDIR/input/newsrun < /dev/null else warning "don't know how to flush new inbound INN batches" fi unlock DUMMY gen_lock_file_name info "done" } gen_lock_file_name() { typeset LOCK_WHAT LOCK_WHAT=$1 echo $LOCK_DIR/$PROGNAME.pid } usage() { { echo "Usage: $PROGNAME [ -d | -v ] { -i | -c }" echo " $PROGNAME -V" } >&2 exit 1 } #shpp include utils.sh.shpp #shpp include gep.sh.shpp @ 1.7 log @lock interface changed ,. @ text @d28 1 a28 1 # $Header: /diskb/home/alexis/dev/supported/ppplc/lib/news/RCS/news-suck.shpp,v 1.6 1999/01/08 17:20:18 alexis Exp alexis $ d161 1 a161 1 @ 1.6 log @fixed bug whereby '-c -i' wasn't an error merged scripts supporting old and new suck (get-news.cnews no longer exists) check run as root (needed for quiet su'ing to news) lock call checks return code (following changes to lock code) changed text of some warning and info messages merged 'if server specified on command line' actions inn option causes warnings not errors now @ text @d18 1 d28 1 a28 1 # $Header: /diskb/home/alexis/dev/ppplc/lib/news/RCS/news-suck-multiple.shpp,v 1.1 1999/01/07 13:21:39 alexis Exp $ d76 1 a76 1 lock || error "lock failed" d140 1 a140 1 unlock d146 3 a148 1 echo MARKER_LOCK_DIR/$PROGNAME.pid @ 1.5 log @symbol name changes @ text @a12 9 # Things you should know about this script: # # It is stored under RCS! Keep it that way! If you want a history of # changes made to this script then refer to rlog(1) - don't look here! # ############################################################################### ############################################################################### # d27 1 a27 1 # $Header: news-suck.shpp,v 1.4 1998/10/07 16:49:21 alexis Exp alexis $ a36 1 d52 4 a55 2 -i) MODE=inn ;; -c) MODE=cnews ;; d61 12 a73 3 # No other commandline arguments should be specified and mode necessary! [ "X$1" != X -o $MODE = unset ] && usage [ ! -x MARKER_GETNEWS_CMD.$MODE ] && error -f "can't execute MARKER_GETNEWS_CMD.$MODE" d75 1 a75 1 lock d84 1 a84 1 info "flushing old inbound batches" a86 2 # Stop Cnews processing while we get files su - news -c "MARKER_NEWSBINDIR/input/newsrunning off" < /dev/null d88 1 a88 1 error -f "inn not supported yet!" d97 4 d102 17 a118 13 ATTEMPT=0 while :; do ATTEMPT=`expr $ATTEMPT + 1` info "attempt #$ATTEMPT/$ATTEMPT_LIMIT" if MARKER_GETNEWS_CMD.$MODE < /dev/null; then break elif [ $ATTEMPT -lt $ATTEMPT_LIMIT ]; then info "news retrieval failed, retrying" sleep 3 else warning "news retrieval failed, giving up" break fi d120 4 d132 1 a132 1 info "flushing new inbound batches" d136 1 a136 1 error -f "inn not supported yet!" @ 1.4 log @removed shortcut exit depending on ppp0 name. @ text @d1 1 a1 1 #!SCRIPTSHELLCMD_MARKER d34 3 a36 2 VERSION="PATCHLEVEL_MARKER" # $Id: news-suck.shpp,v 1.3 1998/08/28 17:40:43 alexis Exp alexis $ d72 1 a72 2 [ MODE = unset ] && usage [ ! -x SUCKGETNEWSCMD_MARKER.$MODE ] && error -f "can't execute SUCKGETNEWSCMD_MARKER.$MODE" d84 2 a85 2 su - news -c "NEWSBINDIR_MARKER/input/newsrunning on" < /dev/null su - news -c NEWSBINDIR_MARKER/input/newsrun < /dev/null d87 1 a87 1 su - news -c "NEWSBINDIR_MARKER/input/newsrunning off" < /dev/null d103 1 a103 1 if SUCKGETNEWSCMD_MARKER.$MODE < /dev/null; then d122 2 a123 2 su - news -c "NEWSBINDIR_MARKER/input/newsrunning on" < /dev/null su - news -c NEWSBINDIR_MARKER/input/newsrun < /dev/null d134 1 a134 1 echo LOCK_DIR_MARKER/$PROGNAME.pid d146 1 a146 1 #shpp include utils.sh @ 1.3 log @removed version number test @ text @d35 1 a35 1 # $Id: news-suck.shpp,v 1.2 1998/08/28 13:50:42 alexis Exp alexis $ d103 1 a103 4 if ! grep -q '^ppp0' /proc/net/route; then warning "abandonning news retrieval - ppp is not up" break elif SUCKGETNEWSCMD_MARKER.$MODE < /dev/null; then @ 1.2 log @*** empty log message *** @ text @d35 1 a35 1 # $Id: news-suck.in,v 1.1 1998/08/07 11:33:43 alexis Exp alexis $ d55 2 a56 7 -V) if expr "$VERSION" : 'P.*R$' > /dev/null; then warning "this is a development version; use 'ident' for version information" exit 1 else echo "$PROGNAME version $VERSION" exit 0 fi ;; d137 1 a137 1 echo LOCKDIR_MARKER/$PROGNAME.pid @