Shell script to add new local groups

Bill.Hoffman at walgreens.com Bill.Hoffman at walgreens.com
Thu Nov 18 15:59:25 UTC 1999



      I put a script together to add new groups to my local news group.  I put
this together before I found the ctlinnd stuff in the FAQ (6.3).  I basically
want to show my script to you gurus to find out if this why I am getting errors
when posting.

Here is the errors that I get when posting:

Nov 18 09:33:06 itsup innd: SERVER cant dbzstore No such file or directory
Nov 18 09:33:06 itsup innd: SERVER cant write history
<811644$b0l$1 at itsup.walgreens.com> No such file or directory
Nov 18 09:33:06 itsup innd: localhost:15 closed seconds 0 accepted 0 refused 0
rejected 1
Nov 18 09:33:06 itsup rnews: offered <811644$b0l$1 at itsup.walgreens.com> 38341bc4
Nov 18 09:33:06 itsup rnews: cant unspool saving to
/usr/local/news/spool/incoming/bad/38341c32gFUXnC


The post went through but I am concerned about the message going to
incoming/bad.

Here is the script that I threw together:


USAGE="usage: newsadd"

function getuser {
tput clear
print "Please enter the new newsgroup to be added: \c"
read USER

# Test to see if group already exists
if (( `grep -c "^$USER " ~news/db/active` == 1 ))
  then print "Group already exists"
       print "Hit <enter> to try again <c> to continue or <q> to quit: \c"
       read ENTER

       case $ENTER in
       q) exit 0;;
       c) print "Are you sure you want to create a new group for $USER (y or n)?
 \c"
         read ANSWER
       if [[ $ANSWER != y ]]
          then exit 0
          #else SKIP=y
       fi ;;
       *) getuser;;
          #realname;;
       esac
  else realname
fi
}

# Enter decription of the group for newsgroup file
function realname {
print "Please enter a description of the group: \c"
read REAL

if [[ $REAL == "" ]]
  then print "You must enter a value for Description "
       print "Hit enter to start over..."
       read ANS
       getuser
fi

}

# make sure that everything worked alright
function testsuccess {
  if [[ $? == 0 ]]
    then print "Completed successfully"
    else print "Process failed."
         exit 1
  fi
}

getuser

ACTIVE=/usr/local/news/db/active
NEWSGROUPS=/usr/local/news/db/newsgroups


# Meat of the program is here
    print "Adding new group"
    print "$USER 0000000000 0000000001 y" >> $ACTIVE
    print "$USER $REAL" >> $NEWSGROUPS
    cd ~news/db
    ~news/bin/makehistory -i
    print "Moving file history.n.index to history.index"
    mv history.n.index history.index
    testsuccess
    print "Moving file history.n.hash to history.hash"
    mv history.n.hash history.hash
    testsuccess
    print "Moving file history.n.dir to history.dir"
    mv history.n.dir history.dir
    testsuccess
    ps aux|grep news|grep -v grep|grep -v newsadd|grep -v $$|kill -9 `awk
'{print $2}'`
    rm ~news/run/*.pid
    su news -c /usr/local/news/bin/rc.news
    testsuccess

exit 0


Thanx for your time,


BEH




More information about the inn-workers mailing list