case $CONFIG in
    '') . ./config.sh ;;
esac
echo "Extracting newsetup (with variable substitutions)"
$spitshell >newsetup <<!GROK!THIS!
$startsh

# $Header: newsetup.SH,v 4.3.2.8 90/11/22 13:26:55 sob Exp $
# 
# $Log:	newsetup.SH,v $
# Revision 4.3.2.8  90/11/22  13:26:55  sob
# Purged unneeded code.
# 
# Revision 4.3.2.7  90/03/17  20:34:48  sob
# Remove the /tmp/n.* files created when generating the .newsrc.
# 
# Revision 4.3.2.6  90/03/17  17:26:42  sob
# Some versions of sed only take 9 wfiles.
# 
# Revision 4.3.2.5  89/11/28  01:15:32  sob
# Fixed a bug that caused the active file to be removed on non-NNTP-based
# systems.
# 
# Revision 4.3.2.4  89/11/28  00:31:20  sob
# Changed news.announce.newuser to news.announce.newusers.
# 
# Revision 4.3.2.3  89/11/08  01:13:15  sob
# Finished modifications to make work with RN and RRN
#
# Revision 4.3.2.2  89/11/07  23:25:50  sob
#
# Added support such that RN and RRN can be made from the same sources.
# 
# Revision 4.3.1.2  86/09/05  15:41:04  lwall
# Changes for newsgroup renaming.
# 
# Revision 4.3.1.1  85/05/10  11:35:43  lwall
# Branch for patches.
# 
# Revision 4.3  85/05/01  11:43:05  lwall
# Baseline for release with 4.3bsd.
# 

export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)

: syntax: newsetup

: System dependencies
: You will want to change the definitions below to reflect the distribution
: areas around you.  If you have more areas than this you will need to modify
: the sed below.

locorg="$locpref"
organization="$orgpref"
city="$citypref"
state="$statepref"
cntry="$cntrypref"
cont="$contpref"
#NORMALactive="${active-/usr/lib/news/active}"
#NNTPactive="/tmp/active.\$\$"

dotdir="\${DOTDIR-\${HOME-\$LOGDIR}}"
$rm -f \$dotdir/.oldnewsrc
$echo "Creating .newsrc in \$dotdir to be used by news programs."
#NNTPrnlib=$rnlib
#NNTPcase \$rnlib in
#NNTP~*) rnlib=\`$filexp \$rnlib\` ;;
#NNTPesac
#NNTP\$rnlib/getactive \$active
#NORMALcase \$active in
#NORMAL~*) active=\`$filexp \$active\` ;;
#NORMALesac

if $test -s \$dotdir/.newsrc ; then
    $echo "Saving your current .newsrc as .oldnewsrc..."
    $mv -f \$dotdir/.newsrc \$dotdir/.oldnewsrc
fi

: newsrc order determined here

$sed <\$active '
	/^to\./d
	/ [^mny][^ ]*$/d
	s/ .*//
	s/^/ /
	s/^ '\$locorg'\./01&/
	s/^ '\$organization'\./02&/
	s/^ '\$city'\./03&/
	s/^ '\$state'\./04&/
	s/^ '\$cntry'\./05&/
	s/^ '\$cont'\./06&/
	s/^ news\./07&/
	s/^ comp\./08&/
	s/^ sci\./09&/
	s/^ rec\./10&/
	s/^ soc\./11&/
	s/^ talk\./13&/
	s/^ control\$/14&/
	s/^ junk\$/14&/
	s/^ test\$/14&/
	/\.test\$/s/^[0-9]*/14/
	s/^ .*\./12&/
	s/^ /00&/
' |
$sort -u |
$sed '
	/^14 /!s/\$/:/
	/^14 /s/\$/!/
	s/^[0-9][0-9] //
' >\$dotdir/.newsrc

#NNTP$rm -f \$active
$rm -f /tmp/n.misc\$\$ /tmp/n.sci\$\$ /tmp/n.soc\$\$ /tmp/n.news\$\$ /tmp/n.comp\$\$
$rm -f /tmp/n.\$cont\$\$ /tmp/n.\$city\$\$ /tmp/n.\$cntry\$\$ /tmp/n.\$state\$\$
$rm -f /tmp/n.to\$\$ /tmp/n.\$organization\$\$ /tmp/n.\$locorg\$\$ /tmp/n.test\$\$
$rm -f /tmp/n.tmp\$\$ /tmp/n.local\$\$ /tmp/n.rec\$\$

$cat <<'EOH'
Done.

If you have never used the news system before, you may find the articles
in news.announce.newusers to be helpful.  There is also a manual entry for rn.

To get rid of newsgroups you aren't interested in, use the 'u' command.
Type h for help at any time while running rn.
EOH
!GROK!THIS!
case "$isrrn" in
define)  sed < newsetup -e '/^#NNTP/s/^#NNTP//' -e '/^#NORMAL/d' > newsetup.new ;;
*) sed < newsetup -e '/^#NNTP/d' -e '/^#NORMAL/s/^#NORMAL//' > newsetup.new ;;
esac
mv newsetup.new newsetup
$eunicefix newsetup
chmod 755 newsetup
