Handle saslauthd upgrade.
[carnet-upgrade.git] / src / functions.sh
index bba996c..2b557d7 100644 (file)
@@ -933,7 +933,7 @@ remove_skey () {
 # remove unsupported php version
 remove_php4 () {
   # leave the configuration just in case
-  pkgrm_only php4-common
+  pkgrm_only php4-common || true
 }
 
 # check if package is orphaned (nothing depends on it)
@@ -981,18 +981,17 @@ upgrade_libc () {
   DEBIAN_FRONTEND=noninteractive pkgadd libc6 tzdata
 }
 
-# upgrade apache2 to etch
+# upgrade apache2 to lenny
 upgrade_apache2 () {
   local package packages
 
   for package in \
-      libapache2-mod-php4 \
-      php4-cli \
-      php4-cgi \
-      php4-cn \
+      libapache2-mod-php5 \
+      php5-cli \
+      php5-cn \
       apache2-cn \
-      php4-odbc \
-      php4-suhosin \
+      php5-odbc \
+      php5-suhosin \
       php-suhosin-cn
   do
       if pkg $package; then
@@ -1000,11 +999,6 @@ upgrade_apache2 () {
       fi
   done
 
-  # enable suhosin downgrade to etch version
-  if pkg php4-suhosin; then
-      pkgrm php4-suhosin php-suhosin-cn
-  fi
-
   eval pkgadd $packages
 }
 
@@ -1045,7 +1039,7 @@ upgrade_amavis () {
 
 # handle freerdius config files upgrade
 upgrade_freeradius () {
-  local template config_new password realm
+  local template config_new password realm hostname basedn
 
   pkg freeradius-aai lt 2.1.3-0lenny0 || return 0
 
@@ -1053,10 +1047,24 @@ upgrade_freeradius () {
   restore_config freeradius-aai freeradius 2.1.3-0lenny0 \
     /etc/freeradius/clients.conf \
     /etc/freeradius/hints \
-    /etc/freeradius/ldap.attrmap \
-    /etc/freeradius/radiusd.conf
+    /etc/freeradius/ldap.attrmap
 
   # handle template based configs
+  template=/usr/share/carnet-upgrade/files/etc/freeradius/radiusd.conf.template
+  config_new=$(mktemp /var/lib/carnet-upgrade/radiusd.conf.XXXXXX)
+  basedn=$(sed -n '/^[[:space:]]*suffix[[:space:]]*/ { 
+    s///; s/"//g; p; q }' /etc/ldap/slapd.conf)
+  hostname=$(hostname -f)
+  cp $template $config_new
+  sed -i "s/#HOSTNAME#/$hostname/" $config_new
+  sed -i "s/#BASEDN#/$basedn/" $config_new
+  if cmp -s $config_new /etc/freeradius/radiusd.conf >/dev/null; then
+     log "Restoring config file /etc/freeradius/radiusd.conf"
+     cp -v /usr/share/carnet-upgrade/files/etc/freeradius/radiusd.conf.restore \
+           /etc/freeradius/radiusd.conf
+  fi
+  rm -f $config_new
+
   template=/usr/share/carnet-upgrade/files/etc/freeradius/eap.conf.template
   config_new=$(mktemp /var/lib/carnet-upgrade/eap.conf.XXXXXX)
   password=$(grep -s '^[[:space:]]*private_key_password[[:space:]]*=' \
@@ -1148,7 +1156,7 @@ upgrade_postgresql () {
 
 # upgrade the MTA
 upgrade_postfix () {
-  pkgadd postfix-cn
+  pkgadd sasl2-bin postfix-cn
 
   if pkg postgrey; then
      pkgrm postgrey # not used by postfix-cn anymore