Code

Various cleanup works.
[pkg-mlmmj.git] / debian / patches / 01_debian_make_mlmmj-ml.dpatch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 01_debian_make_mlmmj-ml.dpatch by  <boll@andariel>
3 ##
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: This patch adds a new mlmmj-make-ml
7 @DPATCH@
8 diff -urNad --exclude=CVS --exclude=.svn ./debian/mlmmj-make-ml.sh /tmp/dpep-work.l7evJe/mlmmj-1.2.8/debian/mlmmj-make-ml.sh
9 --- ./debian/mlmmj-make-ml.sh   1970-01-01 01:00:00.000000000 +0100
10 +++ /tmp/dpep-work.l7evJe/mlmmj-1.2.8/debian/mlmmj-make-ml.sh   2005-09-10 21:33:20.000000000 +0200
11 @@ -0,0 +1,201 @@
12 +#!/bin/sh
13 +#
14 +# mlmmj-make-ml.sh - henne@hennevogel.de
15 +#
16 +# modified for Debian GNU/Linux by boll@debian.org
17 +
18 +VERSION="0.1-debian (Modified for Debian GNU/Linux)"
19 +DEFAULTDIR="/var/spool/mlmmj"
20 +ETCDEFAULTDIR="/etc/mlmmj/lists"
21 +TEXTPATH="/usr/share/mlmmj/text.skel"
22 +SENDMAILPKG=`grep-dctrl -FProvides mail-transport-agent -a -FStatus installed -sPackage -n /var/lib/dpkg/status`
23 +NEWALIASES=`which newaliases`
24 +
25 +USAGE="
26 +mlmmj-make-ml $VERSION
27 +$0 [OPTIONS]
28 +-h     display this help text
29 +-L     the name of the mailinglist
30 +-s     your spool directory if not $DEFAULTDIR
31 +-z     nuffn for now
32 +"
33 +
34 +echo
35 +echo "+------------------------------------------------------------+"
36 +echo "| Information:                                               |"
37 +echo "| Please report bugs against mlmmj-make-ml to the Debian BTS |"
38 +echo "| at http://bugs.debian.org/                                 |"
39 +echo "+------------------------------------------------------------+"
40 +echo
41 +
42 +
43 +while getopts ":hL:s:az:" Option
44 +do
45 +case "$Option" in 
46 +       h )
47 +       echo "$USAGE"
48 +       exit 0
49 +       ;;
50 +       z )
51 +       echo -n "nothing"
52 +       exit 0
53 +       ;;
54 +       L )
55 +       LISTNAME="$OPTARG"
56 +       ;;
57 +       s )
58 +       SPOOLDIR="$OPTARG"
59 +       ;;
60 +       * )
61 +       printf "$0: invalid option\nTry $0 -h for more information.\n"
62 +       exit 1
63 +       ;;
64 +esac
65 +done
66 +SHIFTVAL=$(( $OPTIND - 1 ))
67 +shift $SHIFTVAL
68 +
69 +if [ -z "$SPOOLDIR" ]; then
70 +       SPOOLDIR="$DEFAULTDIR"
71 +fi
72 +
73 +echo "Creating Directorys below $SPOOLDIR. Use '-s spooldir' to change"
74 +
75 +if [ -z "$LISTNAME" ]; then
76 +       echo -n "What should the name of the Mailinglist be? [mlmmj-test] : "
77 +       read LISTNAME
78 +       if [ -z "$LISTNAME" ]; then
79 +       LISTNAME="mlmmj-test"
80 +       fi
81 +fi
82 +
83 +LISTDIR="$SPOOLDIR/$LISTNAME"
84 +ETCLISTDIR="$ETCDEFAULTDIR/$LISTNAME"
85 +
86 +mkdir -p $LISTDIR
87 +mkdir -p $ETCLISTDIR
88 +
89 +for DIR in incoming queue queue/discarded archive subconf unsubconf \
90 +          bounce moderation subscribers.d digesters.d requeue \
91 +          nomailsubs.d
92 +do
93 +       mkdir "$LISTDIR"/"$DIR"
94 +done
95 +
96 +for DIR in text control
97 +do
98 +       mkdir "$ETCLISTDIR"/"$DIR"
99 +       ln -s "$ETCLISTDIR"/"$DIR" "$LISTDIR"/"$DIR"
100 +done
102 +test -f "$LISTDIR"/index || touch "$LISTDIR"/index
104 +echo -n "The Domain for the List? [] : "
105 +read FQDN
106 +if [ -z "$FQDN" ]; then
107 +       FQDN="localhost.localdomain"
108 +fi
110 +echo -n "The emailaddress of the list owner? [postmaster] : "
111 +read OWNER
112 +if [ -z "$OWNER" ]; then
113 +       OWNER="postmaster"
114 +fi
115 +echo "$OWNER" > "$ETCLISTDIR"/"control/owner"
117 +if [ -z "$TEXTPATH" -o ! -d "$TEXTPATH" ]; then
118 +       echo "**NOTE** Could not copy the texts for the list"
119 +       echo "Please manually copy the files from $TEXTPATH"
120 +else
121 +       cp "$TEXTPATH"/* "$ETCLISTDIR"/"text"
122 +fi
124 +LISTADDRESS="$LISTNAME@$FQDN"
125 +echo "$LISTADDRESS" > "$ETCLISTDIR"/control/"listaddress"
127 +MLMMJRECIEVE=`which mlmmj-recieve 2>/dev/null`
128 +if [ -z "$MLMMJRECIEVE" ]; then
129 +       MLMMJRECIEVE="/usr/bin/mlmmj-recieve"
130 +fi
132 +MLMMJMAINTD=`which mlmmj-maintd 2>/dev/null`
133 +if [ -z "$MLMMJMAINTD" ]; then
134 +       MLMMJMAINTD="/usr/bin/mlmmj-maintd"
135 +fi
137 +ALIAS="$LISTNAME:  \"|$MLMMJRECIEVE -L $SPOOLDIR/$LISTNAME/\""
139 +echo "I am adding the following to your /etc/aliases file:"
140 +echo "$ALIAS"
141 +echo -n "is this ok (if not, you need to do so yourself)? [y/N] : "
142 +read OKIDOKI
143 +case $OKIDOKI in
144 +       y|Y)
145 +               echo "$ALIAS" >> /etc/aliases
146 +               ;;
147 +       n|N)
148 +               exit 0
149 +               ;;
150 +       *)
151 +               echo "Options were: y, Y, n or N"
152 +esac
154 +echo "Detecting the installed MTA and changing ownership as needed..."
156 +if [ "$SENDMAILPKG" = "postfix" ]; then
157 +       USER="nobody"
158 +       GROUP="nogroup"
159 +       echo "Postfix appears to be handling your mail, using ownership $USER:$GROUP..."
160 +elif [ "$SENDMAILPKG" = "exim4-daemon-light" ]; then
161 +       USER="Debian-exim"
162 +       GROUP="Debian-exim"
163 +       echo "Exim appears to be handling your mail, using ownership $USER:$GROUP..."
164 +else
165 +       USER="nobody"
166 +       GROUP="nogroup"
167 +       echo "Unable to detect MTA, using default ownership: $USER:$GROUP..."
168 +fi
170 +chown -R $USER:$GROUP $LISTDIR $LISTDIR/*
171 +chmod -R 755 $LISTDIR
172 +chmod -R 755 $ETCLISTDIR
174 +# Check if all lists are owned by the right user, if not, ask if we should fix
175 +# it.
177 +ANOMALIES=0
179 +for ENTRY in `ls $SPOOLDIR`
180 +do
181 +        SOWNER=`stat -c %U $SPOOLDIR/$ENTRY`
182 +        SGROUP=`stat -c %G $SPOOLDIR/$ENTRY`
184 +       if [ $SOWNER != $USER -o $SGROUP != $GROUP ]
185 +               then
186 +                       ANOMALIES=1
187 +       fi
188 +done
190 +if [ $ANOMALIES -eq 1 ]
191 +       then
192 +               echo -n "It appears that not all lists have proper ownership, do you want me to fix this? [y/N] : "
193 +               read FIXOWNERSHIP
194 +               case $FIXOWNERSHIP in
195 +                       y|Y)
196 +                               chown -R $USER:$GROUP $SPOOLDIR/*
198 +                               ;;
199 +                       n|N)
200 +                               echo "Not fixing ownership"
201 +                               ;;
202 +                       *)
203 +                               echo "Options were: y, Y, n or N"
204 +               esac
205 +                                                                                                                       
206 +               
207 +fi
209 +echo "Running $NEWALIASES"
210 +$NEWALIASES
212 +echo "Done."