1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
#!/bin/bash
# $Id: admin.funcs,v 1.2 2001/01/15 22:20:11 tom Exp $
#
# ComeOn Point Functions! v0.9.2
# - usate da vari altri moduli ComeOn Point...
#
# AUTHOR: Beppe (beppe.dem@nsm.it)
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Args: source_file, domain, nldir
install_nodelist() {
NODELIST="$1"
FOR_DOMAIN="$2"
NODEDIR="$3"
dialog --backtitle "$TITLE" --infobox "Installo la nodelist '$NODELIST' per il domain $FOR_DOMAIN, attendere prego..." 0 0
cp "$NODELIST" $NODEDIR/$FOR_DOMAIN.ndl
chown fnet.uucp $NODEDIR/$FOR_DOMAIN.ndl
echo "y" | su -l fnet -c "ifindex" >/dev/null
}
# Args: source, dest
add_alias() {
SOURCE=$1
DEST=$2
ALIASES=/etc/aliases
ENTRY="`grep $SOURCE: $ALIASES`"
dialog --backtitle "$TITLE" --infobox "Creo un alias per redirigere le mail per $SOURCE a $DEST ..." 0 0
if [ ! "$ENTRY" ]
then
echo "$SOURCE: $DEST" >>$ALIASES
else
OLDDEST="`echo $ENTRY | cut -f2 -d:`"
mkstemp alias
sed /"$SOURCE:"/s/"$OLDDEST"/" $DEST"/ $ALIASES >$tmp_alias
cat $tmp_alias >$ALIASES
rm $tmp_alias
fi
mkaliases >/dev/null
}
# Args: Areas_pathname, newsgroup, area_ftn, description [, expire_days]
# Returns: 1 - innd not running
# 2 - already existing newsgroup
# 3 - already existing ftn_area
create_newsgroup() {
AREAS="$1"
NEWSGROUP="$2"
AREA="$3"
DESCRIPTION="$4"
EXPIRE_DAYS="$5"
NEWSGROUPS=~news/newsgroups
EXPIRECTL=~news/expire.ctl
dialog --backtitle "$TITLE" --infobox "Creo il newsgroup $NEWSGROUP per contenere i messaggi dell'area $AREA..." 0 0
if [ ! "`ps ax | grep ~news/etc/innd`" ]
then
return 1
fi
if [ "`cut $NEWSGROUPS -f1 | cut -f1 -d\ | grep -x $NEWSGROUP`" ]
then
return 2
fi
if [ "`cut $AREAS -f1 | cut -f1 -d\ | grep -x $AREA`" ]
then
return 3
fi
su -l news -c "bin/ctlinnd newgroup $NEWSGROUP" >/dev/null
echo -e "$NEWSGROUP\t$DESCRIPTION" >> $NEWSGROUPS
echo -e "$AREA\t$NEWSGROUP\t`echo $NEWSGROUP | cut -f1 -d.`" >> $AREAS
if [ "$EXPIRE_DAYS" ]; then
echo "$NEWSGROUP:A:2:$EXPIRE_DAYS:$EXPIRE_DAYS" >> $EXPIRECTL
fi
chown news.news $NEWSGROUPS $EXPIRECTL
chmod 440 $EXPIRECTL
chown fnet.uucp $AREAS
}
# Returns: 0 if ok, 1 if (innd not running), 2 if (no that newsgroup)
# Args: Areas_pathname, newsgroup
rmgroup() {
AREAS=$1
NEWSGR=$2
NEWSGROUPS=~news/newsgroups
EXPIRE=~news/expire.ctl
dialog --backtitle "$TITLE" --infobox "Elimino il newsgroup $NEWSGR ed i messaggi in esso contenuti, attendere prego. Questa operazione potrebbe durare alcuni minuti." 0 0
if [ ! "`ps x | grep ~news/etc/innd`" ]
then
return 1
fi
if [ ! "`cut -f1 $NEWSGROUPS | cut -f1 -d\ | grep -x $NEWSGR`" ]
then
return 2
else
# Updating newsgroups file
if [ -f $NEWSGROUPS ]
then
mkstemp groups
mv $NEWSGROUPS $NEWSGROUPS~
grep -v $NEWSGR $NEWSGROUPS~ >$tmp_groups
mv $tmp_groups $NEWSGROUPS
else
:> $NEWSGROUPS
fi
chown news.news $NEWSGROUPS
# Updating Areas file
if [ -f $AREAS ]
then
mkstemp areas
mv $AREAS $AREAS~
grep -v $NEWSGR $AREAS~ >$tmp_areas
mv $tmp_areas $AREAS
else
:> $AREAS
fi
chown fnet.uucp $AREAS
# Updating expire.ctl file
if [ -f $EXPIRE ]
then
mkstemp expire
mv $EXPIRE $EXPIRE~
grep -v "$NEWSGR:" $EXPIRE~ >$tmp_expire
mv $tmp_expire $EXPIRE
else
:> $EXPIRE
fi
chown news.news $EXPIRE
chmod 444 $EXPIRE
# Remove pending articles
echo -e "\n$NEWSGR:A:0:0:0" >>$EXPIRE
su -l news -c "bin/news.daily" >/dev/null
mkstemp expire
grep -v $NEWSGR $EXPIRE >$tmp_expire
mv $tmp_expire $EXPIRE
chown news.news $EXPIRE
chmod 444 $EXPIRE
# Updating active file
su -l news -c "bin/ctlinnd rmgroup $NEWSGR" >/dev/null
fi
}
# Args: newsgroups_wildmat, days_to_keep
set_expire_time() {
NEWSGROUP="$1"
KEEPDAYS="$2"
EXPIRE=~news/expire.ctl
dialog --backtitle "$TITLE" --infobox "Imposto a $KEEPDAYS il numero di giorni di mantenimento dei messaggi del newsgroup $NEWSGROUP..." 0 0
if [ ! -f $EXPIRE ]
then
:> $EXPIRE
elif [ "`cut $EXPIRE -s -f1 -d: | grep -x $NEWSGROUP`" ]
then
mkstemp expire
grep -v "$NEWSGROUP:" $EXPIRE >$tmp_expire
mv $tmp_expire $EXPIRE
fi
echo -e "\n$NEWSGROUP:A:2:$KEEPDAYS:$KEEPDAYS" >>$EXPIRE
chown news.news $EXPIRE
chmod 444 $EXPIRE
}
|