Results 1 to 3 of 3
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-06-2012 #1Just Joined!
- Join Date
- Jul 2012
- Posts
- 9
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
paco
- 09-07-2012 #2Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,664
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.
- 09-07-2012 #3Just Joined!
- Join Date
- Jul 2012
- Posts
- 9
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:
[stackoverflow.com/questions/1202347/how-can-i-pass-a-password-from-a-bash-script-to-aptitude-for-installing-mysql]
orCode:sudo DEBIAN_FRONTEND=noninteractive aptitude install -q -y
There is also:Code:#!/bin/bash installnoninteractive(){ sudo bash -c "DEBIAN_FRONTEND=noninteractive aptitude install -q -y $*" } installnoninteractive slapd
For using of 'expect':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
but for 'expect' it needs to install the package.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
After testing all these solutions, i prefer the first:
It's perfect for me.Code:DEBIAN_FRONTEND=noninteractive aptitude install -q -y



