2 # $Id: admin.funcs,v 1.2 2001/01/15 22:20:11 tom Exp $
4 # ComeOn Point Functions! v0.9.2
5 # - usate da vari altri moduli ComeOn Point...
7 # AUTHOR: Beppe (beppe.dem@nsm.it)
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License
11 # as published by the Free Software Foundation; either version 2
12 # of the License, or (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 # Args: source_file, domain, nldir
31 dialog --backtitle "$TITLE" --infobox "Installo la nodelist '$NODELIST' per il domain $FOR_DOMAIN, attendere prego..." 0 0
33 cp "$NODELIST" $NODEDIR/$FOR_DOMAIN.ndl
34 chown fnet.uucp $NODEDIR/$FOR_DOMAIN.ndl
36 echo "y" | su -l fnet -c "ifindex" >/dev/null
45 ENTRY="`grep $SOURCE: $ALIASES`"
47 dialog --backtitle "$TITLE" --infobox "Creo un alias per redirigere le mail per $SOURCE a $DEST ..." 0 0
51 echo "$SOURCE: $DEST" >>$ALIASES
53 OLDDEST="`echo $ENTRY | cut -f2 -d:`"
55 sed /"$SOURCE:"/s/"$OLDDEST"/" $DEST"/ $ALIASES >$tmp_alias
56 cat $tmp_alias >$ALIASES
62 # Args: Areas_pathname, newsgroup, area_ftn, description [, expire_days]
63 # Returns: 1 - innd not running
64 # 2 - already existing newsgroup
65 # 3 - already existing ftn_area
74 NEWSGROUPS=~news/newsgroups
75 EXPIRECTL=~news/expire.ctl
77 dialog --backtitle "$TITLE" --infobox "Creo il newsgroup $NEWSGROUP per contenere i messaggi dell'area $AREA..." 0 0
79 if [ ! "`ps ax | grep ~news/etc/innd`" ]
84 if [ "`cut $NEWSGROUPS -f1 | cut -f1 -d\ | grep -x $NEWSGROUP`" ]
89 if [ "`cut $AREAS -f1 | cut -f1 -d\ | grep -x $AREA`" ]
94 su -l news -c "bin/ctlinnd newgroup $NEWSGROUP" >/dev/null
95 echo -e "$NEWSGROUP\t$DESCRIPTION" >> $NEWSGROUPS
96 echo -e "$AREA\t$NEWSGROUP\t`echo $NEWSGROUP | cut -f1 -d.`" >> $AREAS
98 if [ "$EXPIRE_DAYS" ]; then
99 echo "$NEWSGROUP:A:2:$EXPIRE_DAYS:$EXPIRE_DAYS" >> $EXPIRECTL
102 chown news.news $NEWSGROUPS $EXPIRECTL
104 chown fnet.uucp $AREAS
107 # Returns: 0 if ok, 1 if (innd not running), 2 if (no that newsgroup)
108 # Args: Areas_pathname, newsgroup
113 NEWSGROUPS=~news/newsgroups
114 EXPIRE=~news/expire.ctl
116 dialog --backtitle "$TITLE" --infobox "Elimino il newsgroup $NEWSGR ed i messaggi in esso contenuti, attendere prego. Questa operazione potrebbe durare alcuni minuti." 0 0
118 if [ ! "`ps x | grep ~news/etc/innd`" ]
123 if [ ! "`cut -f1 $NEWSGROUPS | cut -f1 -d\ | grep -x $NEWSGR`" ]
128 # Updating newsgroups file
129 if [ -f $NEWSGROUPS ]
132 mv $NEWSGROUPS $NEWSGROUPS~
133 grep -v $NEWSGR $NEWSGROUPS~ >$tmp_groups
134 mv $tmp_groups $NEWSGROUPS
138 chown news.news $NEWSGROUPS
140 # Updating Areas file
145 grep -v $NEWSGR $AREAS~ >$tmp_areas
150 chown fnet.uucp $AREAS
152 # Updating expire.ctl file
157 grep -v "$NEWSGR:" $EXPIRE~ >$tmp_expire
158 mv $tmp_expire $EXPIRE
162 chown news.news $EXPIRE
164 # Remove pending articles
165 echo -e "\n$NEWSGR:A:0:0:0" >>$EXPIRE
166 su -l news -c "bin/news.daily" >/dev/null
168 grep -v $NEWSGR $EXPIRE >$tmp_expire
169 mv $tmp_expire $EXPIRE
170 chown news.news $EXPIRE
173 # Updating active file
174 su -l news -c "bin/ctlinnd rmgroup $NEWSGR" >/dev/null
178 # Args: newsgroups_wildmat, days_to_keep
183 EXPIRE=~news/expire.ctl
185 dialog --backtitle "$TITLE" --infobox "Imposto a $KEEPDAYS il numero di giorni di mantenimento dei messaggi del newsgroup $NEWSGROUP..." 0 0
191 elif [ "`cut $EXPIRE -s -f1 -d: | grep -x $NEWSGROUP`" ]
194 grep -v "$NEWSGROUP:" $EXPIRE >$tmp_expire
195 mv $tmp_expire $EXPIRE
197 echo -e "\n$NEWSGROUP:A:2:$KEEPDAYS:$KEEPDAYS" >>$EXPIRE
198 chown news.news $EXPIRE