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 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532
|
#!/bin/sh -e
# creating sympa user if he isn't already there
if ! id sympa >/dev/null 2>/dev/null ; then
echo Adding system user: sympa.
adduser --system --group --gecos "Sympa mailing list manager" --no-create-home --home /var/lib/sympa sympa >/dev/null
fi
# Source debconf library
. /usr/share/debconf/confmodule
# Stop the daemon if it has already been started
# This is necessary when you run dpkg-reconfigure
if [ "$1" = "configure" ]; then
if [ -f /var/run/sympa/sympa.pid ]
then
set +e
/etc/init.d/sympa stop
set -e
fi
fi
# Ensure that directory exists
if [ ! -d /etc/sympa ]; then
mkdir /etc/sympa
fi
# Ensure that data structure version file exists
# and is writable for Sympa
if [ ! -f /etc/sympa/data_structure.version ]; then
if [ "$1" = "configure" ]; then
if [ -n "$2" ] && dpkg --compare-versions "$2" lt "5.2.3";
then
echo "$2" > /etc/sympa/data_structure.version
else
touch /etc/sympa/data_structure.version
fi
fi
fi
chown sympa:sympa /etc/sympa/data_structure.version
# Install sympa.conf
if [ -f /etc/sympa/sympa.conf ]; then
# Replace obsolete msgcat setting in configuration file
perl -i -pe 's%^msgcat(.*)%localedir /usr/lib/sympa/locale%' /etc/sympa/sympa.conf
fi
if [ ! -f /etc/sympa/sympa.conf ]; then
/usr/lib/sympa/bin/sympa_wizard.pl -c sympa.conf -f /etc/sympa/sympa.conf
perl -i -pe 's%^(cookie\s+).*%cookie `/bin/cat /etc/sympa/cookie`%' /etc/sympa/sympa.conf
perl -i -pe 's%^(syslog\s+).*%syslog `/bin/cat /etc/sympa/facility`%' /etc/sympa/sympa.conf
fi
# Install wwsympa.conf
# Even if WWSympa is not used, we need to provide a default wwsympa.conf
if [ ! -f /etc/sympa/wwsympa.conf ]; then
/usr/lib/sympa/bin/sympa_wizard.pl -c wwsympa.conf -f /etc/sympa/wwsympa.conf
perl -i -pe 's%^(arc_path\s+).*%$1/var/lib/sympa/wwsarchive%; s%^(bounce_path\s+).*%$1/var/spool/sympa/wwsbounce%' /etc/sympa/wwsympa.conf
fi
# Configure the language
db_get sympa/language
lang="$RET"
perl -pi.old -e "s/^\s*lang.*$/lang\t\t$lang/;" /etc/sympa/sympa.conf
rm -f /etc/sympa/sympa.conf.old
# Get the hostname
db_get sympa/hostname
hostn="$RET"
if grep -q "^[ ]*host" /etc/sympa/sympa.conf ; then
perl -pi.old -e "s/^\s*host.*$/domain\t\t$hostn/;" /etc/sympa/sympa.conf
else
perl -pi.old -e "s/^\s*domain.*$/domain\t\t$hostn/;" /etc/sympa/sympa.conf
fi
rm -f /etc/sympa/sympa.conf.old
# Get the listmasters and escape '@' caracters for Perl processing. Ugly, anyway ...
db_get sympa/listmaster
listmaster=`echo $RET | sed 's/@/\\\\@/g'`
perl -pi.old -e "s/^\s*listmaster.*$/listmaster\t\t$listmaster/;" /etc/sympa/sympa.conf
rm -f /etc/sympa/sympa.conf.old
## ensure permissions and ownerships are right
chown -R root:root /usr/lib/sympa
chown -R sympa:sympa /var/spool/sympa /var/lib/sympa /var/run/sympa
chmod -R ug=rwX,o=X /var/spool/sympa /var/lib/sympa /var/run/sympa
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
## 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 -e "s;\([^#]*\)/var/spool/sympa/expl;\1/var/lib/sympa/expl;" \
/etc/sympa/sympa.conf > /etc/sympa/sympa.conf.new
mv /etc/sympa/sympa.conf.new /etc/sympa/sympa.conf
fi
chown -R sympa:sympa /etc/sympa/*
chmod 0640 /etc/sympa/sympa.conf /etc/sympa/sympa.conf-smime.in
touch /var/log/sympa.log || true
chown sympa:sympa /var/log/sympa.log
chmod 0640 /var/log/sympa.log
chown sympa:sympa /usr/lib/sympa/bin/queue /usr/lib/sympa/bin/bouncequeue
chmod 4755 /usr/lib/sympa/bin/queue /usr/lib/sympa/bin/bouncequeue
# 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
## 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
chown sympa:sympa /etc/mail/sympa.aliases
fi
## Setup a syslog facility
if [ -x /usr/sbin/syslog-facility ]; then
if [ -e /etc/syslog.conf ]; then
if ! grep -q "/var/log/sympa.log" /etc/syslog.conf ; then
syslog-facility set all /var/log/sympa.log > /etc/sympa/facility
if [ -x /etc/init.d/sysklogd ]; then
/etc/init.d/sysklogd reload
fi
fi
fi
fi
## If no facility file does exist then touch it
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
## Configure S/MIME support
db_get sympa/smime_support
smime="$RET"
# Remove the previous S/MIME configuration
if grep -q "^#-- S\/MIME configuration begin" /etc/sympa/sympa.conf; then
sed -e '/#-- S\/MIME configuration begin/,/#-- S\/MIME configuration end/d' \
/etc/sympa/sympa.conf >/etc/sympa/sympa.conf.new
mv /etc/sympa/sympa.conf.new /etc/sympa/sympa.conf
chown sympa:sympa /etc/sympa/sympa.conf
chmod 0640 /etc/sympa/sympa.conf
fi
if [ $smime = "true" ]; then
if [ -f /usr/bin/openssl ]; then
if ! grep -q "^#-- S/MIME configuration" /etc/sympa/sympa.conf ; then
db_get sympa/key_password
key_password="$RET"
sed -e "s/@KEY_PASSWORD@/$key_password/" \
/etc/sympa/sympa.conf-smime.in >>/etc/sympa/sympa.conf
chown sympa:sympa /etc/sympa/sympa.conf
fi
else
db_set sympa/smime_support "false"
echo "OpenSSL not found. Not configuring for S/MIME."
fi
fi
# 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
}
# Remove the database configuration
if grep -q "#-- Database configuration" /etc/sympa/sympa.conf
then
sed -e '/#-- Database configuration begin/,/#-- Database configuration end/d' \
/etc/sympa/sympa.conf >/etc/sympa/sympa.conf.new
mv /etc/sympa/sympa.conf.new /etc/sympa/sympa.conf
chown sympa:sympa /etc/sympa/sympa.conf
chmod 0640 /etc/sympa/sympa.conf
fi
# Check whether we want to use a database
db_get sympa/use_db
use_db="$RET"
if [ "$use_db" = "true" ]; then
db_get sympa/db_type
db_type="$RET"
db_get sympa/db_hostname
db_hostname="$RET"
if [ "$db_hostname" != "localhost" ]; then
db_get sympa/db_port
db_port="$RET"
else
db_port=""
fi
db_get sympa/db_name
db_name="$RET"
db_get sympa/db_user
db_user="$RET"
db_get sympa/db_passwd
db_passwd="$RET"
db_get sympa/db_options
db_options="$RET"
case $db_type in
"PostgreSQL")
db_type="Pg"
;;
"MySQL")
db_type="mysql"
;;
esac
## Install the database configuration
# Install mandatory parameters
/bin/echo -e "#-- Database configuration begin\n"\
"# DO NOT REMOVE SURROUNDING COMMENTS\n\n"\
"# DO NOT EDIT BY HAND\n"\
"# USE dpkg-reconfigure -plow sympa TO RECONFIGURE\n\n"\
"## Database driver (DBD)\n"\
"db_type\t\t$db_type\n\n"\
"## Name of your database\n"\
"db_name\t\t$db_name\n\n"\
"## Your database hostname\n"\
"db_host\t\t$db_hostname\n\n"\
"## Username to connect to the DB\n"\
"db_user\t\t$db_user\n"\ >> /etc/sympa/sympa.conf
# Install optional parameters
if [ -n "$db_passwd" ]; then
/bin/echo -e "## Password for the user\n"\
"db_passwd\t\t$db_passwd\n" >> /etc/sympa/sympa.conf
fi
if [ -n "$db_options" ]; then
/bin/echo -e "## Database options\n"\
"db_options\t\t$db_options\n" >> /etc/sympa/sympa.conf
fi
if [ -n "$db_port" ]; then
/bin/echo -e "## TCP port for the database connection\n"\
"db_port\t\t$db_port\n" >> /etc/sympa/sympa.conf
fi
/bin/echo -e "#-- Database configuration end" >> /etc/sympa/sympa.conf
chown sympa:sympa /etc/sympa/sympa.conf
chmod 0640 /etc/sympa/sympa.conf
fi
# remove depreciated WWW configuration fragment
db_get wwsympa/webserver_type
webserver="$RET"
case $webserver in
"Apache 2") webserver="none";;
"Apache") webserver="apache";;
"Apache-SSL") webserver="apache-ssl";;
*) webserver="none";;
esac
if [ "$webserver" != "none" ]; then
# Check whether you have to modify the Web server configuration
db_get wwsympa/webserver_modifconf || true
modifconf="$RET"
if [ "$modifconf" = "true" ]; then
# Remove the previous Web configuration
if grep -q "#-- WWSYMPA begin" /etc/$webserver/httpd.conf ; then
sed -e '/#-- WWSYMPA begin/,/#-- WWSYMPA end/d' \
/etc/$webserver/httpd.conf > /etc/$webserver/httpd.conf.new
mv /etc/$webserver/httpd.conf.new /etc/$webserver/httpd.conf
fi
fi
fi
db_get sympa/use_wwsympa
use_wwsympa="$RET"
# Use WWSympa
if [ "$use_wwsympa" = "true" ]; then
# Check whether sympa was configured for using a database
db_get sympa/use_db
use_db="$RET"
if [ "$use_db" = "false" ]; then
echo "WWSympa cannot work without a RDBMS and it seems that"
echo "Sympa was not configured for using a database."
echo ""
echo "Please first reconfigure sympa with the following command:"
echo " dpkg-reconfigure -plow sympa"
exit 0
fi
# Ensure permissions and ownerships are right
chown -R sympa.sympa /var/spool/sympa/wws* /var/lib/sympa/wws*
chmod -R ug=rwX,o=X /var/spool/sympa/wws* /var/lib/sympa/wws*
## 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 -e "s;\([^#]*\)/var/spool/sympa/wwsarchive;\1/var/lib/sympa/wwsarchive;" \
/etc/sympa/wwsympa.conf > /etc/sympa/wwsympa.conf.new
mv /etc/sympa/wwsympa.conf.new /etc/sympa/wwsympa.conf
fi
chown sympa:sympa /etc/sympa/wwsympa.conf /etc/sympa/topics.conf
chmod 0640 /etc/sympa/wwsympa.conf
chown sympa:sympa /usr/lib/cgi-bin/sympa/wwsympa.fcgi
chmod 6755 /usr/lib/cgi-bin/sympa/wwsympa.fcgi
# WebServer configuration
db_get wwsympa/webserver_type
webserver="$RET"
case $webserver in
"Apache 2")
webserver="apache2"
;;
"Apache")
webserver="apache"
;;
"Apache-SSL")
webserver="apache-ssl"
;;
*)
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/fastcgi.load ]; then
echo "FastCGI module not enabled, skipping."
fastcgi="false"
fi
elif [ $webserver != "none" ]; then
if [ ! -f /usr/lib/apache/1.3/mod_fastcgi.so ]; then
echo "FastCGI module not enabled, skipping."
fastcgi="false"
fi
fi
fi
## Generate /etc/sympa/wwsympa.conf
case $fastcgi in
"true")
fastcgi="1"
;;
*)
fastcgi="0"
;;
esac
db_get wwsympa/wwsympa_url
wwsympa_url="$RET"
perl -i -pe "s%^(wwsympa_url\s+).*%wwsympa_url ${wwsympa_url}%" /etc/sympa/sympa.conf
# Tell Debconf WWSympa has been configured
db_set sympa/wwsympa_configured true
fi
if [ "$fastcgi" = "1" ]; then
db_get sympa/use_soap
use_soap="$RET"
# Use SOAP
if [ "$use_soap" = "true" ]; then
chown sympa:sympa /usr/lib/cgi-bin/sympa/sympa_soap_server.fcgi
chmod 6755 /usr/lib/cgi-bin/sympa/sympa_soap_server.fcgi
db_get sympa/soap_url
soap_url="$RET"
perl -i -pe "s%^(soap_url\s+).*%soap_url ${soap_url}%" /etc/sympa/sympa.conf
# Tell Debconf SOAP has been configured
db_set sympa/soap_configured true
fi
fi
# WebServer configuration
if [ "$use_soap" = "true" -o "$use_wwsympa" = "true" ]; then
db_get wwsympa/webserver_type
webserver="$RET"
case $webserver in
"Apache 2")
webserver="apache2"
;;
"Apache")
webserver="apache"
;;
"Apache-SSL")
webserver="apache-ssl"
;;
*)
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
if [ $webserver = "none" ]; then
echo "Not configuring Web server."
else
mkdir -p /etc/$webserver/conf.d
if [ "$use_wwsympa" = "true" ]; then
# Activate wwsympa
if [ ! -f /etc/$webserver/conf.d/sympa -a ! -h /etc/$webserver/conf.d/sympa ]; then
ln -sf /etc/sympa/apache-wwsympa /etc/$webserver/conf.d/sympa
fi
fi
if [ "$use_soap" = "true" ]; then
# Activate soap
if [ ! -f /etc/$webserver/conf.d/sympa-soap -a ! -h /etc/$webserver/conf.d/sympa-soap ]; then
ln -s /etc/sympa/apache-soap /etc/$webserver/conf.d/sympa-soap
fi
fi
fi
fi
# Check whether we have to restart the Web server
db_get wwsympa/webserver_restart
restart="$RET"
if [ "$restart" = "true" ]; then
if [ -x /etc/init.d/$webserver ]; then
/etc/init.d/$webserver restart
fi
fi
if [ "$use_db" = "true" ]; then
/usr/share/sympa/db/prepare_db
fi
## End up with debconf
db_stop
## Other jobs
#DEBHELPER#
|