This file is indexed.

postinst is in sympa 6.1.17~dfsg-1.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
#!/bin/sh

#
# postinst script for sympa
#

set -e

if [ -f /usr/share/debconf/confmodule ]; then
	. /usr/share/debconf/confmodule
fi

if [ -f /usr/share/dbconfig-common/dpkg/postinst ]; then
	. /usr/share/dbconfig-common/dpkg/postinst
fi

conf=/etc/sympa/sympa.conf
wwconf=/etc/sympa/wwsympa.conf

sympa_version() {
	perl -e "use lib '/usr/share/sympa/lib'; use Sympa::Constants; print Sympa::Constants::VERSION;"
}

# creating sympa user if he isn't already there
if ! getent passwd sympa >/dev/null ; then
	echo "Adding system user: sympa."
	# We use --force-badname in case of a not compatible NAME_REGEX in /etc/adduser.conf (see #328053)
	adduser --force-badname --system --group --gecos "Sympa mailing list manager" --no-create-home --home /var/lib/sympa sympa >/dev/null
fi

# /etc/sympa/data_structure.version should not be handled as a conffile as it
# is modified by sympa upgrade tool and it breaks the sympa upgrade process
# itsself (#655967)
if [ -f /etc/sympa/data_structure.version ] && [ ! -f /etc/sympa/data_structure.version.debian-old ]; then
	cp /etc/sympa/data_structure.version /etc/sympa/data_structure.version.debian-old
fi
if which dpkg-maintscript-helper >/dev/null && dpkg-maintscript-helper supports rm_conffile ; then
	dpkg-maintscript-helper rm_conffile /etc/sympa/data_structure.version \
		"6.1.11~dfsg-1~" -- "$@"
fi

# Ensure that data structure version file exists and is writable for Sympa
if [ -f /etc/sympa/data_structure.version.debian-old ]; then
	cp /etc/sympa/data_structure.version.debian-old /etc/sympa/data_structure.version
	rm -f /etc/sympa/data_structure.version.debian-old
fi
if [ ! -f /etc/sympa/data_structure.version ]; then
	sympa_version > /etc/sympa/data_structure.version
fi
chown sympa:sympa /etc/sympa/data_structure.version

# Remove conffiles used by apache2 < 2.4
if which dpkg-maintscript-helper >/dev/null && dpkg-maintscript-helper supports rm_conffile ; then
	for i in apache apache-soap httpd.conf-cgi httpd.conf-fcgi ; do
		dpkg-maintscript-helper rm_conffile "/etc/sympa/${i}" \
			"6.1.17~dfsg-1~" -- "$@"
	done
fi

# Stop the daemon if it has already been started This is necessary when you run
# dpkg-reconfigure
if [ "$1" = "configure" ]; then
	if [ -f /etc/init.d/sympa ]; then
		if which invoke-rc.d >/dev/null 2>&1; then
			invoke-rc.d sympa stop || true
		else
			/etc/init.d/sympa stop || true
		fi
	fi
fi

# Install sympa.conf
if [ -f "$conf" ]; then
	# Replace/disable obsolete settings in configuration file
	perl -i -pe 's%^\s*msgcat(.*)%localedir /usr/lib/sympa/locale%; s%(\s*queueexpire.*)%# $1%;' "$conf"
	perl -i -pe 's%^\s*(dkim_header_list.*)$%#$1%;' "$conf"
else
	# Create congfiguration file
	/usr/lib/sympa/bin/sympa_wizard.pl --create sympa.conf --target "$conf"
	perl -i -pe 's%^#?(cookie\s+).*%cookie `cat /etc/sympa/cookie`%; s%^(syslog\s+).*%syslog `cat /etc/sympa/facility`%;' "$conf"
fi

# Install wwsympa.conf even if WWSympa is not used, we need to provide a
# default wwsympa.conf
if [ ! -f "$wwconf" ]; then
	/usr/lib/sympa/bin/sympa_wizard.pl --create wwsympa.conf --target "$wwconf"
	perl -i -pe 's%^(arc_path\s+).*%$1/var/lib/sympa/wwsarchive%; s%^(bounce_path\s+).*%$1/var/spool/sympa/wwsbounce%' "$wwconf"
fi

# Configure the language
db_get sympa/language
lang="$RET"
perl -pi -e "s/^\s*lang.*$/lang\t\t$lang/;" "$conf"

# Fixing supported_lang if empty
perl -i -pe "s/^\s*(supported_lang)\s*\$/\$1\t\tnone\n/;" "$conf"

# Get the hostname
db_get sympa/hostname
hostn="$RET"
if grep -q "^[[:space:]]*host" "$conf" ; then
	perl -pi -e "s/^\s*host.*$/domain\t\t$hostn/;" "$conf"
else
	perl -pi -e "s/^\s*domain.*$/domain\t\t$hostn/;" "$conf"
fi

# Get the listmasters and escape '@' caracters for Perl processing. Ugly, anyway ...
db_get sympa/listmaster
listmaster=$(echo $RET | sed 's/@/\\@/g')
perl -pi -e "s/^\s*listmaster.*$/listmaster\t\t$listmaster/;" "$conf"

if [ "$1" = "configure" ] && [ -n "$2" ] && dpkg --compare-versions "$2" lt "6.0.1"; then
	# add required parameters in Sympa 6
	if ! grep -q -e '^bounce_warn_rate' $conf; then
		echo "bounce_warn_rate 30" >> $conf;
	fi
	if ! grep -q -e '^bounce_halt_rate' $conf; then
		echo "bounce_halt_rate 50" >> $conf;
	fi
	# fix paths
	perl -pi -e "s%^home\s+/usr/lib/sympa/expl$%home /var/lib/sympa/expl%; s%^static_content_path\s+/usr/lib/sympa/static_content%static_content_path /var/lib/sympa/static_content%;" "$conf"
fi

## ensure permissions and ownerships are right
if [ -e /var/log/sympa.log ] && [ ! -f /var/log/sympa.log ]; then
	echo "Problem: /var/log/sympa.log already exists and it isn't a file !"
fi
touch /var/log/sympa.log || true
chown sympa:sympa /var/log/sympa.log
chmod 0640 /var/log/sympa.log

# Upgrade workaround problem in case of the old list home directory does not
# contain any list configuration and was removed on upgrade.
if [ ! -d /var/spool/sympa/expl ]; then
	sed -i -e "s;\([^#]*\)/var/spool/sympa/expl;\1/var/lib/sympa/expl;" "$conf"
fi

chown -R sympa:sympa /etc/sympa/*
chmod 0640 "$conf" /etc/sympa/sympa.conf-smime.in

# Get rid of the old /etc/sympa/config directory
if [ -d /etc/sympa/config ]; then
	rm -f /etc/sympa/config/helpfile
	rm -f /etc/sympa/config/helpfile.advanced
	rm -f /etc/sympa/config/lists
	rmdir /etc/sympa/config || true
fi

# Add the sympa aliases
if ! grep -q "#-- SYMPA begin" /etc/aliases
then
	cat >>/etc/aliases <<EOF
#-- SYMPA begin
## Aliases used for the sympa mailing-list manager
sympa:		"|/usr/lib/sympa/bin/queue sympa"
sympa-request:	postmaster
sympa-owner:	postmaster
listmaster:	postmaster
#-- SYMPA end
EOF
	newaliases
fi

# Moving alias files to a destination where SYMPA can write
# and create the db alias file with the right permissions
# from /etc/mail/sympa.aliases to /etc/mail/sympa/aliases
if [ ! -d /etc/mail/sympa ]; then
	mkdir -p /etc/mail/sympa
fi
if [ -d /etc/mail/sympa ]; then
	chown sympa:sympa /etc/mail/sympa
	for ext in '' '.db' ; do
		if [ ! -f /etc/mail/sympa/aliases${ext} ] && [ -f /etc/mail/sympa.aliases${ext} ] && [ ! -h /etc/mail/sympa/aliases${ext} ]; then
			mv /etc/mail/sympa.aliases${ext} /etc/mail/sympa/aliases${ext}
			ln -s /etc/mail/sympa/aliases${ext} /etc/mail/sympa.aliases${ext}
			chown -h sympa:sympa /etc/mail/sympa.aliases${ext}
		fi
	done
fi

# Create file for mailing list aliases
if [ ! -f /etc/mail/sympa/aliases ]; then
	echo "## List aliases used for the sympa mailing-list manager" > /etc/mail/sympa/aliases
fi

# Ensure permissions are correct
for ext in '' '.db' ; do
	if [ -f /etc/mail/sympa/aliases${ext} ]; then
		chown sympa:sympa /etc/mail/sympa/aliases${ext}
	fi
done

## Setup a syslog facility
if which syslog-facility >/dev/null 2>&1 \
		&& [ -e /etc/syslog.conf ] \
		&& ! grep -q "/var/log/sympa.log" /etc/syslog.conf \
		&& syslog-facility set all /var/log/sympa.log > /etc/sympa/facility \
		&& [ -x /etc/init.d/sysklogd ]; then
	if which invoke-rc.d >/dev/null 2>&1; then
		invoke-rc.d sysklogd reload
	else
		etc/init.d/sysklogd reload
	fi
fi
## ...and ensure existence and access rights of facility file even if unused
if [ ! -e /etc/sympa/facility ]; then
	touch /etc/sympa/facility
fi
chown sympa:sympa /etc/sympa/facility

## Create a unique cookie for this host
if [ ! -e /etc/sympa/cookie ]; then
	touch /etc/sympa/cookie
	chmod 0660 /etc/sympa/cookie
	chown sympa:sympa /etc/sympa/cookie
	if [ -r /dev/urandom ]; then
		dd if=/dev/urandom bs=1k count=1 2>/dev/null \
		| md5sum | cut -d " " -f 1 >>/etc/sympa/cookie
	else
		(free; uptime; ps aux) | md5sum | cut -d " " -f 1 >>/etc/sympa/cookie
	fi
fi

if [ ! -e /etc/sympa/cookies.history ]; then
	cp /etc/sympa/cookie /etc/sympa/cookies.history
	chmod 0660 /etc/sympa/cookies.history
	chown sympa:sympa /etc/sympa/cookies.history
fi

## Look for bad path in aliases file (why the hell did they move the files ?)
if grep -q "/usr/lib/sympa/queue" /etc/aliases ; then
	echo "WARNING : The path of the queue program is bad in the aliases file"
	echo "Change /usr/lib/sympa/queue by /usr/lib/sympa/bin/queue !"
	echo "I'll create a symlink to prevent problems from happening..."
	echo ""
	ln -sf bin/queue /usr/lib/sympa/queue
fi

# setup Sendmail smrsh links
if [ -d /etc/mail/smrsh ]; then
	ln -sf /usr/lib/sympa/bin/bouncequeue /etc/mail/smrsh
	ln -sf /usr/lib/sympa/bin/queue /etc/mail/smrsh
fi

dbc_first_version="5.3.4-6~"
dbc_dbfile_owner="sympa:sympa"
dbc_go sympa $@

# Check whether a DB driver is installed
installed_dbd() {
	driver=$1
	if perl -MDBD::$driver -e ';' >/dev/null 2>&1 ; then
		return 0
	fi
	return 1
}

# Translate database parameters from dbconfig-common to Sympa's db_xxx
# configuration values
name=$dbc_dbname
case "$dbc_dbtype" in
	mysql)
		type=mysql
		;;
	pgsql)
		type=Pg
		;;
	sqlite3)
		type=SQLite
		name="$dbc_basepath/$dbc_dbname"
		;;
	*)
		echo "Unknown database type $dbc_dbtype."
		exit 1
		;;
esac

# Install the database configuration
NEW=$(perl -i -pe "BEGIN {
%db= (type => '$type', name => '$name', host => '$dbc_dbserver', user => '$dbc_dbuser', passwd => '$dbc_dbpass', options => '$dbc_dboptions', port => '$dbc_dbport');}; "'
END {
	for (keys %db) {
		if ($db{$_}) {
			print "db_$_ $db{$_}\n"
		}
	}
};
s%^(\s*db_)(\w+)(\s+)(.*)%
if (exists $db{$2}) {
	if ($db{$2}) {
		$var = $db{$2};
		$db{$2} = "";
		"$1$2$3$var";
	} else {
		"# $1$2$3$4";
	}
} else {
	"$1$2$3$4";
}%e;' "$conf")

if [ -n "$NEW" ]; then
	echo "$NEW" >> "$conf"
fi

# Upgrade workaround problem in case of the old web archive directory does not
# contain any archive file and was removed on upgrade.
if [ ! -d /var/spool/sympa/wwsarchive ]; then
	sed -i -e "s;\([^#]*\)/var/spool/sympa/wwsarchive;\1/var/lib/sympa/wwsarchive;" "$wwconf"
fi

echo "Ensuring that permissions and ownerships are right (this can take a while)..."
# Ensure permissions and ownerships are right
chown sympa:sympa "$conf" "$wwconf" /etc/sympa/topics.conf
chmod 0640 "$conf" "$wwconf"

# set default permissions for sympa's data directory except static_content
# which has to be readable by the webserver
find /var/lib/sympa /var/spool/sympa \
	-maxdepth 1 -type d -not -name 'static_content' \
	-exec chmod 0771 {} \;

# It's better to search files and directories with wrong owner/group and fix
# them instead of recursively doing it, even if it's not needed (see #630384)
find /var/spool/sympa /var/lib/sympa \
	\( -not -user sympa -or -not -group sympa \) \
	-exec chown sympa:sympa {} \;

# Fix permissions on MTA tools wrappers
chmod u+s /usr/lib/sympa/bin/aliaswrapper
chmod u+s /usr/lib/sympa/bin/virtualwrapper

# Fix permissions on CGI wrappers
chown sympa:sympa /usr/lib/cgi-bin/sympa/wwsympa-wrapper.fcgi \
	/usr/lib/cgi-bin/sympa/sympa_soap_server-wrapper.fcgi
chmod 6755 /usr/lib/cgi-bin/sympa/wwsympa-wrapper.fcgi \
	/usr/lib/cgi-bin/sympa/sympa_soap_server-wrapper.fcgi

# Fix permission on *queue binaries
chown sympa:sympa /usr/lib/sympa/lib/sympa/*
chmod u+s /usr/lib/sympa/lib/sympa/*

# WebServer configuration
db_get wwsympa/webserver_type
webserver="$RET"

case $webserver in
	"Apache 2")
		webserver="apache2"
		;;
	*)
		webserver="none"
		;;
esac

# Check whether the Web server is installed
if [ -f /etc/$webserver/httpd.conf ]; then
	echo "$webserver: installation seems OK ..."
else
	webserver="none"
fi

# Read FastCGI setting
db_get wwsympa/fastcgi
fastcgi="$RET"
if [ "$fastcgi" = "true" ]; then
	if [ $webserver = "apache2" ]; then
		if [ ! -f /etc/apache2/mods-enabled/fcgid.load ] && [ ! -f /etc/apache2/mods-enabled/fastcgi.load ]; then
			echo "FastCGI module not installed or enabled, skipping."
			fastcgi="false"
		fi
	fi
fi
if [ "$fastcgi" = "true" ]; then
	perl -pi -e 's%^\s*(use_fast_cgi)\s+\d+%$1\t1%' "$wwconf"
else
	perl -pi -e 's%^\s*(use_fast_cgi)\s+\d+%$1\t0%' "$wwconf"
fi

db_get wwsympa/wwsympa_url
wwsympa_url="$RET"
perl -i -pe "s%^(wwsympa_url\s+).*%wwsympa_url ${wwsympa_url}%" "$conf"

db_get sympa/use_soap
use_soap="$RET"
# Use SOAP
if [ "$use_soap" = "true" ]; then
	if ! grep -q soap_url "$conf"; then
		echo "soap_url http://${hostn}/sympasoap" >> "$conf"
	else
		perl -pi -e "s%^(soap_url\s+).*%soap_url  http://$hostn/sympasoap%" "$conf"
	fi
fi

# Cleanup sympa configuration files used by Apache2 << 2.4
for suffix in '' '-soap' ; do
	if [ -h "/etc/apache2/conf.d/sympa${suffix}" ] && \
		[ "$(readlink -f "/etc/apache2/conf.d/sympa${suffix}")" = "/etc/sympa/apache${suffix}" ]; then
		rm -f "/etc/apache2/conf.d/sympa${suffix}"
	fi
done

# WebServer configuration
db_get wwsympa/webserver_type
webserver="$RET"

if [ "$webserver" = "Apache 2" ]; then
	if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
		# Apache2 >= 2.4
		. /usr/share/apache2/apache2-maintscript-helper
		apache2_invoke enconf sympa.conf
		if [ "$use_soap" = "true" ]; then
			apache2_invoke enconf sympa-soap.conf
		else
			#apache2_invoke disconf sympa-soap.conf
			#
			# FIXME: Workaround disconf no (yet?) supported in postinst
			#
			rm -f /etc/apache2/conf-enabled/sympa-soap.conf
			export APACHE2_NEED_ACTION=1
			apache2_reload reload
		fi
	fi
else
	if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
		# Apache2 >= 2.4
		. /usr/share/apache2/apache2-maintscript-helper
		#apache2_invoke disconf sympa.conf
		#apache2_invoke disconf sympa-soap.conf
		#
		# FIXME: Workaround disconf no (yet?) supported in postinst
		#
		rm -f /etc/apache2/conf-enabled/sympa.conf
		rm -f /etc/apache2/conf-enabled/sympa-soap.conf
		export APACHE2_NEED_ACTION=1
		apache2_reload reload
	fi
fi

su -l sympa -s /bin/sh -c "/usr/lib/sympa/bin/sympa.pl --upgrade"

## End up with debconf
db_stop

# Automatically added by dh_installinit
if [ -x "/etc/init.d/sympa" ] || [ -e "/etc/init/sympa.conf" ]; then
	if [ ! -e "/etc/init/sympa.conf" ]; then
		update-rc.d sympa defaults 50 >/dev/null
	fi
	invoke-rc.d sympa start || exit $?
fi
# End automatically added section


exit 0