I looked for what you propose. For use of 'preseeding' with 'debconf-get-selections':
Code:
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
And i fell also on this thread:
[stackoverflow.com/questions/1202347/how-can-i-pass-a-password-from-a-bash-script-to-aptitude-for-installing-mysql]
Code:
sudo DEBIAN_FRONTEND=noninteractive aptitude install -q -y
or
Code:
#!/bin/bash
installnoninteractive(){
sudo bash -c "DEBIAN_FRONTEND=noninteractive aptitude install -q -y $*"
}
installnoninteractive slapd
Also I found 'expect'. For the use of 'expect':
Code:
#!/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 slapd
but for 'expect' the need to install the package.
After testing all these solutions, i prefer:
Code:
DEBIAN_FRONTEND=noninteractive aptitude install -q -y