Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Script install slapd with admin ldap password

    Hello all,

    In my script bash, i search to install the package 'slapd' (openldap) automatically on ubuntu12.04.

    The thing is that slapd ask, in ncurses mode, to define an admin password for my openldap directory.

    How can i put/insert this password in my script to automate the installation?

    Thanks very much


  2. #2
    I don't know of a way to provide this info via apt-get, but it would be nice to tell it to run non-interactively.

    but perhaps your bash script can call expect, which is a program that exists for just this kind of thing: providing input to some other program that normally acts interactively. the idea would be that, you'd write a simple expect script, which would run a system call (e.g., "apt-get install slapd"). the output normally sent to the terminal by apt-get (i.e., the admin password prompt) is sent instead to expect, and in your script, you provide your answer. it will take some trial and error to get it right, but it is worth a shot, if this is truly important.

    it should go w/out saying that it is insecure in that your password would be in clear text in your script.

  3. #3
    Hello atreyu,

    Thanks very much for your reply.

    I looked for what you propose: 'non-interactively' and 'expect' and i fell on this thread for more details:

    sudo DEBIAN_FRONTEND=noninteractive aptitude install -q -y
      sudo bash -c "DEBIAN_FRONTEND=noninteractive aptitude install -q -y $*"
    installnoninteractive slapd
    There is also:
    sudo debconf-set-selections <<< 'slapd/root_password password your_password'
    sudo debconf-set-selections <<< 'slapd/root_password_again password your_password'
    sudo aptitude -y install slapd
    For using of 'expect':
    aptitude update
    aptitude install expect
    VAR=$(expect -c '
    spawn aptitude -y install slapd
    expect "New password for the slapd \"root\" user:"
    send "PasswordHere\r"
    expect "Repeat password for the slapd \"root\" user:"
    send "PasswordHere\r"
    expect eof
    echo "$VAR"
    aptitude -y install slapd
    but for 'expect' it needs to install the package.

    After testing all these solutions, i prefer the first:
    DEBIAN_FRONTEND=noninteractive aptitude install -q -y
    It's perfect for me.

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts