#!/usr/bin/env perl use 5.008; use strict; use warnings; use Getopt::Long; use Sys::Hostname; use File::Basename; use Helios::Config; use Helios::Error; use Helios::LogEntry::Levels ':all'; our $VERSION = '2.81'; our $Service_Name; our $Param_Name; our $Host = hostname(); our $Help_Mode = 0; our $Debug_Mode = 0; our $Config; our $Value; GetOptions ( "service=s" => \$Service_Name, "param=s" => \$Param_Name, "H|hostname=s" => \$Host, "help" => \$Help_Mode, "debug" => \$Debug_Mode ); # debug mode if ($Debug_Mode) { Helios::Config->debug(1); } # help mode if ($Help_Mode) { require Pod::Usage; Pod::Usage::pod2usage(-verbose => 2, -exitstatus => 0); } # stop if we were not given at least service and param unless ($Service_Name && $Param_Name) { warn "$0: A service name and config parameter name are required.\n"; exit(1); } # parse the global config; we'll need it eval { $Config = Helios::Config->parseConfig(); 1; } or do { my $E = $@; warn "$0: Helios::Config ERROR: $E\n"; exit(1); }; # OK, now use Helios::Config to attempt to find the # param in the collective database eval { $Value = Helios::Config->unsetParam( service => $Service_Name, hostname => $Host, param => $Param_Name ); 1; } or do { my $E = $@; warn "$0: Helios::Config ERROR: $E\n"; exit(1); }; # if we found the param, print its value # if not, we print nothing if ( defined($Value) ) { print STDOUT "Service: $Service_Name Hostname: $Host Param: $Param_Name CLEARED.\n"; } exit(0); =head1 NAME helios_config_unset - delete a config param's value from the Helios database =head1 SYNOPSIS helios_config_unset --service=<service name> --param=<param name> [--hostname=<hostname>] # delete the "endpoint_url" param for MyService on all hosts helios_config_unset --service=MyService --hostname=* --param=endpoint_url # delete the "port" param for MyService on the current host helios_config_unset --service=MyService --param=port =head1 DESCRIPTION The helios_config_unset command can be used to delete configuration parameters for a service from the Helios collective database. This allows Helios configuration parameters to be deleted from the command line or shell scripts. If the --hostname (or -H) parameter is not specifed, helios_config_unset will default to the current host. If you want a parameter to be removed for a service across an entire collective, set the --hostname parameter to '*'. WARNING: Be careful with deleting parameters with --hostname=* as you will deleting the parameter for every instance of your service in the entire collective! =head1 AUTHOR Andrew Johnson, E<lt>lajandy at cpan dot orgE<gt> =head1 COPYRIGHT AND LICENSE Copyright (C) 2013-4 by Logical Helion, LLC. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available. =head1 WARRANTY This software comes with no warranty of any kind. =cut