#!/usr/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/sn-gn - fetch news # # Creation : 2001 chriswue # Last update: $Id$ # # Copyright (c) 2001-2003 by Christian Wuerdig eisfair(at)chriswue(dot)de # Copyright (c) 2010-@@YEAR@@ Holger Bruenjes, holgerbruenjes(at)gmx(dot)net # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- . /var/install/include/eislib . /var/lib/sn/sn.info . /etc/sysconfig/sn sn_req_new_groups=${SN_REQ_NEW_GROUPS} sn_log_dir=${SN_LOG_DIR} sn_fetch_log=${SN_FETCH_LOG} if [ -n "${sn_log_dir}" ] then if [ ! -f ${sn_log_dir}/${sn_fetch_log} ] then > ${sn_log_dir}/${sn_fetch_log} fi chown news:news ${sn_log_dir}/${sn_fetch_log} fi if [ ! -d ${OUTGOING} ] then if [ -z "$1" ] then echo mecho --warn "sn-gn: No external newsserver found." mecho --warn " Could not fetch any news." echo else mecho --warn "sn-gn: No external newsserver found." mecho --warn " Could not fetch any news." fi exit 0 fi d=$(date +'%F %T %Z') service=$(ps -A | grep 'snstore\|snget\|SNHELLO') if ! test "$service" then if [ "$sn_req_new_groups" = "yes" ] then cd ${OUTGOING} ls -1 | while read server do s=$(echo $server | cut -d ':' -f 1) if [ -f $server/request-list ] then if [ -z "$1" ] then mecho -n --info "requesting grouplist for" mecho " '${s}'" fi if [ "$1" = "cron" -o "${1}" = "news" ] then echo "$d: requesting grouplist for $s" >> $sn_log_dir/$sn_fetch_log fi else if [ -z "$1" ] then mecho -n --info "scanning for new NG's on" mecho " '${s}'" fi if [ "${1}" = "cron" -o "${1}" = "news" ] then echo "$d: scanning for new NG's on $s" >> $sn_log_dir/$sn_fetch_log fi cp -f /var/lib/sn/savelist $server/savelist > /dev/null echo "/var/lib/sn/savelist" >$server/request-newgroups chown news:news $server/* fi done fi if [ -z "$1" ] then mecho --info "fetching news (in background) ..." fi if [ "${1}" = "cron" -o "${1}" = "news" ] then echo "$d: fetching news (in background)" >> $sn_log_dir/$sn_fetch_log fi if [ -z "$1" -o "$1" = "cron" ] then su news -s /usr/bin/sh -c "/usr/sbin/snget -p${SN_FETCH_CONNECTS} 2>>$sn_log_dir/$sn_fetch_log" else # for getmsg.sh (netcat doesn't like su) /usr/sbin/snget -p${SN_FETCH_CONNECTS} 2>>$sn_log_dir/$sn_fetch_log fi else mecho --info "sn: service already active" fi exit 0 # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------