File: realmctl

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 (938 lines) | stat: -rwxr-xr-x 21,112 bytes parent folder | download
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
#!/usr/bin/perl
#
# Copyright 2012 SPARTA, Inc.  All rights reserved.  See the COPYING
# file distributed with this software for details.
#
#
# realmctl
#
#	This script controls the realms daemon.
#	See the pod for more details.
#


use strict;

use Getopt::Long qw(:config no_ignore_case_always);

use Net::DNS::SEC::Tools::conf;
use Net::DNS::SEC::Tools::realmmgr;
use Net::DNS::SEC::Tools::rolllog;
use Net::DNS::SEC::Tools::tooloptions;

#
# Version information.
#
my $NAME   = "realmctl";
my $VERS   = "$NAME version: 1.13.0";
my $DTVERS = "DNSSEC-Tools Version: 1.13";

#######################################################################

#
# Data required for command line options.
#
my %options = ();			# Filled option array.
my @opts =
(
	"allstart",			# Start all realms.
	"allstop",			# Stop all realms.
	"cmd",				# Command to execute in a realm.
	"command",			# Command to execute in a realm.
	"halt:s",			# Shutdown dtrealms.
	"display",			# Turn on dtrealms' graphical display.
	"logfile=s",			# Set dtrealms' log file.
	"loglevel:s",			# Set dtrealms' logging level.
	"logtz=s",			# Set dtrealms' logging timezone.
	"nodisplay",			# Turn off dtrealms' graphical display.
	"startrealm",			# Restart the suspended, named realm(s).
	"shutdown:s",			# Shutdown dtrealms.
	"stoprealm",			# Stop the named realm(s).
	"status",			# Get dtrealms' status.
	"realmstatus",			# Get status of realms.

	"Version",			# Display the version number.
	"quiet",			# Don't print anything.
	"help",				# Give a usage message and exit.
);

#
# Flags for the options.  Variable/option mapping should obvious.
#
my $commandcount    = 0;

my $allstopflag	    = 0;
my $allstartflag    = 0;
my $cmdstr	    = '';
my $dispflag	    = 0;
my $logfileflag	    = 0;
my $loglevelflag    = 0;
my $logtzflag	    = 0;
my $nodispflag	    = 0;
my $startrealmflag  = 0;
my $shutdownflag    = 0;
my $stoprealmflag   = 0;
my $statusflag	    = 0;
my $realmsstatflag  = 0;

my $quiet	    = 0;
my $version	    = 0;		# Display the version number.

#######################################################################


my $ret;				# Return code from main().

$ret = main();
exit($ret);

#-----------------------------------------------------------------------------
# Routine:	main()
#
# Purpose:	Yeah, yeah, a main() isn't necessary.  However, it offends my
#		sense of aesthetics to have great gobs of code on the same
#		level as a pile of globals.
#
#		But what about all those globals, you ask...
#
sub main()
{
	my $argc = @ARGV;		# Number of command line arguments.

	my $rcret = 0;			# Return code for realmctl.
	my $ret;			# Return code from dtrealms.
	my $resp;			# Response message from dtrealms.
	my $olderr;			# Saved error action.

	#
	# Use the packed config file if we're running as part of a packed
	# configuration.
	#
	if(runpacked())
	{
		setconffile("$ENV{'PAR_TEMP'}/inc/dnssec-tools.conf");
	}

	#
	# Check our options.  All the commands are alphabetized, except
	# for shutdown.  We'll save that for last.
	#
	doopts($argc);

	#
	# Run our configuration checks and make sure any error messages
	# will be printed.
	#
	$olderr = erraction(ERR_MSG);
	if(dt_confcheck(0) > 0)
	{
		print STDERR "realmctl:  configuration checks failed, can't send commands\n";
		exit(201);
	}
	erraction($olderr);

	#
	# If dtrealms isn't running, we'll give an error message and exit.
	# Some realmmgr_running() implementations may not be fool-proof.
	#
	if(realmmgr_running() != 1)
	{
		print STDERR "dtrealms is not running\n";
		exit(200);
	}

	#
	# Send commands for all the specified options.
	#
	if($cmdstr ne '')
	{
		if(! sendcmd(REALMCMD_COMMAND,$cmdstr))
		{
			print STDERR "realmctl:  error sending command COMMAND\n";
			exit(1);
		}

		($ret, $resp) = realmmgr_getresp();
		if(($ret == REALMCMD_RC_BADEVENT) && ($resp eq 'realm command timed out'))
		{
			print "realm command timed out\n";
		}
		elsif($resp eq '')
		{
			print "command returned no output; return code - $ret\n";
		}
		else
		{
			chomp $resp;
			print "command executed on realm\nreturned:\n$resp\n";
		}
	}
	elsif($dispflag)
	{
		if(! sendcmd(REALMCMD_DISPLAY,1))
		{
			print STDERR "realmctl:  error sending command DISPLAY\n";
			exit(1);
		}

		($ret, $resp) = realmmgr_getresp();
		if(($ret == REALMCMD_RC_OKAY) && ($ret ne ""))
		{
			print "dtrealms display started\n";
		}
		else
		{
			print STDERR "dtrealms display not started\n";
			$rcret++;
		}
	}
	elsif($logfileflag)
	{
		if(! sendcmd(REALMCMD_LOGFILE,$logfileflag))
		{
			print STDERR "realmctl:  error sending command LOGFILE\n";
			exit(1);
		}

		($ret, $resp) = realmmgr_getresp();
		if($ret == REALMCMD_RC_OKAY)
		{
			print "dtrealms log file set to $logfileflag\n";
		}
		else
		{
			print STDERR "log-level set failed:  $resp\n";
			$rcret++;
		}
	}
	elsif($loglevelflag)
	{
		if(rolllog_validlevel($loglevelflag) == 0)
		{
			print STDERR "invalid dtrealms log level: $loglevelflag\n";
			$rcret++;
		}
		else
		{
			if(! sendcmd(REALMCMD_LOGLEVEL,$loglevelflag))
			{
				print STDERR "realmctl:  error sending command LOGLEVEL\n";
				exit(1);
			}

			($ret, $resp) = realmmgr_getresp();
			if($ret == REALMCMD_RC_OKAY)
			{
				print "dtrealms log level set to $loglevelflag\n";
			}
			else
			{
				print STDERR "log-level set failed:  $resp\n";
				$rcret++;
			}
		}
	}
	elsif($logtzflag)
	{
		if(! sendcmd(REALMCMD_LOGTZ,$logtzflag))
		{
			print STDERR "realmctl:  error sending command LOGTZ\n";
			exit(1);
		}

		($ret, $resp) = realmmgr_getresp();
		if($ret == REALMCMD_RC_OKAY)
		{
			print "dtrealms log timezone set to $logtzflag\n";
		}
		else
		{
			print STDERR "log-tz set failed:  $resp\n";
			$rcret++;
		}
	}
	elsif($nodispflag)
	{
		if(! sendcmd(REALMCMD_DISPLAY,0))
		{
			print STDERR "realmctl:  error sending command DISPLAY\n";
			exit(1);
		}

		($ret, $resp) = realmmgr_getresp();
		if($ret == REALMCMD_RC_OKAY)
		{
			print "dtrealms display stopped\n";
		}
		else
		{
			print STDERR "dtrealms display not stopped\n";
			$rcret++;
		}
	}
	elsif($realmsstatflag)
	{
		if(! sendcmd(REALMCMD_REALMSTATUS))
		{
			print STDERR "realmctl:  error sending command REALMSTATUS\n";
			exit(1);
		}

		($ret, $resp) = realmmgr_getresp();
		if($ret == REALMCMD_RC_OKAY)
		{
			realmstatus("$resp");
		}
		else
		{
			print STDERR "realmstatus failed:  \"$resp\"\n";
			$rcret++;
		}
	}
	elsif($startrealmflag)
	{
		if(@ARGV == 0)
		{
			print STDERR "realmctl: -startrealm missing realm argument\n";
			exit(2);
		}

		foreach my $realm (@ARGV)
		{
			if(! sendcmd(REALMCMD_STARTREALM,$realm))
			{
				print STDERR "realmctl:  error sending command STARTZONE($realm)\n";
				exit(1);
			}

			($ret, $resp) = realmmgr_getresp();
			if($ret == REALMCMD_RC_OKAY)
			{
				print "realm $realm started\n";
			}
			else
			{
				print STDERR "unable to start realm $realm:  \"$resp\"\n";
				$rcret++;
			}
		}
	}
	elsif($allstartflag)
	{
		if(! sendcmd(REALMCMD_STARTALL,$allstartflag))
		{
			print STDERR "realmctl:  error sending command STARTALL\n";
			exit(1);
		}

		($ret, $resp) = realmmgr_getresp();
		if($ret == REALMCMD_RC_OKAY)
		{
			print "$resp\n";
		}
		else
		{
			print STDERR "$resp\n";
			$rcret++;
		}
	}
	elsif($allstopflag)
	{
		if(! sendcmd(REALMCMD_STOPALL,$stoprealmflag))
		{
			print STDERR "realmctl:  error sending command STOPALL\n";
			exit(1);
		}

		($ret, $resp) = realmmgr_getresp();
		if($ret == REALMCMD_RC_OKAY)
		{
			print "$resp\n";
		}
		else
		{
			print STDERR "$resp\n";
			$rcret++;
		}
	}
	elsif($stoprealmflag)
	{
		if(@ARGV == 0)
		{
			print STDERR "realmctl: -stoprealm missing realm argument\n";
			exit(2);
		}

		foreach my $realm (@ARGV)
		{
			if(! sendcmd(REALMCMD_STOPREALM,$realm))
			{
				print STDERR "realmctl:  error sending command STOPREALM($realm)\n";
				exit(1);
			}

			($ret, $resp) = realmmgr_getresp();
			if($ret == REALMCMD_RC_OKAY)
			{
				print "realm $realm stopped\n";
			}
			else
			{
				print STDERR "unable to stop realm $realm:  \"$resp\"\n";
				$rcret++;
			}
		}
	}
	elsif($statusflag)
	{
		if(! sendcmd(REALMCMD_STATUS))
		{
			print STDERR "realmctl:  error sending command STATUS\n";
			exit(1);
		}

		($ret, $resp) = realmmgr_getresp();
		if($ret == REALMCMD_RC_OKAY)
		{
			print "$resp";
		}
		else
		{
			print STDERR "status failed:  \"$resp\"\n";
			$rcret++;
		}
	}
	elsif($shutdownflag)
	{
		if($shutdownflag == 2)
		{
			my $pid = realmmgr_getid();
			if(kill("INT", $pid) < 1)
			{
				print STDERR "realmctl:  unable to send immediate SHUTDOWN\n";
				exit(1);
			}

			print STDERR "realmctl:  immediate SHUTDOWN notice sent to dtrealms\n";
			exit(0);
		}

		if(! sendcmd(REALMCMD_SHUTDOWN))
		{
			print STDERR "realmctl:  error sending command SHUTDOWN\n";
			exit(1);
		}
		($ret, $resp) = realmmgr_getresp();
		if($ret == REALMCMD_RC_OKAY)
		{
			print "$resp\n";
		}
		else
		{
			print STDERR "shutdown failed:  \"$resp\"\n";
			$rcret++;
		}
	}

	return($rcret);
}

#-----------------------------------------------------------------------------
# Routine:	doopts()
#
# Purpose:	This routine shakes and bakes our command line options.
#		A bunch of option variables are set according to the specified
#		options.  Then a little massaging is done to make sure that
#		the proper actions are taken.  A few options imply others, so
#		the implied options are set if the implying options are given.
#
sub doopts
{
	my $argc = shift;			# Command line argument count.
	my $argcnt;				# Specified-argument count.

	#
	# Give a usage flag if there aren't any options.
	#
	usage() if($argc == 0);

	#
	# Parse the options.
	#
	GetOptions(\%options,@opts, verbose => 1) || usage();

	#
	# Handle a couple administrative tasks.
	#
	usage()   if(defined($options{'help'}));
	version() if($version);

	#
	# Set our option variables based on the parsed options.
	#
	$quiet = $options{'quiet'} || 0;

	#
	# Command Options
	#

	if(exists($options{'cmd'}) || exists($options{'command'}))
	{
		if(@ARGV < 2)
		{
			print STDERR "-command requires at least two arguments -- <realm> <command> <arguments>\n";
			exit(4);
		}
		$cmdstr = join(' ',@ARGV);
		$commandcount++;
	}
	if(exists($options{'display'}))
	{
		$dispflag = $options{'display'};
		$commandcount++;
	}
	if(exists($options{'logfile'}))
	{
		$logfileflag = $options{'logfile'};
		$commandcount++;
	}
	if(exists($options{'loglevel'}))
	{
		$loglevelflag = $options{'loglevel'};
		$commandcount++;
	}
	if(exists($options{'logtz'}))
	{
		$logtzflag = $options{'logtz'};
		$commandcount++;
	}
	if(exists($options{'nodisplay'}))
	{
		$nodispflag = $options{'nodisplay'};
		$commandcount++;
	}
	if(exists($options{'realmstatus'}))
	{
		$realmsstatflag = $options{'realmstatus'};
		$commandcount++;
	}
	if(exists($options{'startrealm'}))
	{
		$startrealmflag = $options{'startrealm'};
		$commandcount++;
	}
	if(exists($options{'shutdown'}) || exists($options{'halt'}))
	{
		$shutdownflag =	1;

		if(($options{'shutdown'} eq 'now') || ($options{'halt'} eq 'now'))
		{
			$shutdownflag = 2;
		}

		$commandcount++;
	}
	if(exists($options{'allstart'}))
	{
		$allstartflag = $options{'allstart'};
		$commandcount++;
	}
	if(exists($options{'allstop'}))
	{
		$allstopflag = $options{'allstop'};
		$commandcount++;
	}
	if(exists($options{'stoprealm'}))
	{
		$stoprealmflag = $options{'stoprealm'};
		$commandcount++;
	}
	if(exists($options{'status'}))
	{
		$statusflag = $options{'status'};
		$commandcount++;
	}
	if(exists($options{'Version'}))
	{
		$version = $options{'Version'};
		$commandcount++;
	}

	#
	# Ensure that only one command argument was given.
	# We'll get rid of the non-command options before checking.
	#

	if($commandcount > 1)
	{
		print STDERR "only one command argument may be specified per execution\n";
		exit(3);
	}
	elsif($commandcount < 1)
	{
		print STDERR "a command argument must be specified\n";
		exit(5);
	}

	#
	# Close our output descriptors if the -quiet option was given.
	#
	if($quiet)
	{
		close(STDOUT);
		close(STDERR);
	}

	#
	# Show the logging levels if one wasn't specified.
	#
	if(defined($options{'loglevel'}) && ($options{'loglevel'} eq ''))
	{
		showloglevels();
	}

}

#----------------------------------------------------------------------
# Routine:	realmstatus()
#
# Purpose:	Print the status for all the realms.
#
sub realmstatus
{
	my $resp = shift;			# Full response from dtrealms.

	my @lines;				# Line-split responses.
	my @rnames = ();			# Realm names.
	my @states = ();			# Realm states.
	my @phases = ();			# Zone/phase counts.

	my $rml = -1;				# Max. length of realm names.

	#
	# Check for dormancy.
	#
	if($resp eq 'no managed realms')
	{
		print "$resp\n";
		return;
	}

	#
	# Divide the pieces of each response line into the data arrays.
	#
	@lines = split /\n/, $resp;
	foreach my $line (@lines)
	{
		my $len;
		my @slices = split /\t/, $line;

		#
		# Save the atoms.
		#
		push @rnames, $slices[0];
		push @states, $slices[1];
		push @phases, $slices[2];

		#
		# Save the length of the longest realm name.
		#
		$len = length($slices[0]);
		$rml = $len if($len > $rml);

	}

	#
	# Pretty-print the realm-status data from dtrealms.
	#
	for(my $ind=0; $ind < @rnames; $ind++)
	{
		my @atoms;				# Actual phase counts.

		if($states[$ind] eq 'inactive')
		{
			printf "%-$rml.*s    inactive\n", $rml, $rnames[$ind];
			next;
		}

		@atoms = split /\//, $phases[$ind];

		printf "%-$rml.*s    active      normal: $atoms[0]    ZSK: $atoms[1]    KSK: $atoms[2]    KSK phase 6: $atoms[3]\n",
			$rml, $rnames[$ind];
	}
}

#----------------------------------------------------------------------
# Routine:	sendcmd()
#
# Purpose:	Send the command to dtrealms.
#
sub sendcmd
{
	my $cmd = shift;			# Command to send dtrealms.
	my $arg = shift;			# Command's optional argument.
	my $ret;				# Return code.

	$ret = realmmgr_sendcmd(CHANNEL_WAIT,$cmd,$arg);
	return($ret);
}


#----------------------------------------------------------------------
# Routine:	showloglevels()
#
# Purpose:	Print the logging levels and exit.
#
sub showloglevels
{
	my @levels = rolllog_levels();			# Valid logging levels.

	print "valid dtrealms logging levels:\n";

	foreach my $level (@levels)
	{
		my $lnum;				# Numeric logging level.

		$lnum = rolllog_num($level);
		print "\t$level\t\t($lnum)\n";
	}

	exit(0);
}

#----------------------------------------------------------------------
# Routine:	version()
#
# Purpose:	Print the version number(s) and exit.
#
sub version
{
	print STDERR "$VERS\n";
	print STDERR "$DTVERS\n";

	exit(0);
}

#-----------------------------------------------------------------------------
# Routine:	usage()
#
sub usage
{
	print STDERR "usage:  realmctl [options] \n";
	print STDERR "\t-allstart                        start all realms\n";
	print STDERR "\t-allstop                         stop all realms\n";
	print STDERR "\t-command -- <realm> <command>    send command to a realm\n";
	print STDERR "\t-display                         start graphical display\n";
	print STDERR "\t-halt                            shutdown dtrealms and its realms\n";
	print STDERR "\t-logfile <logfile>               set log file\n";
	print STDERR "\t-loglevel <loglevel>             set logging level\n";
	print STDERR "\t-logtz <log-timezone>            set logging timezone\n";
	print STDERR "\t-nodisplay                       stop graphical display\n";
	print STDERR "\t-realmstatus                     get status of realms\n";
	print STDERR "\t-shutdown                        shutdown dtrealms and its realms\n";
	print STDERR "\t-startrealm <realm>              restart named suspended realm\n";
	print STDERR "\t-status                          get dtrealms' status\n";
	print STDERR "\t-stoprealm <realm>               stop named realm\n";
	print STDERR "\t-Version                         display version number\n";
	print STDERR "\t-quiet                           don't give any output\n";
	print STDERR "\t-help                            help message \n";
	exit(0);
}

1;

##############################################################################
#

=pod

=head1 NAME

realmctl - Send commands to the DNSSEC-Tools realms daemon

=head1 SYNOPSIS

  realmctl [options]

=head1 DESCRIPTION

The B<realmctl> command sends commands to B<dtrealms>, the DNSSEC-Tools realms
daemon.  In most cases, B<dtrealms> will send a response to B<realmctl>.
B<realmctl> will print a success or failure message, as appropriate.  Only one
option may be specified on a command line.

=head1 OPTIONS

The following options are handled by B<realmctl>.

=over 4

=item B<-allstart>

Starts all suspended realms.

=item B<-allstop>

Stops all running realms.

=item B<-cmd -- realm cmd args>

=item B<-command -- realm cmd args>

Sends a command to the specified realm.  The command given as I<cmd> will be
sent to the B<rollerd> running in realm I<realm>.

The double-dash given above is critical for proper argument parsing of the
command line.

All command-line arguments, as I<args> above, following the realm name and
command name will be sent as the command.

Whatever output the command gives will be returned to B<realmctl>, which will
then print that output.  The command's return code will be appended to the
command's output.  No attempt will be made to analyze the output for
success or failure.

For example, this command will tell the realm B<giant-isp> to stop
rollover of zone I<bob.example.com>:

   $ realmctl -command -- giant-isp rollctl -skipzone bob.example.com

B<Warning:>  This is an inherently dangerous command.  When choosing a user
under which the realm and rollover commands will be executed, be aware that
this problem exists.  B<realmctl> I<may> be modified in the future to
restrict the commands that may be executed with this option.

=item B<-display>

Starts the realms status GUI.

=item B<-halt> [now]

Cleanly halts B<dtrealms> execution.

=item B<-logfile logfile>

Sets the B<dtrealms> log file to I<logfile>.  This must be a valid logging
file, meaning that if I<logfile> already exists, it must be a regular file.
The only exceptions to this are if I<logfile> is B</dev/stdout> or
B</dev/tty>.

=item B<-loglevel loglevel>

Sets the B<dtrealms> logging level to I<loglevel>.
This must be one of the valid logging levels defined in B<realmmgr.pm(3)>.

If a logging level is not specified, then the list of valid levels will be
printed and B<realmctl> will exit.  The list is given in both text and numeric
forms.

=item B<-logtz logtz>

Sets the B<dtrealms> logging timezone to I<loglevel>.  This must be either
I<gmt> (for Greenwich Mean Time or I<local> (for the host's local time.)

=item B<-nodisplay>

Stops the realms status GUI.

=item B<-realmstatus>

Gets the current status of all the realms from B<dtrealms>.  For each realm,
the name, execution status, and zone counts are printed.  The zone counts
are, in order, the number of zones in normal state, the number of zones in
ZSK rollover, the number of zones in KSK rollover, and the number of zones
waiting in KSK phase 6.  The zone counts are determined by sending the
realm's rollover manager an information request.  Therefore, if the zone is
inactive, the zone counts are not included.

Example:

    dev     active     normal: 18   ZSK: 3   KSK: 1   KSK phase 6: 0
    test-r  inactive
    money   active     normal: 10   ZSK: 0   KSK: 0   KSK phase 6: 1

=item B<-shutdown>

Synonym for B<-halt>.

=item B<-startrealm realm>

Starts the suspended realm named by I<realm>.  Multiple realms can be
specified on the command line.  For instance, this command will send the
I<startrealm> command to B<dtrealms> for three realms.

    $ realmctl -startrealm testing production customers

=item B<-status>

Has B<dtrealms> write several of its operational parameters to its log file.
The parameters are also reported to B<realmctl>, which prints them to the
screen.

=item B<-stoprealm realm>

Stops the realm named by I<realm>.  Multiple realms can be specified on the
command line.  For instance, this command will send the I<stoprealm> command
to B<dtrealms> for two realms.

    $ realmctl -stoprealm big-isp-3 misc-customers

=item B<-Version>

Displays the version information for B<realmctl> and the DNSSEC-Tools package.

=item B<-quiet>

Prevents output from being given.  Both error and non-error output is stopped.

=item B<-help>

Displays a usage message.

=back

=head1 EXIT CODES

B<realmctl> may give the following exit codes:

=over 4

=item 0 - Successful execution

=item 1 - Error sending the command to B<dtrealms>.

=item 2 - Missing realm argument.

=item 3 - Too many command options specified.

=item 4 - Missing argument for B<-cmd> or B<-command>.

=item 5 - No option specified.

=item 200 - dtrealms is not running.

=item 201 - Configuration file checks failed.

=back

=head1 COPYRIGHT

Copyright 2012 SPARTA, Inc.  All rights reserved.
See the COPYING file included with the DNSSEC-Tools package for details.

=head1 AUTHOR

Wayne Morrison, tewok@tislabs.com

=head1 SEE ALSO

B<Net::DNS::SEC::Tools::realmmgr.pm(3)>,
B<Net::DNS::SEC::Tools::realm.pm(3)>

B<dtrealms(8)>,
B<rollctl(8)>
B<rollerd(8)>

=cut