I'm using ssmtp to provide simple mail services on a Linux box.
I want the configuration to be as simple as possible to migrate between different boxes, but using different users and passwords for different boxes. So for example I might decide to use the device's MAC address as the username, and derive a password from that somehow. That way, I can install a filesystem image onto a device and it will self-configure. (It may be that the device will call a web service with it's MAC address and retreive settings that way, but once the script knows what the user and password details are I still need a method to "insert" them into the configuration files.)
So, my question is how best to "insert" these details into a config file (in this case /etc/ssmtp/ssmtp.conf but I'm looking for a general solution).
One option would be to simply recreate these files on startup inserting relevant details - or, better, to use sed (or maybe awk) to replace the relevant parts of the config. Is that the "right" way to do it? Obviously I'd need to restart any relevant services after this is done (or better, make sure it happens before they start).
Is there a general way to insert an environment variable or other value into a configuration file?
Mark
On Wednesday, 9 May 2012 at 14:17, Mark Rogers wrote:
I'm using ssmtp to provide simple mail services on a Linux box.
I want the configuration to be as simple as possible to migrate between different boxes, but using different users and passwords for different boxes. So for example I might decide to use the device's MAC address as the username, and derive a password from that somehow. That way, I can install a filesystem image onto a device and it will self-configure. (It may be that the device will call a web service with it's MAC address and retreive settings that way, but once the script knows what the user and password details are I still need a method to "insert" them into the configuration files.)
So, my question is how best to "insert" these details into a config file (in this case /etc/ssmtp/ssmtp.conf but I'm looking for a general solution).
One option would be to simply recreate these files on startup inserting relevant details - or, better, to use sed (or maybe awk) to replace the relevant parts of the config. Is that the "right" way to do it? Obviously I'd need to restart any relevant services after this is done (or better, make sure it happens before they start).
Is there a general way to insert an environment variable or other value into a configuration file?
Something like Puppet [http://projects.puppetlabs.com/projects/puppet] or Chef [http://www.opscode.com/chef/%5D?
On 09/05/12 14:30, David Reynolds wrote:
Something like Puppet [http://projects.puppetlabs.com/projects/puppet] or Chef [http://www.opscode.com/chef/%5D?
I think maybe one day this would be a worthwhile approach, but for the time being I'm wanting something more "controlled" from the device end. At the moment I think these approaches would be overkill for the limited changes I need to make per-device.
But thanks for the suggestion because it's an angle I hadn't considered.