[Pkg-sympa-commits] [sympa] 24/30: Rewrite postinst for Sympa 6.2
Emmanuel Bouthenot
kolter at moszumanska.debian.org
Mon Sep 19 20:08:49 UTC 2016
This is an automated email from the git hooks/post-receive script.
kolter pushed a commit to branch master
in repository sympa.
commit 22fd17adf106bfa6457421264ba95e4a22b56301
Author: Emmanuel Bouthenot <kolter at openics.org>
Date: Mon Sep 19 21:44:57 2016 +0200
Rewrite postinst for Sympa 6.2
---
debian/config | 221 +++++++++++++-------------
debian/control | 16 +-
debian/sympa.postinst | 426 ++++++++++++++++++++------------------------------
3 files changed, 292 insertions(+), 371 deletions(-)
diff --git a/debian/config b/debian/config
index 9cea5cb..39239f7 100644
--- a/debian/config
+++ b/debian/config
@@ -2,149 +2,148 @@
set -e
-# Debconf configuration script for Sympa.
-# by Jerome Marant <jerome at debian.org>
-
-# Modifications by Stefan Hornburg (Racke) <racke at linuxia.de>.
-
# Source debconf library
. /usr/share/debconf/confmodule
db_version 2.0
-conf="/etc/sympa/sympa.conf"
-wwconf="/etc/sympa/wwsympa.conf"
+if [ -f "/etc/sympa/sympa/sympa.conf" ] || [ ! -f "/etc/sympa/sympa.conf" ]; then
+ conf=/etc/sympa/sympa/sympa.conf
+else
+ conf=/etc/sympa/sympa.conf
+fi
# Language selection
# - currently supported languages
-possible_langs="ar bg br ca cs da de el en es et eu fi fr gl hu id it ja ko la ml nb_NO nl oc pl pt pt_BR ro ru sv tr vi zh_CN zh_TW"
-supported_langs="en"
-locales=$(locale -a)
-
-for lang in $possible_langs ; do
- if locale -a | grep -q "$lang" ; then
- supported_langs="$supported_langs, $lang"
- fi
+default_lang="en"
+possible_langs="ar bg br ca cs de el en en_US es et eu fi fr gl hu id it ja ko la ml nb_NO nl oc pl pt_BR pt ro ru sv tr vi zh_CN zh_TW"
+supported_langs="${default_lang}"
+locales="$(locale -a)"
+
+for lang in ${possible_langs} ; do
+ if locale -a | grep -q "${lang}" ; then
+ supported_langs="${supported_langs}, ${lang}"
+ fi
done
# Get the language value in case of a manual change
-if [ -f "$conf" ]; then
- lang=$(perl -nle 'if (/^\s*lang\s+(\w+)/) {print $1;}' "$conf")
- db_set sympa/language "$lang"
- # Get the hostname.
- # Since this parameter could be a unix command, we have
- # to check this and run the command to get the value
- if grep -q "^[ ]*host" "$conf" ; then
- host=$(perl -nle 'if (/^\s*host\s+(.*)$/) {
- if ($1 =~ m/^`(.*)`$/) {
- $cmd=`$1`; print $cmd;
- } else {
- print $1;
- }
- }' "$conf")
- else
- host=$(perl -nle 'if (/^\s*domain\s+(.*)$/) {
- if ($1 =~ m/^`(.*)`$/) {
- $cmd=`$1`; print $cmd;
- } else {
- print $1;
- }
- }' "$conf")
- fi
- # Get the listmasters, since this parameter could be a unix command, we have
- # to check this and run the command to get the value
- listmaster=$(perl -nle 'if (/^\s*listmaster\s+(.*)$/) {
- if ($1 =~ m/^`(.*)`$/) {
- $cmd=`$1`; print $cmd;
- } else {
- print $1;
- }
- }' "$conf")
+if [ -f "${conf}" ]; then
+ lang=$(perl -nle 'if (/^\s*lang\s+(\w+)/) {print $1;}' "${conf}")
+ db_set sympa/language "${lang}"
+ # Get the hostname.
+ # Since this parameter could be a unix command, we have
+ # to check this and run the command to get the value
+ if grep -q "^[ ]*host" "${conf}" ; then
+ host=$(perl -nle 'if (/^\s*host\s+(.*)$/) {
+ if ($1 =~ m/^`(.*)`$/) {
+ ${cmd}=`$1`; print ${cmd};
+ } else {
+ print $1;
+ }
+ }' "${conf}")
+ else
+ host=$(perl -nle 'if (/^\s*domain\s+(.*)$/) {
+ if ($1 =~ m/^`(.*)`$/) {
+ ${cmd}=`$1`; print ${cmd};
+ } else {
+ print $1;
+ }
+ }' "${conf}")
+ fi
+ # Get the listmasters, since this parameter could be a unix command, we have
+ # to check this and run the command to get the value
+ listmaster=$(perl -nle 'if (/^\s*listmaster\s+(.*)$/) {
+ if ($1 =~ m/^`(.*)`$/) {
+ ${cmd}=`$1`; print ${cmd};
+ } else {
+ print $1;
+ }
+ }' "${conf}")
else
- # Get default values on configure
+ # Get default values on configure
host=$(head -n 1 /etc/mailname || hostname -f || echo localhost)
- listmaster=
+ listmaster="listmaster@${host}"
fi
# Set default values
# Ask for language
-if [ "$supported_langs" != "en" ]; then
- db_subst sympa/language supported_langs $supported_langs
- db_input medium sympa/language || [ $? -eq 30 ]
- db_go
+if [ "${supported_langs}" != "en" ]; then
+ db_subst sympa/language supported_langs ${supported_langs}
+ db_input medium sympa/language || [ $? -eq 30 ]
+ db_go
else
- db_set sympa/language en
+ db_set sympa/language "${default_lang}"
fi
db_get sympa/hostname
-if [ -z "$RET" ]; then
- db_set sympa/hostname "$host"
+if [ -z "${RET}" ]; then
+ db_set sympa/hostname "${host}"
fi
db_input medium sympa/hostname || [ $? -eq 30 ]
db_go
db_get sympa/listmaster
-if [ -z "$RET" ]; then
- db_get sympa/hostname
- if [ "$listmaster" ]; then
- db_set sympa/listmaster "$listmaster"
- else
- db_set sympa/listmaster "listmaster@$RET"
- fi
+if [ -z "${RET}" ]; then
+ if [ -n "${listmaster}" ]; then
+ db_set sympa/listmaster "${listmaster}"
+ else
+ db_get sympa/hostname
+ db_set sympa/listmaster "listmaster@${RET}"
+ fi
fi
db_input medium sympa/listmaster || [ $? -eq 30 ]
db_go
if [ -f /usr/share/dbconfig-common/dpkg/config ]; then
- dbc_dbtypes="mysql, pgsql, sqlite3"
- dbc_authmethod_user="password"
- . /usr/share/dbconfig-common/dpkg/config
- dbc_first_version="5.3.4-6~"
- if [ -f "$conf" ] && dbctmpfile=$(tempfile -p sympa); then
- # Extract sympa.conf options parsable by dbconfig-common
- perl -ne 'print "$1=\"$2\"\n" if /^\s*(db_[a-z]+)\s*(.*)\s*$/' \
- "$conf" > "$dbctmpfile"
- dbc_load_include="sh:$dbctmpfile"
- dbc_load_include_args="-d db_name -p db_passwd -s db_host -P db_port -u db_user -t db_type"
- fi
- dbc_go sympa $@
- rm -f -- "$dbctmpfile"
+ dbc_dbtypes="mysql, pgsql, sqlite3"
+ dbc_authmethod_user="password"
+ . /usr/share/dbconfig-common/dpkg/config
+ dbc_first_version="5.3.4-6~"
+ if [ -f "${conf}" ] && dbctmpfile=$(tempfile -p sympa); then
+ # Extract sympa.conf options parsable by dbconfig-common
+ perl -ne 'print "$1=\"$2\"\n" if /^\s*(db_[a-z]+)\s*(.*)\s*$/' \
+ "${conf}" > "${dbctmpfile}"
+ dbc_load_include="sh:${dbctmpfile}"
+ dbc_load_include_args="-d db_name -p db_passwd -s db_host -P db_port -u db_user -t db_type"
+ fi
+ dbc_go sympa $@
+ rm -f -- "${dbctmpfile}"
fi
db_get wwsympa/wwsympa_url
-if [ -z "$RET" ]; then
- wwsympa_url_default="http://${host}/wws"
- # Get the url from sympa.conf
- if [ -f "$conf" ]; then
- wwsympa_url_conf=$(perl -nle 'if (/^\s*wwsympa_url\s+(.*)$/) {print $1;}' "$conf")
- if [ -z "$wwsympa_url" ]; then
- db_get wwsympa/wwsympa_url
- wwsympa_url_conf="$RET"
- fi
- fi
- if [ -z "$wwsympa_url_conf" ]; then
- db_set wwsympa/wwsympa_url "$wwsympa_url_default"
- else
- db_set wwsympa/wwsympa_url "$wwsympa_url_conf"
- fi
+if [ -z "${RET}" ]; then
+ wwsympa_url_default="http://${host}/wws"
+ # Get the url from sympa.conf
+ if [ -f "${conf}" ]; then
+ wwsympa_url_conf=$(perl -nle 'if (/^\s*wwsympa_url\s+(.*)$/) {print $1;}' "${conf}")
+ if [ -z "${wwsympa_url}" ]; then
+ db_get wwsympa/wwsympa_url
+ wwsympa_url_conf="${RET}"
+ fi
+ fi
+ if [ -z "${wwsympa_url_conf}" ]; then
+ db_set wwsympa/wwsympa_url "${wwsympa_url_default}"
+ else
+ db_set wwsympa/wwsympa_url "${wwsympa_url_conf}"
+ fi
fi
db_input medium wwsympa/wwsympa_url || [ $? -eq 30 ]
db_go
db_get wwsympa/fastcgi
-if [ -z "$RET" ] && [ -f "$wwconf" ]; then
- fastcgi=$(perl -nle 'if (/^\s*use_fast_cgi\s+(\d)$/) {print $1;}' "$wwconf")
- case "$fastcgi" in
- 1)
- fastcgi="true"
- ;;
- *)
- fastcgi="false"
- ;;
- esac
- db_set wwsympa/fastcgi "$fastcgi"
+if [ -z "${RET}" ] && [ -f "${conf}" ]; then
+ fastcgi=$(perl -nle 'if (/^\s*use_fast_cgi\s+(\d)$/) {print $1;}' "${conf}")
+ case "${fastcgi}" in
+ 1)
+ fastcgi="true"
+ ;;
+ *)
+ fastcgi="false"
+ ;;
+ esac
+ db_set wwsympa/fastcgi "${fastcgi}"
fi
# Ask for the installed web server
@@ -152,15 +151,15 @@ db_input high wwsympa/webserver_type || [ $? -eq 30 ]
db_go
db_get wwsympa/webserver_type
-webserver="$RET"
-
-if [ "$webserver" != "none" ]; then
- # Ask for fastCGI configuration
- db_input medium wwsympa/fastcgi || [ $? -eq 30 ]
- db_go
- # Ask for soap usage
- db_input medium sympa/use_soap || [ $? -eq 30 ]
- db_go
+webserver="${RET}"
+
+if [ "${webserver}" != "none" ]; then
+ # Ask for fastCGI configuration
+ db_input medium wwsympa/fastcgi || [ $? -eq 30 ]
+ db_go
+ # Ask for soap usage
+ db_input medium sympa/use_soap || [ $? -eq 30 ]
+ db_go
fi
# Ask for spool directories removal
diff --git a/debian/control b/debian/control
index 3a454db..7ab0c9d 100644
--- a/debian/control
+++ b/debian/control
@@ -46,6 +46,13 @@ Depends:
libmsgcat-perl (>= 1.0),
libmime-tools-perl,
perl (>= 5.8),
+ libclass-singleton-perl,
+ libdatetime-format-mail-perl,
+ libfile-nfslock-perl,
+ libmail-dkim-perl (>= 0.36),
+ libnet-cidr-perl,
+ libcrypt-openssl-x509-perl,
+ libcrypt-smime-perl,
libio-stringy-perl,
libnet-ldap-perl,
libcgi-fast-perl,
@@ -69,8 +76,8 @@ Depends:
dbconfig-common,
libdbd-mysql-perl (>= 4.007),
libdbd-pg-perl,
- libdbd-sybase-perl,
libdbd-sqlite3-perl,
+ libdbd-csv-perl,
sqlite3,
libfcgi-perl,
libfile-copy-recursive-perl (>= 0.36),
@@ -83,10 +90,8 @@ Replaces: wwsympa
Provides: wwsympa
Conflicts: wwsympa
Recommends:
- libfile-nfslock-perl,
libio-socket-ssl-perl,
libcrypt-ciphersaber-perl,
- libmail-dkim-perl (>= 0.36),
libapache2-mod-fcgid,
apache2-suexec,
logrotate,
@@ -96,9 +101,8 @@ Recommends:
Suggests:
libauthcas-perl (>= 1.4),
libdbd-oracle-perl (>= 0.90),
- libtext-wrap-perl,
- apache2 | httpd-cgi,
- openssl (>= 0.9.5a)
+ libdbd-odbc-perl,
+ apache2 | httpd-cgi
Description: Modern mailing list manager
Sympa is a scalable and highly customizable modern mailing list manager
capable of handling big setups: 20.000 lists with 700,000 subscribers.
diff --git a/debian/sympa.postinst b/debian/sympa.postinst
index f915de9..7e619cc 100644
--- a/debian/sympa.postinst
+++ b/debian/sympa.postinst
@@ -7,396 +7,314 @@
set -e
if [ -f /usr/share/debconf/confmodule ]; then
- . /usr/share/debconf/confmodule
+ . /usr/share/debconf/confmodule
fi
if [ -f /usr/share/dbconfig-common/dpkg/postinst ]; then
- . /usr/share/dbconfig-common/dpkg/postinst
+ . /usr/share/dbconfig-common/dpkg/postinst
fi
-conf=/etc/sympa/sympa.conf
-wwconf=/etc/sympa/wwsympa.conf
+if [ -f "/etc/sympa/sympa/sympa.conf" ] || [ ! -f "/etc/sympa/sympa.conf" ]; then
+ conf=/etc/sympa/sympa/sympa.conf
+else
+ conf=/etc/sympa/sympa.conf
+fi
sympa_version() {
- perl -e "use lib '/usr/share/sympa/lib'; use Sympa::Constants; print Sympa::Constants::VERSION;"
+ perl -e "use lib '/usr/share/sympa/lib'; use Sympa::Constants; print Sympa::Constants::VERSION;"
+}
+
+sympa_config_update() {
+ key="${1}"
+ value="${2}"
+ if [ -n "${value}" ]; then
+ if grep -qE "^\s*${key}\s+" "${conf}" ; then
+ sed -r -i "s~^\s*${key}\s+.*\$~${key}\t${value}~" "${conf}"
+ elif grep -qE "^\s*#\s*${key}\s+" "${conf}" ; then
+ sed -r -i "s~^\s*#\s*${key}\s+.*\$~${key}\t${value}~" "${conf}"
+ else
+ printf "${key}\t${value}\n" >> "${conf}"
+ fi
+ else
+ sed -r -i "s~^\s*(${key}\s+.*)\$~#\1~" "${conf}"
+ fi
}
# 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
+ 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
+ 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~" -- "$@"
+ 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
+ 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
+ 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
+ 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
+ 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
- # Create congfiguration file
- /usr/lib/sympa/bin/sympa_wizard.pl --create sympa.conf --target "$conf"
-fi
-if [ -f "$conf" ]; then
- # Replace/disable obsolete settings in configuration file
- perl -i -pe 's%^#?(cookie\s+).*%cookie `cat /etc/sympa/cookie`%; s%^(syslog\s+).*%syslog `cat /etc/sympa/facility`%;' "$conf"
- 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"
- perl -i -pe 's/^(pidfile.*)$/### deprecated (>= 6.1.20): \1/' "$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"
-fi
-if [ -f "$wwconf" ]; then
- # Replace/disable obsolete settings in configuration file
- perl -i -pe 's%^(arc_path\s+).*%$1/var/lib/sympa/wwsarchive%; s%^(bounce_path\s+).*%$1/var/spool/sympa/wwsbounce%' "$wwconf"
- perl -i -pe 's%^(log_facility\s+).*%log_facility `cat /etc/sympa/facility`%;' "$wwconf"
- perl -i -pe 's/^([_a-z]+_pidfile\s.*)$/### deprecated (>= 6.1.20): \1/' "$wwconf"
+ # Create congfiguration file
+ /usr/lib/sympa/bin/sympa_wizard.pl --create sympa.conf --target "$conf"
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"
+sympa_config_update "lang" "${RET}"
# 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
+hostname="${RET}"
+sympa_config_update "domain" "${hostname}"
-# 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
+listmaster="${RET}"
+if ! echo "${listmaster}" | grep -qE '^.+ at .+$' ; then
+ listmaster="listmaster@${hostname}"
fi
+sympa_config_update "listmaster" "${listmaster}"
# 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
+ echo "## List aliases used for the sympa mailing-list manager" > /etc/mail/sympa/aliases
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
- 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
+ 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
# 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
+ if [ -f /etc/mail/sympa/aliases${ext} ]; then
+ chown sympa:sympa /etc/mail/sympa/aliases${ext}
+ fi
done
# Remove old sympa aliases
if [ -f /etc/aliases ]; then
- sed -i -e '/#-- SYMPA begin/,/#-- SYMPA end/d' /etc/aliases
- newaliases || true
+ sed -i -e '/#-- SYMPA begin/,/#-- SYMPA end/d' /etc/aliases
+ newaliases || true
fi
## 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
+ touch /etc/sympa/cookie
+ chmod 0660 /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
+ cp /etc/sympa/cookie /etc/sympa/cookies.history
+ chmod 0660 /etc/sympa/cookies.history
fi
+sympa_config_update "cookie" "\`head -n1 /etc/sympa/cookie\`"
+
## 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
+ 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
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
- ;;
+ 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
+sympa_config_update "db_type" "${type}"
+sympa_config_update "db_name" "${dbc_dbname}"
+sympa_config_update "db_host" "${dbc_dbserver}"
+sympa_config_update "db_user" "${dbc_dbuser}"
+sympa_config_update "db_passwd" "${dbc_dbpass}"
+sympa_config_update "db_port" "${dbc_dbport}"
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"
+chown -R sympa:sympa /etc/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
+touch /var/log/sympa.log || true
+chown sympa:sympa /var/log/sympa.log
+chmod 0640 /var/log/sympa.log
# 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 {} \;
+ -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 {} \;
+ \( -not -user sympa -or -not -group sympa \) \
+ -exec chown sympa:sympa {} \;
# 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
+ /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
+ /usr/lib/cgi-bin/sympa/sympa_soap_server-wrapper.fcgi
# Fix permissions on newaliases wrapper
chmod u+s /usr/lib/sympa/bin/sympa_newaliases-wrapper
# WebServer configuration
db_get wwsympa/webserver_type
-webserver="$RET"
-
-case $webserver in
- "Apache 2")
- webserver="apache2"
- ;;
- *)
- webserver="none"
- ;;
+case "${RET}" 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
+fastcgi="${RET}"
+if [ "$fastcgi" = "true" ] && [ $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
if [ "$fastcgi" = "true" ]; then
- perl -pi -e 's%^\s*(use_fast_cgi)\s+\d+%$1\t1%' "$wwconf"
+ sympa_config_update "use_fast_cgi" "1"
else
- perl -pi -e 's%^\s*(use_fast_cgi)\s+\d+%$1\t0%' "$wwconf"
+ sympa_config_update "use_fast_cgi" "0"
fi
db_get wwsympa/wwsympa_url
-wwsympa_url="$RET"
-perl -i -pe "s%^(wwsympa_url\s+).*%wwsympa_url ${wwsympa_url}%" "$conf"
+sympa_config_update "wwsympa_url" "${RET}"
db_get sympa/use_soap
-use_soap="$RET"
+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
+ sympa_config_update "soap_url" "http://${hostname}/sympasoap"
+else
+ sympa_config_update "soap_url" ""
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
+ 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"
-
+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
- fi
- fi
+ 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
+ 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
- fi
+ 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
+ fi
fi
+echo "Moving configuration files for Sympa >= 6.2 (if required)"
+su -l sympa -s /bin/sh -c "/usr/lib/sympa/bin/sympa.pl --upgrade_config_location"
+
+echo "Upgrading Sympa internals (health check)"
+su -l sympa -s /bin/sh -c "/usr/lib/sympa/bin/sympa.pl --health_check"
+
+echo "Upgrading Sympa internals (upgrade)"
su -l sympa -s /bin/sh -c "/usr/lib/sympa/bin/sympa.pl --upgrade"
+echo "Move messages stored in database to filesystem (if required)"
+su -l sympa -s /bin/sh -c "/usr/share/sympa/bin/upgrade_bulk_spool.pl" || true
+
+echo "Move messages sent through the web interface to the new formalism (if required)"
+su -l sympa -s /bin/sh -c "/usr/share/sympa/bin/upgrade_send_spool.pl"
+
## End up with debconf
db_stop
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/sympa.git
More information about the Pkg-sympa-commits
mailing list