fixed autotools build, broken since r466, inhandlers/Makefile.am
[matthijs/upstream/backupninja.git] / handlers / ldap.helper.in
1 # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
2
3 HELPERS="$HELPERS ldap:ldap_database_backup"
4
5 ldap_create_file() {
6 while true; do
7       checkBox "ldap action wizard" "check options (slapcat OR ldapsearch)" \
8          "slapcat" "export ldif using slapcat" on \
9          "ldapsearch" "export ldif using ldapsearch" off \
10          "compress" "compress the ldif output files" on
11       status=$?
12       compress="compress = off"
13       method="method = <unset>"
14       restart="restart = no"
15       binddn=""
16       passwordfile=""
17       [ $status = 1 ] && return;
18       result="$REPLY"
19       for opt in $result; do
20          case $opt in
21            '"compress"') compress="compress = on";;
22            '"slapcat"')
23               method="method = slapcat"
24               [ "$_RESTART" == "yes" ] && restart="restart = yes"
25               ;;
26            '"ldapsearch"')
27               method="method = ldapsearch"
28               inputBox "ldap action wizard" "ldapsearch requires authentication. Specify here what password file to use. It must have the password with no trailing return and it should not be world readable."
29               [ $? = 1 ] && return
30               passwordfile="passwordfile = $REPLY"
31               inputBox "ldap action wizard" "ldapsearch requires authentication. Specify here what DN to bind as:"
32               [ $? = 1 ] && return
33               binddn="binddn = $REPLY"
34               require_packages ldap-utils
35               ;;
36          esac
37       done
38       get_next_filename $configdirectory/30.ldap
39       cat > $next_filename <<EOF
40 $method
41 $compress
42 $restart
43 $binddn
44 $passwordfile
45 # backupdir = /var/backups/ldap
46 # conf = /etc/ldap/slapd.conf
47 # databases = all
48 EOF
49      chmod 600 $next_filename
50      return
51 done
52 }
53
54 ldap_wizard() {
55    bdb=no
56    ldbm=no
57    for backend in `grep -e "^backend" /etc/ldap/slapd.conf | @AWK@ '{print $2}'`; do
58       if [ "$backend" == "bdb" -a "$bdb" == "no" ]; then
59          bdb=yes
60       elif [ "$backend" == "ldbm" -a "$ldbm" == "no" ]; then
61          ldbm=yes
62       fi
63    done    
64
65    if [ "$bdb" == "yes" -a "$ldbm" == "no" ]; then
66      msgBox "ldap action wizard" "It looks like the backend in your slapd.conf is set to BDB. If this is not the case, exit this wizard! From this point on, we will assume BDB backend, which might have disasterious consequences if this is incorrect."
67      _RESTART=no
68      ldap_create_file
69    elif [ "$ldbm" == "yes" ]; then
70      msgBox "ldap action wizard" "It looks like the backend in your slapd.conf is set to LDBM. Because of this, you will have less options (because it is not safe to use slapcat while slapd is running LDBM)." 
71      _RESTART=yes
72      ldap_create_file
73    else
74      msgBox "ldap action wizard" "I couldn't find any backends in your slapd.conf. Bailing out." 
75      return
76    fi
77 }
78