File: mlmmj-make-ml.sh.in

package info (click to toggle)
mlmmj 1.2.17-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,836 kB
  • ctags: 585
  • sloc: ansic: 8,973; sh: 4,521; php: 1,057; perl: 643; makefile: 156
file content (184 lines) | stat: -rwxr-xr-x 3,639 bytes parent folder | download
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
#!/bin/sh
#
# mlmmj-make-ml.sh - henne@hennevogel.de
#

VERSION="0.1"
DEFAULTDIR="/var/spool/mlmmj"
ALIASFILE=/etc/aliases

USAGE="mlmmj-make-ml "$VERSION"
"$0" [OPTIONS]

-h	display this help text
-L	the name of the mailinglist
-s	your spool directory if not "$DEFAULTDIR"
-a	create the needed entrys in your $ALIASFILE file
-z	nuffn for now
-c	chown the spool dir"

while getopts ":hL:s:azc:" Option
do
case "$Option" in 
	h )
	echo -e "$USAGE"
	exit 0
	;;
	z )
	echo -n "nothing"
	exit 0
	;;
	L )
	LISTNAME="$OPTARG"
	;;
	s )
	SPOOLDIR="$OPTARG"
	;;
	a )
	A_CREATE="YES"
	;;
	c )
	DO_CHOWN=1
	CHOWN="$OPTARG"
	;;
	* )
	echo -e "$0: invalid option\nTry $0 -h for more information."
	exit 1
esac
done
SHIFTVAL=$((OPTIND-1))
shift $SHIFTVAL

if [ -z "$SPOOLDIR" ]; then
	SPOOLDIR="$DEFAULTDIR"
fi

echo "Creating Directorys below $SPOOLDIR. Use '-s spooldir' to change"

if [ -z "$LISTNAME" ]; then
	echo -n "What should the name of the Mailinglist be? [mlmmj-test] : "
	read LISTNAME
	if [ -z "$LISTNAME" ]; then
	LISTNAME="mlmmj-test"
	fi
fi

LISTDIR="$SPOOLDIR/$LISTNAME"

mkdir -p $LISTDIR

for DIR in incoming queue queue/discarded archive text subconf unsubconf \
	   bounce control moderation subscribers.d digesters.d requeue \
	   nomailsubs.d
do
	mkdir "$LISTDIR"/"$DIR"
done

test -f "$LISTDIR"/index || touch "$LISTDIR"/index

echo -n "The Domain for the List? [] : "
read FQDN
if [ -z "$FQDN" ]; then
	FQDN=`domainname -f`
fi

echo -n "The emailaddress of the list owner? [postmaster] : "
read OWNER
if [ -z "$OWNER" ]; then
	OWNER="postmaster"
fi
echo "$OWNER" > "$LISTDIR"/"control/owner"

(
	cd "@textlibdir@"
	echo
	echo "For the list texts you can choose between the following languages or"
	echo "give a absolute path to a directory containing the texts."
	echo
	echo "Available languages:"
	ls

	TEXTPATHDEF=en
	echo -n "The path to texts for the list? [$TEXTPATHDEF] : "
	read TEXTPATHIN
	if [ -z "$TEXTPATHIN" ] ; then
		TEXTPATH="$TEXTPATHDEF"
	else
		TEXTPATH="$TEXTPATHIN"
	fi
	if [ ! -d "$TEXTPATH" ]; then
		echo
		echo "**NOTE** Could not copy the texts for the list"
		echo "Please manually copy the files from the listtexts/ directory"
		echo "in the source distribution of mlmmj."
		sleep 2
	else
		cp "$TEXTPATH"/* "$LISTDIR"/"text"
	fi
)

LISTADDRESS="$LISTNAME@$FQDN"
echo "$LISTADDRESS" > "$LISTDIR"/control/"listaddress"

MLMMJRECIEVE=`which mlmmj-recieve 2>/dev/null`
if [ -z "$MLMMJRECIEVE" ]; then
	MLMMJRECIEVE="/path/to/mlmmj-recieve"
fi

MLMMJMAINTD=`which mlmmj-maintd 2>/dev/null`
if [ -z "$MLMMJMAINTD" ]; then
	MLMMJMAINTD="/path/to/mlmmj-maintd"
fi

ALIAS="$LISTNAME:  \"|$MLMMJRECIEVE -L $SPOOLDIR/$LISTNAME/\""
CRONENTRY="0 */2 * * * \"$MLMMJMAINTD -F -L $SPOOLDIR/$LISTNAME/\""

if [ -n "$A_CREATE" ]; then
	echo "I want to add the following to your $ALIASFILE file:"
	echo "$ALIAS"

	echo -n "is this ok? [y/N] : "
	read OKIDOKI
	case $OKIDOKI in
		y|Y)
		echo "$ALIAS" >> $ALIASFILE
		;;
		n|N)
		exit 0
		;;
		*)
		echo "Options was: y, Y, n or N"
	esac
else
	echo
	echo "Don't forget to add this to $ALIASFILE:"
	echo "$ALIAS"
fi

if [ "$DO_CHOWN" ] ; then
	echo
	echo -n "chown -R $CHOWN $SPOOLDIR/$LISTNAME? [y/n]: "
	read OKIDOKI
	case $OKIDOKI in
		y|Y)
			chown -R $CHOWN $SPOOLDIR/$LISTNAME
		;;
		n|N)
			exit 0
		;;
		*)
			echo "option is: y, Y, n, N"
		;;
	esac
fi

echo
echo "If you're not starting mlmmj-maintd in daemon mode,"
echo "don't forget to add this to your crontab:"
echo "$CRONENTRY"

echo
echo " ** FINAL NOTES **
1) The mailinglist directory have to be owned by the user running the 
mailserver (i.e. starting the binaries to work the list)
2) Run newaliases"