Hi all,

I have just written the following fragment for site-vs-batch.pl which,
rather than using the hard coded files, will allow you to specify
which files are searched for the key words #HOSTNAME# and
#BINDADDR# (I found whilst building a skel that I had quite a few
config files that should contain the VSs hostname / IP)....

-----------------------------------
  my @files_to_upd = (  'etc/httpd/conf/httpd.conf',
                        'etc/ssh/sshd_config',
                        'etc/ssh2/sshd2_config');

  print "Replace #HOSTNAME# and #BINDADDR# in files...\n";

  foreach $file (@files_to_upd) {

    if (-e "$vsdir/$file") {

      print "- $file\n";
      # get the name of the file (exc. directory)
      $file =~ m/([^\/]*)$/;
      $filename = $1;

      if (!$filename) { die ('Filename is blank!'); }

      # copy to temp directory
      `cp $vsdir/$file /tmp/$filename`;
      open (FILEIN, "/tmp/$filename") or die "cant open: $!";
      open (FILEOUT, ">$vsdir/$file");
      while (<FILEIN>) {
        $_ =~ s/\#BINDADDR\#/$ip/g;
        $_ =~ s/\#HOSTNAME\#/$fqdn/g;
        print FILEOUT $_
      }
      close (FILEOUT);
      close (FILEIN);
      unlink ("/tmp/$filename");
    }

  }
-----------------------------------------

Hope this is useful to someone.

Cyas,
-- 
Ben Kennish
[EMAIL PROTECTED]

------------------------- The freeVSD Support List --------------------------
Subscribe:   mailto:[EMAIL PROTECTED]?body=subscribe%20freevsd-support
Unsubscribe: mailto:[EMAIL PROTECTED]?body=unsubscribe%20freevsd-support
Archives:    http://freevsd.org/support/mail-archives/freevsd-support
-----------------------------------------------------------------------------

Reply via email to