Handle radiusd.conf upgrade.
authorValentin Vidic <Valentin.Vidic@CARNet.hr>
Fri, 8 May 2009 15:03:50 +0000 (17:03 +0200)
committerValentin Vidic <Valentin.Vidic@CARNet.hr>
Fri, 8 May 2009 15:03:50 +0000 (17:03 +0200)
files/etc/freeradius/radiusd.conf.template [moved from files/etc/freeradius/radiusd.conf.expect with 99% similarity]
src/functions.sh

similarity index 99%
rename from files/etc/freeradius/radiusd.conf.expect
rename to files/etc/freeradius/radiusd.conf.template
index 7906089..7586c66 100644 (file)
@@ -734,11 +734,11 @@ $INCLUDE ${confdir}/eap.conf
        #  really can't emphasize this enough.
        #       
        ldap {
-               server = "debian.local"
+               server = "#HOSTNAME#"
                # identity = "cn=admin,o=My Org,c=UA"
                # password = mypass
                port = 389
-               basedn = "dc=local,dc=hr"
+               basedn = "#BASEDN#"
                filter = "(uid=%{Stripped-User-Name:-%{User-Name}})"
                # base_filter = "(objectclass=radiusprofile)"
 
index cbb8be2..b29e43e 100644 (file)
@@ -1039,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
 
@@ -1047,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:]]*=' \