I have several machines (running Ubuntu LTS 12.4 64-bit) which need to be configured in the same way, so I created a shell script which will run automatically the first time the machine boots. It works for the most part, but any call to apt-get fails. As an example, here are two commands I want to execute.
debconf-set-selections ./files/ldap.preseed
apt-get -y install ldap-auth-client
Here is the result if I type those lines directly:
root@spare:/tmp/scripts# debconf-set-selections ./files/ldap.preseed
root@spare:/tmp/scripts# apt-get -y install ldap-auth-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be installed:
ldap-auth-config libnss-ldap libpam-ldap
The following NEW packages will be installed:
ldap-auth-client ldap-auth-config libnss-ldap libpam-ldap
0 upgraded, 4 newly installed, 0 to remove and 67 not upgraded.
Need to get 0 B/200 kB of archives.
After this operation, 877 kB of additional disk space will be used.
Preconfiguring packages...
[and so on...]
But if I execute a shell script containing only those lines, this happens:
root@spare:/tmp/scripts# ./ldap.cr
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package ldap-auth-client
The same thing occurs when I run the script using sudo, or chown it to root first. What is the difference, to the program, if it is being called directly or through a shell script? And is it possible to convince it otherwise?
EDIT: More information:
root@spare:/tmp/scripts# apt-cache policy ldap-auth-client
ldap-auth-client:
Installed: (none)
Candidate: 0.5.3
Version table:
0.5.3.0
500 http://us.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
cat ldap.cr
? And are both on the same system?apt-cache policy ldap-auth-client
– Braiam Oct 16 '14 at 15:06