[Ultrapossum-cvs 431] ultrapossum/debian ...

Back to archive index

Masato Taruishi taru****@users*****
2004年 9月 16日 (木) 20:14:58 JST


===================================================================
RCS file: ultrapossum/debian/ultrapossum-common.config,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ultrapossum/debian/ultrapossum-common.config	2004/03/31 13:24:35	1.3
+++ ultrapossum/debian/ultrapossum-common.config	2004/09/16 11:14:58	1.4
@@ -7,14 +7,101 @@
 db_version 2.0
 db_title "UltraPossum Configuration"
 
+check_ldap() {
+  db_get ultrapossum-common/config_backend_ldap_uri
+  ldapuri="$RET"
+  db_get ultrapossum-common/config_backend_ldap_basedn
+  ldapbasedn="$RET"
+  db_get ultrapossum-common/config_backend_ldap_binddn
+  ldapbinddn="$RET"
+  db_get ultrapossum-common/config_backend_ldap_bindpw
+  ldapbindpw="$RET"
+  if test "x`ldapsearch -LLL -x -H "$ldapuri" -b "$ldapbasedn" -D "$ldapbinddn" -w "$ldapbindpw" -s one description=\*`" = "x"; then
+    return 1
+  else
+    return 0
+  fi
+}
+
 SUFFIX="o=ultrapossum"
-if test "$1" = "reconfigure" ; then
+if test -x "/usr/bin/ultrapossum-config"; then
   eval `/usr/bin/ultrapossum-config init`
   trap "eval `ultrapossum-config term`" 0
 elif test -f "/etc/ultrapossum/ultrapossum.cf"; then
   . /etc/ultrapossum/ultrapossum.cf
 fi
 
-db_set ultrapossum-common/suffix $SUFFIX
+if test "$1" = "reconfigure"; then
+  db_set ultrapossum-common/suffix $SUFFIX
+  db_set ultrapossum-common/config_backend_ldap_uri "$ULTRAPOSSUM_CONFIG_BACKEND_LDAP_URI"
+  db_set ultrapossum-common/config_backend_ldap_basedn "$ULTRAPOSSUM_CONFIG_BACKEND_LDAP_BASEDN"
+  db_set ultrapossum-common/config_backend_ldap_binddn "$ULTRAPOSSUM_CONFIG_BACKEND_LDAP_BINDDN"
+  db_set ultrapossum-common/config_backend_ldap_bindpw "$ULTRAPOSSUM_CONFIG_BACKEND_LDAP_BINDPW"
+  db_set ultrapossum-common/config_backend_ldap_bindpw2 "$ULTRAPOSSUM_CONFIG_BACKEND_LDAP_BINDPW"
+fi
+
+case "$ULTRAPOSSUM_CONFIG_BACKEND" in
+  ldap)
+    backend=ldap
+  ;;
+  *)
+    backend=file
+  ;;    
+esac
+
+db_set ultrapossum-common/config_backend "$backend"
 
+STATE=start
+while test "$STATE" != "end"; do
+  case "$STATE" in
+    start)
+      db_input low ultrapossum-common/config_backend || true
+      db_go
+      db_get ultrapossum-common/config_backend
+      backend=$RET
+      case "$backend" in
+        ldap)
+          STATE=ldapstart
+        ;;
+        *)
+          STATE=end
+      esac
+    ;;
+    ldapstart)
+      db_input low ultrapossum-common/config_backend_ldap_uri || true
+      db_input low ultrapossum-common/config_backend_ldap_basedn || true
+      db_input low ultrapossum-common/config_backend_ldap_binddn || true
+      STATE=ldappasswd
+    ;;
+    ldappasswd)
+      db_input low ultrapossum-common/config_backend_ldap_bindpw || true
+      db_input low ultrapossum-common/config_backend_ldap_bindpw2 || true
+      db_go
+      db_get ultrapossum-common/config_backend_ldap_bindpw
+      passwd="$RET"
+      db_get ultrapossum-common/config_backend_ldap_bindpw2
+      if test "x$passwd" != "x$RET"; then
+        db_fset ultrapossum-common/config_backend_ldap_password_mismatch seen false
+        db_input low ultrapossum-common/config_backend_ldap_password_mismatch
+        db_go
+        db_fset ultrapossum-common/config_backend_ldap_bindpw seen false
+        db_fset ultrapossum-common/config_backend_ldap_bindpw2 seen false
+      else
+        if check_ldap; then
+          STATE=end
+        else
+          db_fset ultrapossum-common/config_backend_ldap_failed seen false
+          db_input low ultrapossum-common/config_backend_ldap_failed
+          db_go
+          db_fset ultrapossum-common/config_backend_ldap_uri seen false
+          db_fset ultrapossum-common/config_backend_ldap_basedn seen false
+          db_fset ultrapossum-common/config_backend_ldap_binddn seen false
+          db_fset ultrapossum-common/config_backend_ldap_bindpw seen false
+          db_fset ultrapossum-common/config_backend_ldap_bindpw2 seen false
+          STATE=start
+        fi
+      fi
+    ;;
+  esac
+done
 
===================================================================
RCS file: ultrapossum/debian/ultrapossum-common.postinst,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ultrapossum/debian/ultrapossum-common.postinst	2004/05/13 15:41:31	1.5
+++ ultrapossum/debian/ultrapossum-common.postinst	2004/09/16 11:14:58	1.6
@@ -33,6 +33,14 @@
   fi
 }
 
+# setconfig <template_base> <var>
+setconfig_backend() {
+  db_get ultrapossum-common/$1
+  if test "x$RET" != "x${!2}"; then
+    ultrapossum_setconf_shell /etc/ultrapossum/config.cf $2 "$RET"
+  fi
+}
+
 case "$1" in
     configure)
 
@@ -50,6 +58,19 @@
 
 	setconfig suffix SUFFIX
 
+        db_get ultrapossum-common/config_backend
+        case "$RET" in
+          ldap)
+	    setconfig_backend config_backend ULTRAPOSSUM_CONFIG_BACKEND
+	    setconfig_backend config_backend_ldap_uri ULTRAPOSSUM_CONFIG_BACKEND_LDAP_URI
+	    setconfig_backend config_backend_ldap_basedn ULTRAPOSSUM_CONFIG_BACKEND_LDAP_BASEDN
+	    setconfig_backend config_backend_ldap_binddn ULTRAPOSSUM_CONFIG_BACKEND_LDAP_BINDDN
+	    setconfig_backend config_backend_ldap_bindpw ULTRAPOSSUM_CONFIG_BACKEND_LDAP_BINDPW
+          ;;
+          *)
+            ultrapossum_setconf_shell /etc/ultrapossum/config.cf ULTRAPOSSUM_CONFIG_BACKEND ""
+          ;;
+        esac
 	chmod 1777 /var/cache/ultrapossum/
     ;;
 
===================================================================
RCS file: ultrapossum/debian/ultrapossum-common.templates,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ultrapossum/debian/ultrapossum-common.templates	2004/04/01 10:48:55	1.3
+++ ultrapossum/debian/ultrapossum-common.templates	2004/09/16 11:14:58	1.4
@@ -1,3 +1,39 @@
+Template: ultrapossum-common/config_backend
+Type: select
+Choices: file, ldap
+Default: file
+_Description: Which backend do you want to use to store configurations
+ UltraPossum stores your configuration in a configuration backend. You
+ can select the backend to use.
+
+Template: ultrapossum-common/config_backend_ldap_uri
+Type: string
+_Description: LDAP URI you connect
+
+Template: ultrapossum-common/config_backend_ldap_basedn
+Type: string
+_Description: BaseDN to search
+
+Template: ultrapossum-common/config_backend_ldap_binddn
+Type: string
+_Description: BindDN to search
+
+Template: ultrapossum-common/config_backend_ldap_bindpw
+Type: password
+_Description: password to search
+
+Template: ultrapossum-common/config_backend_ldap_bindpw2
+Type: password
+_Description: retype password to search
+
+Template: ultrapossum-common/config_backend_ldap_password_mismatch
+Type: Note
+_Description: password mismatch
+
+Template: ultrapossum-common/config_backend_ldap_failed
+Type: Note
+_Description: Configuration not found there
+
 Template: ultrapossum-common/suffix
 Type: string
 Default: o=ultrapossum



Ultrapossum-cvs メーリングリストの案内
Back to archive index