Wednesday, March 24, 2010

Sed is you friend - managing the passwords for the boostrap process

For MS Windows we have opted to preseed a set of passwords so users don't have to type all those passwords. That however involves changing a bunch of config files in the bootstrap directory. Doing that manually for every release was just out of the question. Sed comes to the rescue.
echo off

SET SED=C:\bin\sed.exe
SET VER=12.2
SET WORKINGDIR=C:\workplace\gnumed-server.%VER%\server\bootstrap
SET GMDBOPWD=gm-dbpass
SET PGPWD=postgrespassword

echo # patching files in %WORKINGDIR%
for %%f in (*.conf) do %SED% -i "s/password = /password = %GMDBOPWD%/g" %%f
for %%f in (*.conf) do %SED% -i "s/#password =/password = %PGPWD%/g" %%f
echo # clean up
del sed*
That is magic. No more messing around and screwing up.

No comments: