#! /bin/sh #------------------------------------------------------------------------------ # part of the sn-package for eisfair # add a newsgroup # last update: 2003/09/11 # (c) 2001-2003 by Christian Würdig (eisfair@chriswue.de) #------------------------------------------------------------------------------ . /etc/config.d/sn outgoing="/var/spool/news/.outgoing" tmp="/tmp/.snserv" defmax="200" defexpt="1m" create_login() { if [ "$1" != "" ]; then echo if /var/install/bin/ask "Login required"; then cd $outgoing/$1:119 echo echo -e "Login: \c" read login echo echo -e "Password: \c" read -s pass echo echo -e "retype Password: \c" read -s rpass echo if [ "$pass" = "$rpass" ]; then echo $login >username echo $pass >password cp /usr/local/sn/HELLO HELLO chmod 600 username password chown news username password HELLO chgrp news username password HELLO else echo colecho "Passwords are not equal, doing nothing" rd fi fi fi } add_group() { touch /var/spool/news/.noservice su news -c "/usr/local/sn/snnewgroup $1 $2 2>>$SN_LOG_DIR/$SN_CONF_LOG" echo $defmax > /var/spool/news/$1/.max chown news /var/spool/news/$1/.max chgrp news /var/spool/news/$1/.max echo $defexpt > /var/spool/news/$1/.expire chown news /var/spool/news/$1/.expire chgrp news /var/spool/news/$1/.expire touch /var/spool/news/$1/.compress chown news /var/spool/news/$1/.compress chgrp news /var/spool/news/$1/.compress rm -f /var/spool/news/.noservice echo "Newsgroup $1 on server ${2:-local} added." } clrhome colecho "add newsgroup" gn echo echo "add NG on" echo "1) existing newsserver (or local NG)" echo "2) new newsserver" echo echo "0) exit" echo exists=0 while [ 1 ]; do echo -e "> \c" read choice case "$choice" in 0) echo; echo "quit"; echo /var/install/bin/anykey exit 0 ;; 1) /var/install/bin/sn-getserver local if [ -f $tmp ]; then read ns < $tmp rm -f $tmp else echo; echo "quit"; echo /var/install/bin/anykey exit 0 fi exists=1 break ;; 2) echo -e "server: \c" read ns break ;; *) colecho "choose 0, 1, or 2!" br x br ;; esac done tmp="/tmp/.sngl" sdir="$outgoing/$ns:119" if [ -f $sdir/grouplist ]; then echo echo -e "newsgroup (regex possible): \c" read regex grep "$regex" $sdir/grouplist > $tmp n=0 while read line; do n=`expr $n + 1` eval ng_$n='"$line"' done < $tmp rm -f $tmp n=`expr $n + 1` eval ng_$n='"all groups"' if [ "$n" -gt 50 ]; then if ! /var/install/bin/ask "Display all $n possibilities"; then exit 0 fi fi numb=$n n=0 last=0 while [ 1 ]; do clrhome colecho "Subscribe newsgroups (`expr $numb - 1` groups found matching '$regex')" gn echo row=1 last=`expr $last + 1` while [ $row -le 20 -a "$n" -lt "$numb" ]; do n=`expr $n + 1` eval group='$ng_'$n echo -e "($n)\t$group" row=`expr $row + 1` done echo echo -e "Newsgroup to add ($last-$n, RETURN=Next page, 0=Return): \c" read a if [ "$a" != "" ]; then if [ "$a" -eq 0 ]; then break fi while [ "$a" -lt "$last" -o "$a" -gt "$n" ]; do echo -e "Newsgroup to add ($last-$n, RETURN=Next page, 0=Return): \c" read a if [ "$a" = "" ]; then break fi if [ "$a" -eq 0 ]; then break 2 fi done if [ "$a" != "" ]; then eval group='$ng_'$a if [ "$group" = "all groups" ]; then n=0 numb=`expr $numb - 1` while [ "$n" -lt "$numb" ]; do n=`expr $n + 1` eval group='$ng_'$n add_group "$group" "$ns" done break else add_group "$group" "$ns" /var/install/bin/anykey last=`expr $last - 1` n=$last fi fi fi if [ "$n" -eq "$numb" ]; then n=0 fi last=$n done else echo echo -e "newsgroup (no regex possible due to missing grouplist): \c" read ng if [ "$ns" = "local" ]; then ns="" fi add_group "$ng" "$ns" if [ "$exists" = "1" ]; then echo "newsserver exists, skipping authorisation" else create_login "$ns" fi fi echo /var/install/bin/anykey exit 0