PDA

View Full Version : [SOLVED] Script install slapd with admin ldap password



paco699
September 6th, 2012, 07:50 PM
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


paco

paco699
September 7th, 2012, 04:58 PM
Hello all,

I looked for and I found many solutions.. For use of 'preseeding' with 'debconf-get-selections':
http://www.debian-administration.org/articles/394

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 slapdAnd i fell also on this thread:
http://stackoverflow.com/questions/1202347/how-can-i-pass-a-password-from-a-bash-script-to-aptitude-for-installing-mysql


sudo DEBIAN_FRONTEND=noninteractive aptitude install -q -yor

#!/bin/bash

installnoninteractive(){
sudo bash -c "DEBIAN_FRONTEND=noninteractive aptitude install -q -y $*"
}

installnoninteractive slapdAlso I found 'expect'. For the use of 'expect':

#!/bin/bash
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 slapdbut for 'expect' the need to install the package.

After testing all these solutions, i prefer:

DEBIAN_FRONTEND=noninteractive aptitude install -q -yIt's perfect for me.