File: phaser

package info (click to toggle)
dnssec-tools 1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 16,064 kB
  • sloc: perl: 44,399; ansic: 31,547; cpp: 21,306; sh: 15,813; xml: 2,113; makefile: 1,390; pascal: 836; python: 290; csh: 11
file content (76 lines) | stat: -rwxr-xr-x 1,478 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/perl
# Copyright 2006-2008 SPARTA, Inc.  All rights reserved.
# See the COPYING file included with the DNSSEC-Tools package for details.
#
# phaser
#
#	This script adjusts the phasestart lines in a DNSSEC-Tools rollrec
#	file so the current phases have only just started.
#
#	This is ONLY intended for building testing environments!
#

usage() if(@ARGV == 0);

$rrf = $ARGV[0];

#
# Get the GMT time and lop off the trailing newline.
#
$tempus = gmtime;
chomp $tempus;

#
# Split the time up into three chunks, with the minutes in the middle.
#
$tempus =~ /(.*?:)(..)(:.*)/;
$date1 = $1;
$min   = $2;
$date2 = $3;

#
# Drop the minutes back a shade.
#
$min = adjuster($min,1);

#
# Build the new "phasestart" lines for the rollrec file.
#
$phase1 = sprintf("phasestart	\"$date1%02d$date2\"",$min);

#
# Fix the "phasestart" lines in the rollrec file.
#
system("perl -pi -e 's/phasestart/$phase1/' $rrf");

print "gmtime - $tempus\n";
print "phase  - $phase1\n";

exit(0);

#########################################################################
#
# Adjust a minutes count by a certain amount, making sure it doesn't go
# negative.
#
sub adjuster
{
	my $min = shift;				# Minutes to adjust.
	my $adj = shift;				# Adjustment value.

	$min -= $adj;

	$min = 0 if($min < 0);
	return($min);
}

#########################################################################
#
# Give usage and exit.
#
sub usage
{
	print STDERR "usage:  phaser <rollrec-file>\n";
	exit(0);
}