chiark / gitweb /
probes: started feature
[modbot-mtm.git] / install-newsgroup
1 #!/bin/bash
2 set -e
3
4 . get-settings
5
6 mkdir -p stump/tmp/messages
7 mkdir -p stump/data
8 mkdir -p webstump/queues/$GROUP
9 mkdir -p webstump/log
10 mkdir -p xlog/log/$GROUP/public
11
12 ngdir=webstump/config/newsgroups/$GROUP
13 mkdir -p $ngdir
14 cp webstump/skeleton/*.IN[1O] $ngdir/.
15
16 exec <moderators
17
18 mods=$ngdir/moderators
19 exec 3>$mods.new
20
21 test -f $mods || touch $mods
22
23 while read name email; do
24         set +e
25         grep "^$name " $mods >$mods.tmp
26         rc=$?
27         set -e
28         case $rc in
29         0)      ;;
30         1)
31                 pass=`perl -e </dev/urandom '
32                         select(STDIN); $|=1; select(STDOUT);
33                         for $x (0..7) {
34                                 read(STDIN,$bin,4) == 4 or die $!;
35                                 $v= unpack "l",$bin;
36                                 $v %= 36;
37                                 printf "%c", $v<10
38                                         ? $v+ord("0")
39                                         : $v-10+ord("A");
40                         }
41                         print "\n";
42                 '`
43                 echo "$name $pass" >$mods.tmp
44
45                 mail -s "your $ABBREV moderator password" <<END "$email"
46 The moderation interface for $GROUP is here:
47   $CGIBASEURL/g.$ABBREV/webstump?action=login_screen&newsgroup=$GROUP
48
49 Your username and password for the moderation interface are:
50   $name
51   $pass
52 These are _not_ case sensitive (!)
53
54 Please see other emails for further information.
55
56 Regards,
57 moderation system administrator
58 END
59                 ;;
60         *)
61                 echo >&2 "huh $rc ?"; exit 1
62                 ;;
63         esac
64         cat $mods.tmp >&3
65         rm $mods.tmp
66 done
67
68 exec <$mods
69 while read name pass; do
70         set +e
71         grep "^$name " $mods.new >$mods.tmp
72         rc=$?
73         set -e
74         case $rc in
75         0)      ;;
76         1)
77                 echo "*** Removing obsolete moderator $name"
78                 ;;
79         *)
80                 echo >&2 "huh2 $rc ?"; exit 1
81                 ;;
82         esac
83         rm $mods.tmp
84 done
85
86 mv -f $mods.new $mods