github.com/canhui/fabric_ca2_2@v2.0.0-alpha+incompatible/images/fabric-ca-fvt/payload/slapd_setup.sh (about)

     1  #!/bin/bash
     2  RC=0
     3  
     4  # Install slapd
     5  printf  "slapd slapd/internal/generated_adminpw password $LDAPPASWD\n\
     6  slapd slapd/password2 password $LDAPPASWD\n\
     7  slapd slapd/internal/adminpw password $LDAPPASWD\n\
     8  slapd slapd/password1 password $LDAPPASWD\n\
     9  slapd slapd/domain string example.com\n\
    10  slapd shared/organization string example.com" | debconf-set-selections
    11  apt-get -y update
    12  apt-get -y install --no-install-recommends slapd ldap-utils
    13  adduser openldap ssl-cert
    14  cp $FABRIC_CA_DATA/$TLS_BUNDLE /etc/ssl/certs/
    15  cp $FABRIC_CA_DATA/$TLS_SERVER_CERT /etc/ssl/certs/
    16  cp $FABRIC_CA_DATA/$TLS_SERVER_KEY /etc/ssl/private/$TLS_SERVER_KEY
    17  cp $FABRIC_CA_DATA/*ldif /etc/ldap/
    18  
    19  chgrp ssl-cert /etc/ssl/private/$TLS_SERVER_KEY
    20  chmod 644 /etc/ssl/certs/$TLS_BUNDLE
    21  chmod 644 /etc/ssl/certs/$TLS_SERVER_CERT
    22  chmod 640 /etc/ssl/private/$TLS_SERVER_KEY
    23  sed -i \
    24     "s@^[[:blank:]]*SLAPD_SERVICES=.*@SLAPD_SERVICES=\"ldap://$HOSTADDR:$LDAPPORT/ ldaps:/// ldapi:///\"@"\
    25     /etc/default/slapd
    26  
    27  /etc/init.d/slapd start || let RC+=1
    28  
    29  i=0;while ! nc -znvt $HOSTADDR $LDAPPORT; do
    30      sleep .5
    31      let i+
    32      if test $((i/2)) -gt $timeout; then
    33         let RC+=1
    34         break
    35      fi
    36  done
    37  
    38  ldapadd -Y EXTERNAL -H ldapi:///  -f /etc/ldap/member.ldif || let RC+=1
    39  ldapadd -Y EXTERNAL -H ldapi:///  -f /etc/ldap/refint.ldif || let RC+=1
    40  ldapadd -h localhost -p $LDAPPORT -D cn=$LDAPUSER,dc=example,dc=com -w $LDAPPASWD -f /etc/ldap/base.ldif || let RC+=1
    41  ldapadd -h localhost -p $LDAPPORT -D cn=$LDAPUSER,dc=example,dc=com -w $LDAPPASWD -f /etc/ldap/add-users.ldif || let RC+=1
    42  ldapadd -h localhost -p $LDAPPORT -D cn=$LDAPUSER,dc=example,dc=com -w $LDAPPASWD -f /etc/ldap/groups.ldif || let RC+=1
    43  ldapmodify -Y EXTERNAL -H ldapi:/// -f /etc/ldap/certinfo.ldif || let RC+=1
    44  ldapmodify -Y EXTERNAL -H ldapi:/// -f /etc/ldap/forceTimeout.ldif
    45  /etc/init.d/slapd stop
    46  
    47  exit $RC