Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / script / add_header.pl
1 #!/usr/bin/perl
2
3 use strict;
4 my $fn = shift @ARGV;
5 my $old = `cat $fn`;
6
7 my $header = `cat doc/header.txt`;
8
9 # strip existing header
10 my $new = $old;
11 if ($new =~ /^(.*)\* Ceph - scalable distributed file system/s) {
12         my ($a,@b) = split(/\*\/\n/, $new);
13         $new = join("*/\n",@b);
14 }
15 $new = $header . $new;
16
17 if ($new ne $old) {
18         open(O, ">$fn.new");
19         print O $new;
20         close O;
21         system "diff $fn $fn.new";
22         rename "$fn.new", $fn;
23         #unlink "$fn.new";
24
25 }
26